User Tools

Site Tools


ucase

Table of Contents

ucase

upper case - a string processing function that returns a string argument with all letters in uppercase

syntax

ucase(string)

  • the string argument can be a string variable, constant, function or literal

See also instr, acase, lcase, pcase, tcase

details

ucase works with variable-, fixed-length and constant strings. The result can be assigned to a variable or fixed-length string, and passed to a string parameter or function result.

The functions lcase and ucase are helpful in string comparison operations where tests need to be case insensitive.

example

This example loops through a string in search of the term 'BASIC' and prints the start position each time the term was found. The string function ucase is used to make the search case insensitive.

' SharpBASIC uppercase programming example
' ----------------------------------------
incl "lib/sys.sbi";

const text = "SharpBASIC is a great Basic programming language";

dim n: uint = 0;

main do
  ' loop through the text
  loop do
    ' convert to uppercase and look for the term 'BASIC'
    n = instr(ucase(text), "BASIC", n + 1);
    ' exit the loop if no more results
    if n == 0 do
      break;
    end
    print(n);
  end
end
Output:

6

23

ucase.txt · Last modified: 2023/06/26 00:40 by admin