Q(uick)BASIC Function: UCASE$
Quick View
UCASE$
A string processing function that returns a string expression with all letters in uppercase
Worth knowing
Useful and cross-version information about the programming environments of QBasic and QuickBasic.
Syntax
- LCASE$(stringexpression$)
- UCASE$(stringexpression$)
Description/Parameter(s)
stringexpression$ | Any string expression. |
Example
Test$ = "THE string"
PRINT Test$
PRINT LCASE$(Test$); " in lowercase"
PRINT UCASE$(Test$); " IN UPPERCASE"
Syntax
- UCASE$(stringexpression)
Description/Parameter(s)
The stringexpression argument can be any string expression.
The UCASE$ function works with both variable- and fixed-length strings.
The UCASE$ and LCASE$ statements are helpful in making string comparisons case insensitive.
Example
UCASE_EX.BAS is a program file in the subdirectory ADVR_EX that illustrates the UCASE$ function. To look at the program in the View window and, optionally, to run it, load it using the File menu's Open Program command.
The program contains a FUNCTION, YesQues, that returns a Boolean value depending on how the user responds. The FUNCTION YesQues uses UCASE$ to make a case-insensitive test of the user's response.
See also:
Syntax
- UCASE$(stringexpression$)
Description/Parameter(s)
stringexpression$ | Any string variable, string constant, or string expression. |
Usage Notes
- The UCASE$ function works with both variable- and fixed-length strings.
- The UCASE$ and LCASE$ statements are helpful in string-comparison operations that are not case sensitive.
Example
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
See also: