{}→g_ll
0→g_d
For k,1,g_dim
mid(g_str,k,1)→cc
if cc≥"A" and cc≤"Z":char(ord(cc)+32)→cc
If vardeb(cc) then
cc→ss
k+1→k
mid(g_str,k,1)→cc
if cc≥"A" and cc≤"Z":char(ord(cc)+32)→cc
while k≤g_dim and varin(cc)
ss&cc→ss
k+1→k
mid(g_str,k,1)→cc
if cc≥"A" and cc≤"Z":char(ord(cc)+32)→cc
Endwhile
If cc≠"(" and ss≠"and" and ss≠"or" and ss≠"xor" then
For i,1,g_d
if ss=g_ll[i]:exit
Endfor
If i>g_d then
augment(g_ll,{ss})→g_ll
g_d+1→g_d
Endif
Endif
Endif
Endfor
g_ll
Endfunc
Note that the expression is passed as a string, and need not be a valid expression. The variable
names are returned as string elements of a list. For example, the call
exprvars("a+b/c+sin(d^e)+22.2=f")
returns
{"a","b","c","d","e","f"}
Timité Hassan's original getvars() function
This is Timité's original getvar() code. I include it here out of courtesy, and so that if I have made in
mistake in my changes, you can use the original code. getvars() calls varin() and vardeb().
getvars():
getvars(g_str)
Func
Local k,i,cc,g_vr,g_d,g_dim,g_ll,ss
dim(g_str)→g_dim
{}→g_ll
0→g_d
For k,1,g_dim
mid(g_str,k,1)→cc
if cc≥"A" and cc≤"Z"
char(ord(cc)+32)→cc
If vardeb(cc) then
cc→ss
k+1→k
mid(g_str,k,1)→cc
if cc≥"A" and cc≤"Z"
char(ord(cc)+32)→cc
while k≤g_dim and varin(cc)
7 - 43