[8.3] Creating Strings That Include Quote Characters; [8.4] Count Occurrences Of A Character In A String - Texas Instruments TI-89 Tip List

Graphing calculator
Hide thumbs Also See for TI-89:
Table of Contents

Advertisement

[8.3] Creating strings that include quote characters

Suppose you want to store "abcde" in a string str1. This won't work:
""abcde"" → str1
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"
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))
won't work!
does work
8 - 2

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92+

Table of Contents