Changing+the+case+of+a+string

//by Jon Ripley, May 2006//

The **FNUSING** library supplied with BBC BASIC for Windows contains the functions **FNlower** and **FNupper** which can be used to change the case of a string to //lower case// or //UPPER CASE// respectively. These are described in the main help documentation [|here]. Alternatively the Windows API calls and  can be used to manipulate the case of characters in a string.

Changing the whole string
To change the case of the string **My$** to upper case use code similar to the following: code format="bb4w" SYS "CharUpperBuff", !^My$, LEN(My$) code

To change the case of the string **My$** to lower case use code similar to the following: code format="bb4w" SYS "CharLowerBuff", !^My$, LEN(My$) code

Changing a portion of a string
To change characters at the start of the string to upper case use code similar to the following: code format="bb4w" SYS "CharUpperBuff", !^My$, Num% code Here **My$** is the string you want to alter and **Num%** is the number of characters to change. The value of **Num%** must be less than or equal to the length of the string.

To change characters at the end of the string to lower case use code similar to the following: code format="bb4w" SYS "CharLowerBuff", !^My$ + LEN(My$) - Num%, Num% code Here **My$** is the string you want to alter and **Num%** is the number of characters to change. The value of **Num%** must be less than or equal to the length of the string.

To change the case of characters in the middle of the string to upper case use code similar to the following: code format="bb4w" SYS "CharUpperBuff", !^My$ + Pos%, Num% code Here **My$** is the string you want to alter, **Pos%** is the position of the first character in the string to alter and **Num%** is the number of characters to change. The sum of **Num%** and **Pos%** must be less than or equal to the length of the string.