[8.3] Creating strings that include quote characters
Suppose you want to store "abcde" in a string str1. This won't work:
""abcde"" → str1 won't work!
What actually gets saved in str1 is this:
abcde*""
2
which is interesting, because the 89/92+ is interpreting the input string as
abcde * "" * ""
However, these will work:
"""abcd"""->str1
string("abcde")->str1
char(34) & "abcde" & char(34) → str1
so that str1 contains ""abcde"", as you would expect. 34 is the character code for the double quote
symbol.
It is not straightforward to create strings that embed the double quote character, ", because that is also
the character that delimits strings. Suppose you need to create the string
"ab"cd"
Just typing that in won't work: you'll get the missing " error message. This will work, though:
"ab""cd" does work
This will also work:
"ab" & char(34) & "cd"
because 34 is the character code for the double quote character.
You can include two or more consecutive quotes like this:
"ab""""cd"
In general, use two quote characters for each quote you want to create.
[8.4] Count occurences of a character in a string
If you need to count how many times a particular character occurs in a string, use this:
charcnt(st,ch)
Func
©(string,char) count #char in string
Σ(when(mid(st,i,1)=ch,1,0),i,1,dim(st))
8 - 2