Texas Instruments TI-89 Tip List page 374

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

Advertisement

This idea can be extended to more than two variables. The program req3var() shows how to get three
variables from one Request command.
req3var()
Prgm
©Demo, get three variables in one Request
©14oct00 dburkett@infinet.com
local s1,s2,x,y,z,xyz
©Set default values for x, y and z
1→x
2→y
3→z
©Combine x, y and z for default prompt
string(x)&","&string(y)&","&string(z)→xyz
©End up here if user omits commas between x, y and z
lbl tryagain
©Prompt for x,y and z
dialog
title "GET X, Y AND Z"
request "x,y,z",xyz
enddlog
if ok=0:return
©Find the comma positions in xyz
instring(xyz,",")→s1
instring(xyz,",",s1+1)→s2
©Test for commas
if s1=0 or s2=0 then
dialog
title "ERROR"
text "You must put commas"
text "between x, y and z"
enddlog
if ok=0:return
goto tryagain
endif
©Convert x,y and z strings to expressions
expr(left(xyz,s1-1))→x
expr(mid(xyz,s1+1,s2-s1-1))→y
expr(right(xyz,dim(xyz)-s2))→z
©Just for a demo, display x, y and z. Your application probably won't do this
dialog
title "SHOW X, Y AND Z"
text "x is "&string(x)
text "y is "&string(y)
text "z is "&string(z)
enddlog
EndPrgm
©x, y and z will be in string xyz
©Let user quit by pressing [ESC]
©s1 is the position of the first comma
©s2 is the position of the second comma
©Display error message if both commas
©not found
©Let user quit by pressing [ESC],
©or try again by pressing [ENTER]
9 - 15

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92+

Table of Contents