Posted: 1st Jan 2003 23:57
Here's some text and numeric input functions to help with more controlled way of inputting data. You can take out the:
SET TEXT FONT "Courier New"
SET TEXT SIZE 15
As i've only put that in due to me using a fixed width font when doing text input.


FUNCTION InputString(X AS INTEGER,Y AS INTEGER,InputLength AS INTEGER, Prompt$ AS STRING, PreviousString$ AS STRING)
` This routine will be the main input routine, the InputNum function will convert the number to a string and input with this function.
`
` X,Y Will be the coordinates on screen
` Prompt is a prompt on screen if Required
` Previous String if needed
`
` Setup Font and Characteristics
`
SET TEXT FONT "Courier New"
SET TEXT SIZE 15
SET TEXT OPAQUE
`
` Setup Temporary Veriables
`
PromptWidth=TEXT WIDTH(Prompt$)
InputX=X+PromptWidth+2
Res$=PreviousString$
CurrentPos=LEN(Res$)
IF InputLength""
PRINT PreviousString$;
ENDIF
PRINT "_";
`
` Main Input Loop
`
DO
IF RETURNKEY()
WHILE RETURNKEY()
ENDWHILE
SET CURSOR InputX,Y
PRINT Res$;" ";
EXIT
ENDIF
Key$=ENTRY$()
IF Res$"" AND ASC(Key$)=8
Res$=LEFT$(Res$,LEN(Res$)-1)
Key$=""
SET CURSOR InputX,Y
PRINT Res$;"_ ";
ENDIF
IF Key$"" AND LEN(Res$)31
IF ASC(Key$)>=48 AND ASC(Key$)
Posted: 1st Jan 2003 23:58
Hmmmmmm, Every time i submit code, the first code tages always get dropped trying again

+ Code Snippet
FUNCTION InputString(X AS INTEGER,Y AS INTEGER,InputLength AS INTEGER, Prompt$ AS STRING, PreviousString$ AS STRING)
   ` This routine will be the main input routine, the InputNum function will convert the number to a string and input with this function.
   `
   ` X,Y Will be the coordinates on screen
   ` Prompt is a prompt on screen if Required
   ` Previous String if needed
   `
   ` Setup Font and Characteristics
   `
   SET TEXT FONT "Courier New"
   SET TEXT SIZE 15
   SET TEXT OPAQUE
   `
   ` Setup Temporary Veriables
   `
   PromptWidth=TEXT WIDTH(Prompt$)
   InputX=X+PromptWidth+2
   Res$=PreviousString$
   CurrentPos=LEN(Res$)
   IF InputLength<0
      Numeric=1
      InputLength=ABS(InputLength)
   ELSE
      Numeric=0
   ENDIF
   `
   ` Display the Prompt
   `
   SET CURSOR X,Y
   PRINT Prompt$;
   `
   ` Display Previous string
   `
   SET CURSOR InputX,Y
   IF PreviousString$<>""
      PRINT PreviousString$;
   ENDIF
   PRINT "_";
   `
   ` Main Input Loop
   `
   DO
      IF RETURNKEY()
         WHILE RETURNKEY()
         ENDWHILE
         SET CURSOR InputX,Y
         PRINT Res$;" ";
         EXIT
      ENDIF
      Key$=ENTRY$()
      IF Res$<>"" AND ASC(Key$)=8
         Res$=LEFT$(Res$,LEN(Res$)-1)
         Key$=""
         SET CURSOR InputX,Y
         PRINT Res$;"_ ";
      ENDIF
      IF Key$<>"" AND LEN(Res$)<=InputLength AND ASC(Key$)>31
         IF ASC(Key$)>=48 AND ASC(Key$)<=57 THEN IsNumber=1 ELSE IsNumber=0
         IF (Numeric AND IsNumber) OR Numeric=0
            Res$=Res$+Key$
            SET CURSOR InputX,Y
            PRINT Res$;"_";
         ENDIF
      ENDIF
      CLEAR ENTRY BUFFER
   LOOP
ENDFUNCTION Res$

FUNCTION InputNumber(X AS INTEGER,Y AS INTEGER,InputLength AS INTEGER, Prompt$ AS STRING, PreviousNumber AS INTEGER)
   PreviousString$=STR$(PreviousNumber)
   InputLength=InputLenght-(2*InputLength)
   Result$=InputString(X,Y,InputLength,Prompt$,PreviousString$)
   Res=VAL(Result$)
ENDFUNCTION Res