If you need to use this method more than once in a dialog box, you can reduce the total code size by
with a subroutine which converts a string of parameters to a list. These two functions, rq2v() and
rq3v(), perform the conversion. Use rq2v() for two parameters:
rq2v(st)
Func
©Convert ("a,b") to {a,b}
©31mar01/dburkett@infinet.com
local s
instring(st,",")→s
if s=0 then
return "ERR"
else
return {expr(left(st,s-1)),expr(right(st,dim(st)-s))}
endif
EndFunc
Use rq3v() for three parameters:
rq3v(st)
Func
©Convert ("a,b,c") to {a,b,c}
©31mar01/dburkett@infinet.com
local s1,s2
instring(st,",")→s1
instring(st,",",s1+1)→s2
if s1=0 or s2=0 then
return "ERR"
else
return
{expr(left(st,s1-1)),expr(mid(st,s1+1,s2-s1-1)),expr(right(st,dim(st)-s2))}
endif
EndFunc
Both of these functions return "ERR" if the commas are missing. This example shows how to use both
functions.
©Initialize prompt variables
"0,0"→ab
"0,0,0"→cde
©Prompt for input variables
dialog
request "a,b",ab
request "c,d,e",cde
enddlog
©Extract a, b variables
util\rq2v(ab)→res
if res="ERR" then
(... handle error here ...)
9 - 16