home *** CD-ROM | disk | FTP | other *** search
-
-
- '(* ------------------------------------------------------ *)
- '(* EINGABE.INC *)
- '(* (c) 1988 TOOLBOX Version 2'89 *)
- '(* ------------------------------------------------------ *)
-
- SUB Eingabe(feldlen%, spos%, zpos%, vartyp$, antwort$)
-
- LOCAL sammel$ 'sammelt die geprüften Zeichen
- LOCAL taste$ 'für das letzte eingegebene Zeichen
- LOCAL dezimal% 'Schalter für Dezimalpunkt
- LOCAL muell$ 'Dummy zum Löschen des Tastaturpuffers
- LOCAL punkte% 'zum Aufbau des Eingabefeldes
- LOCAL punkte$, schleife%
-
- REM In Quick Basic müssen die LOCAL-Deklarationen
- REM wegfallen, weil die Variablen in einer Prozedur
- REM per Default Lokal sind
-
- taste$ = CHR$(1) 'Einstieg in die Hauptschleife
- IF zpos% < 1 OR zpos% > 25 THEN GOSUB Fehler
- IF spos% < 1 OR spos% > 80 THEN GOSUB Fehler
- IF feldlen% < 1 OR feldlen% > (79 - spos%) THEN
- GOSUB Fehler
- END IF
- IF vartyp$ <> "t" AND vartyp$ <> "w" THEN GOSUB Fehler
-
- LOCATE zpos%, spos%
- PRINT CHR$(242); 'Zeichen für den Prompt "≥"
- PRINT STRING$(feldlen%, "_");
-
- WHILE taste$ <> CHR$(13) 'Verlassen mit < RETURN >
- taste$ = ""
- WHILE taste$ = ""
- taste$ = INKEY$ 'Warte und hole erstes Zeichen
- WEND
- muell$ = INKEY$
- IF muell$ = "" THEN GOSUB Abfrage 'Tastaturpuffer leer
- WHILE muell$ <> ""
- muell$ = INKEY$ 'Löschen Tastaturpuffer
- WEND
- WEND
- antwort$ = sammel$ 'Ergebnis bereitstellen
- GOTO Feierabend 'Unterprogramme werden
- 'übersprungen
-
- REM * ---------------------------------------------------- *
- Abfrage:
- DO
- IF ASC(taste$)=27 OR ASC(taste$)=13 THEN GOTO ExitLoop
- IF ASC(taste$)<13 AND ASC(taste$)<>8 THEN GOTO ExitLoop
- IF ASC(taste$) = 8 AND sammel$ = "" THEN GOTO ExitLoop
- IF ASC(taste$) = 8 AND RIGHT$(sammel$, 1) = "." THEN
- dezimal% = 0
- END IF
- IF ASC(taste$) = 8 THEN
- GOSUB Backspace
- GOTO Update
- END IF
-
- IF LEN(sammel$) = feldlen% THEN GOTO ExitLoop
-
- schleife% = -1
- WHILE vartyp$ = "w" AND schleife% = -1
-
- IF taste$ = "," THEN taste$ = "." 'Komma -> Punkt
-
- IF dezimal% = 0 AND ASC(taste$) = 46 THEN
- dezimal% = 1 'Dezimalflag setzen
- GOTO EndWhile
- END IF
-
- IF dezimal% = 1 AND ASC(taste$) = 46 THEN
- taste$ = ""
- GOTO EndWhile
- END IF
-
- IF taste$ = "-" AND sammel$ = "" THEN GOTO EndWhile
- 'erstes zeichen "-"
-
- IF ASC(taste$) > 47 AND ASC(taste$) < 58 THEN
- GOTO EndWhile
- END IF 'nur Ziffern zulassen
-
- taste$ = "" 'Falsche Eingabe, ignorieren
- EndWhile:
- schleife% = 0
- WEND
-
- sammel$ = sammel$ + taste$
- 'Anfügen des gültigen Zeichens
- Update:
- taste$ = ""
- punkte% = feldlen% - LEN(sammel$) 'Update Eingabefeldes
- IF punkte% <= 0 THEN '...am Feldende
- punkte$ = ""
- ELSE
- punkte$ = STRING$(punkte% - 1, "_")
- END IF
- LOCATE zpos%, spos%
- PRINT sammel$; '...bisherige Eingabe
- PRINT CHR$(242); '...Prompt "≥"
- PRINT punkte$; " "; '...Unterstriche
- LOOP UNTIL 1 = 1 'Bedingung für Endlosschleife
- ExitLoop:
- RETURN
-
- REM * ---------------------------------------------------- *
- Backspace:
- sammel$ = LEFT$(sammel$, LEN(sammel$) - 1)
- RETURN
-
- Fehler:
- LOCATE 25, 2
- BEEP: BEEP: BEEP
- PRINT "Fehlerhafte Parameterübergabe, Programmabbruch"
- END
- RETURN
-
- Feierabend:
- END SUB
-
- REM * ---------------------------------------------------- *