home *** CD-ROM | disk | FTP | other *** search
-
- '
- ' Get.String
- '
- ' written by scott dhomas trenn
- ' 797 Mitchell Street, Fredericton, NB, E3B 3S8, CANADA
- ' INTERNET: wilkie@jupiter.sun.csd.unb.ca
- '
- ' "Roll your own" String Requesters.
- '
- ' Parameters:
- ' SX = Window X position to begin text input
- ' SY = Window Y position to begin text input
- ' CharWidth = Font Width
- ' InputString$ = Initial string contents
- ' Length = Maximum length of input string
- ' Capitalize = YES (-1) : Converts input to all capitals
- ' NO (0) : Input stays as entered
- ' Color1 = Cursor color
- ' Color2 = Foreground color to display when inputting
- ' Color3 = Background color to display when inputting
- '
- '
- ' Full edit capability... CRSR LEFT/RIGHT, DEL, BACKSPACE, etc.
- ' Adds ability to use CRSR UP/DOWN for multiple strings (LINE 94)
- '
-
- DEFINT A-Z
- CONST NO = 0
-
- ' Example 1 - Single gadget
-
- iString$ = ""
- LINE (5,1)-(180,14),1,b
- Get.String 10,10,8,iString$,20,NO,1,2,0
-
- CLS
-
-
- ' Example 2 - Multiple gadgets with CRSR UP-DOWN
-
- Artist$ = "Artist" : Title$ = "Title" : Type$ = ""
- LINE (5,1)-(180,14),1,b : PRINT PTAB(10,10);Artist$;
- LINE (5,16)-(180,29),1,b : PRINT PTAB(10,25);Title$;
- LINE (5,31)-(180,44),1,b : PRINT PTAB(10,40);Type$;
-
- Get.1:
- Get.String 10,10,8,Artist$,20,NO,1,2,0
- IF iKey = 28 THEN Get.3 ' CRSR DOWN
- IF iKey = 29 THEN Get.2 ' CRSR UP
- IF iKey = 27 THEN Show.Results ' ESCAPE
- Get.2:
- Get.String 10,25,8,Title$,20,NO,1,2,0
- IF iKey = 28 THEN Get.1
- IF iKey = 29 THEN Get.3
- IF iKey = 27 THEN Show.Results
- Get.3:
- Get.String 10,40,8,Type$,20,NO,1,2,0
- IF iKey = 28 THEN Get.2
- IF iKey = 29 THEN Get.1
-
-
- ' Show all the result strings
- Show.Results:
- CLS : COLOR 1,0
- PRINT "iString$ = ";iString$
- PRINT
- PRINT "Artist$ = ";Artist$
- PRINT "Title$ = ";Title$
- PRINT "Type$ = ";Type$
- END
-
-
- SUB Get.String (VAL SX,VAL SY,VAL CharWidth,InputString$,VAL Length,VAL Capitalize,VAL Color1,VAL Color2,VAL Color3) STATIC
-
- SHARED iKey
- Position = LEN(InputString$)
- COLOR Color2,Color3 : PRINT PTAB(SX,SY);LEFT$(InputString$+SPACE$(Length), Length);
- Position.Cursor:
- IF Position + 1 > LEN(InputString$) THEN
- Character$ = " "
- ELSE
- Character$ = MID$(InputString$,Position + 1,1)
- END IF
- PRINT PTAB(SX+Position*CharWidth,SY);
- COLOR Color2,Color1: PRINT Character$;
- PRINT PTAB(SX+Position*CharWidth,SY);
- COLOR Color2,Color3
- Get.Key:
- iKey$ = INKEY$: IF iKey$ = "" THEN Get.Key
- iKey = ASC(iKey$)
- IF iKey > 31 AND iKey < 127 AND iKey <> 34 AND LEN(InputString$) < Length THEN
- IF Capitalize THEN iKey$ = UCASE$(iKey$)
- InputString$ = LEFT$(InputString$,Position) + iKey$ + RIGHT$(InputString$,LEN(InputString$)-Position)
- PRINT RIGHT$(InputString$,LEN(InputString$)-Position);
- INCR Position
- ELSEIF iKey = 13 OR iKey = 27 OR iKey = 28 OR iKey = 29 THEN
- PRINT Character$;
- EXIT SUB
- ELSEIF iKey = 8 AND LEN(InputString$) <> 0 AND Position <> 0 THEN
- PRINT Character$;
- PRINT PTAB(SX+(Position-1)*CharWidth,SY);
- PRINT RIGHT$(InputString$,LEN(InputString$)-Position);" ";
- InputString$ = LEFT$(InputString$,Position-1) + RIGHT$(InputString$,LEN(InputString$)-Position)
- DECR Position
- ELSEIF iKey = 127 AND LEN(InputString$) <> 0 AND Position < LEN(InputString$) THEN
- InputString$ = LEFT$(InputString$,Position) + RIGHT$(InputString$,LEN(InputString$)-Position-1)
- PRINT RIGHT$(InputString$,LEN(InputString$)-Position);" ";
- ELSEIF iKey = 31 AND Position <> 0 THEN
- PRINT Character$;
- DECR Position
- ELSEIF iKey = 30 AND Position <> LEN(InputString$) THEN
- PRINT Character$;
- INCR Position
- ELSE
- GOTO Get.Key
- END IF
- GOTO Position.Cursor
-
- END SUB
-
-