bas7ex.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
UCASE$ Function Programming Example
                       Example                 Contents  Index  Back
─────────────────────────────────────────────────────────────────────────────
'This example contains a FUNCTION procedure, YesQues, that returns a Boolean
'value depending on how the user responds. The procedure uses the UCASE$
'function to make a non-case-sensitive test of the user's response.
 
DEFINT A-Z
 
DO
LOOP WHILE NOT YesQues("Do you know the frequency?",12,5)
 
 
FUNCTION YesQues(Prompt$,Row,Col) STATIC
   OldRow=CSRLIN
   OldCol=POS(0)
   'Print prompt at Row, Col.
   LOCATE Row,Col : PRINT Prompt$ "(Y/N):";
   DO
      'Get the user to press a key.
      DO
         Resp$=INKEY$
      LOOP WHILE Resp$=""
      Resp$=UCASE$(Resp$)
      'Test to see if it's yes or no.
      IF Resp$="Y" OR Resp$="N" THEN
         EXIT DO
      ELSE
         BEEP
      END IF
   LOOP
   'Print the response on the line.
   PRINT Resp$;
   'Move the cursor back to the old position.
   LOCATE OldRow,OldCol
   'Return a Boolean value by returning the result of a test.
   YesQues=(Resp$="Y")
END FUNCTION