EndFunc
st is the string, and ch is the character to count. For example,
charcnt("abcdddef","d") returns 3
(Credit to Mike Grass)
[8.5] string() uses the current number display format
When string() converts a number to a string, it uses the current display format. This behavior is not
explicitly described in the 89/92+ manual. While this is usually what you want to do when using string()
to convert numbers for display, it is usually not what you want if you use string to convert a number for
additional processing.
For example, suppose you want to extract the mantissa of of x, where x = 1.2345678901234E15. If the
current display format is Fix 4, then string(x) returns "1.2346E15". If you use left() and inString() to
extract the mantissa, you will get "1.2346", which is not the actual mantissa. You can retain most of the
precision in x by first setting the format to Float 12, then string(x) returns "1.23456789012E15".
However, note that you have lost the last two significant digits of ...34.
[8.6] Convert strings to upper- and lower-case
The two functions below convert an alphanumeric string to all upper-case or all lower-case characters.
This is useful, for example, to test strings entered by a user in a program.
Upper-case and lower-case character codes differ by 32, but converting the case is not as simple as
adding or subtracting 32, because the string may also include characters which should not be
changed. Only characters with lower-case equivalents are converted. In addition, the character set
includes international characters, so the conversion routines handle those characters as well
The function to convert a string to lower-case:
casel(s)
Func
© (string) convert to lower case
© 7may02/dburkett@infinet.com
local ä,ï,ÿ
""→ÿ
for ä,1,dim(s)
ord(mid(s,ä,1))→ï
ÿ&char(when(ï≥65 and ï≤90 or ï≥192 and ï≤214 or ï≥216 and ï≤223,ï+32,ï))→ÿ
endfor
return ÿ
EndFunc
The function to convert a string to upper-case:
caseu(s)
Func
© (string) convert to upper case
8 - 3