©End up here if user omits comma between x and y
lbl tryagain
©Prompt for x and y
dialog
title "GET X AND Y"
request "x,y",xy ©x and y will be in string xy
enddlog
if ok=0:return ©Let user quit by pressing [ESC]
©Find the comma position in xy
instring(xy,",")→s
©Test for comma
if s=0 then
dialog ©Display error message if no comma found
title "ERROR"
text "You must put a comma"
text "between x and y"
enddlog
if ok=0:return ©Let user quit by pressing [ESC],
goto tryagain ©or try again by pressing [ENTER]
endif
©Convert x and y strings to expressions
expr(left(xy,s-1))→x
expr(right(xy,dim(xy)-s))→y
©Just for a demo, display x and y. Your application probably won't do this
dialog
title "SHOW X AND Y"
text "x is "&string(x)
text "y is "&string(y)
enddlog
EndPrgm
Note that the copy of this program in the tlcode.zip file does not include all the comments.
When this program runs, this Dialog box is shown:
Note that the defaults of 1 and 2 are shown. The user presses [ENTER] to accept these defaults, or
enters the new values, separated by a comma. Or, the user can press [ESC] to quit the program.
If the user forgets to enter the comma separating the two values, an error message dialog box is
shown. The user can press [ESC] to quit the program at this point, or press [ENTER] to try again.
9 - 14