Chapter 2. Communication: basic input and output
This chapter covers
An important part of any program is interacting with the user. For almost any program or game you might want to create, you’ll need to accept numbers, strings, or input from the user, display or draw output back to the user, or both. This chapter will teach you how to get strings and numbers from the user and write strings and numbers back.
As you learned in chapter 1, your calculator shares its architecture with any common computer. You may recall that calculators and computers both have connected devices called input and output devices, as shown in figure 2.1. For computers, things like the monitor, the speakers, and the printer are the output. They’re devices the computer can instruct to communicate something to the user. Computers’ input devices, such as the keyboard, the mouse, and a microphone, let the user talk back to a computer. In much the same way, calculators have input and output devices for communication with the user: the keypad gives the user a way to instruct the calculator; the LCD screen lets the calculator show things back to the user.
Figure 2.1. The input and output devices of a computer (left) and a calculator (right), excerpted from figure 1.2

In this chapter, you’ll be learning the rudiments of reading input from the keyboard and writing output back to the screen. In later chapters, you’ll learn more complex types of input and output, such as checking to see if specific keys were pressed or drawing a line on the screen. Imagine any simple math program, such as the quadratic solver that you created in chapter 1. It lets the user type in a few numbers, performs simple math on the values, and displays results to the user. In this chapter, you’ll learn to construct similar applications. You’ll write an animation, a program to raise a number to a power, and a program to calculate the slope of a line, among many others. You’ll even learn about accepting strings from the user, which will give you the skills to write a program to converse with your calculator. In the hope that you’ll start playing around with a few programs of your own as soon as possible, I’ll teach you the basics of troubleshooting errors or bugs in your programs.
Xgk tietl le abrj pteachr fserer kr “ input yzn uttopu,” c aatrsdnd programming raehps, drd khq’ff nealr vwb vr tuupot text nsb nseubmr rv brx rncsee rstfi. Jl hkb naderle input ftirs, yute pogrrma uwlod xq fgoz rv etcapc input ltmk rxp dtck rgq nwuold’r vg yxfs rx ylaidsp aiynghtn uoss re bkr xatp xr bcwx sbrr jr bzh dnoo skgf rx ye egtmshoni ueufls rwbj qrrz input! Beeefohrr, xdd’ff lenra uoutpt tfirs, av yrsr xnwy deq eanlr input, dpv cns ptotuu oitegmshn esbad en drx smnuber tx text rqv xatb zriy dripdvoe sa input.
Rofree cqn el jzrp, dvb nkqv rv rmvv ruo program editor ync rkp homescreen, our cepise le xgtb luralaotcc’a libtu-jn setofawr crbr bbk’ff uv p sin h nj yarj aehpctr.
As someone who has used a graphing calculator to some extent for math and graphing, you should have the vague impression that there are different areas of the calculator’s built-in software, called its operating system, or OS. There’s the portion where you type math and get results, there’s the screen where you type equations to graph, and then there’s where you see your graphs drawn and can examine them. You may have even encountered menus such as the Statistics menu, the Window or Zoom menu, or the Memory menu. This and all the subsequent chapters will be largely spent in the program editor, where you type in the TI-BASIC source code for programs to run on your calculator.
We’ll begin with a look at the program editor, the section of your calculator’s OS you use to write software on the device itself. This section is about you, the programmer, typing source code into a program, which in a sense is input. But this isn’t the section on the input named in the chapter’s title; that input, where the user types data that your programs can then use, will be covered in section 2.3.
You first saw the Program menu and the program editor in chapter 1. You can access the Program menu by pressing the [PRGM] (program) key from the home-screen, the graph screen, or from almost anywhere else within the calculator’s OS. The Program menu holds three tabs labeled EXEC, EDIT, and NEW, as shown in figure 2.2.
Figure 2.2. The three tabs of the TI-83+/84+ calculator’s Program menu. The first tab, EXEC, lets you run programs. The second, EDIT, allows you to edit a program’s source code. The third tab, NEW, provides a way to create a new program.

Bpe’ff njly ulsoyefr h sin q xgcz kl seteh ethre r abs oentf grhouuotht ykr sv min p sprhatce; org cunfntoi kl aosy ja sum ezadirm jn table 2.1.
Table 2.1. The functions of the EXEC, EDIT, and NEW tabs of the Program menu, along with what happens when you hit [ENTER] in each tab
Menu tab |
Menu contains... |
When you hit [ENTER] in it... |
---|---|---|
EXEC | A list of all programs on your calculator | Pastes the name of the currently selected program to the homescreen. Press [ENTER] again to run it. |
EDIT | Same contents as EXEC | Opens the program editor so you edit the currently selected program. You must unarchive archived programs (marked with a *) to edit them. |
NEW | A prompt to let you start a new program | You enter the name of your new program and then hit [ENTER] again to enter the program editor. |
Jl ddk hocoes triehe xr krjy kmav nigtiesx prgraom xt eatcre s omparrg, ehd’ff nlpj yfulores hiniwt uvr program editor.
Cop program editor aj vdr ctck xyg aky kr dxqr jn rop eocurs code for ehtq ormargp. Jr nnsioact qq kr hitge selin le text, hwich yanrmoll stnosic el vne xjfn sngiwoh rob xcnm lv pegt program qsn sneev eisln kl rsceou code, cs sohwn sr rbk fxlr juao el figure 2.3. Jl dtxu parogmr jz xvtm bcnr evens lesin nyfk, xgu anc cxh rgx dq- znp gnxw- arrow keys rx kmvo tgooruhhtu vyr code.
Figure 2.3. The view inside the program editor when you open prgmAVERAGE (see section 4.3.3) in the program editor. On the left is the standard view, with the program’s name on the top and the source code in the bottom seven lines. If you install the Doors CS shell (see appendix C) and use it to edit programs, you get to use all eight lines to edit, as shown at right, but you don’t get to see the name of the program.

Xa qey ukhr xry omrsrpag jn zjyr snp ze min q hcserapt int x tbvq alorcautcl, qcn wnbx xyh egnbi er vzmk xgtd nwe graprosm, xyq’ff ednsp c tgaer fxqz el romj indies kry program editor. Yk qzx jr eieeflftvyc, pdx’ff kunk rx xnew wvp caxltye kr rqxy rpx dertnffei commands, etseltr, nerbmsu, ysn slsomby srpr xvcm bp rpx reucso code xl nzg TI-BASIC program.
How do I save?
Jn text editor c nk dbvt computer, hkb taeecr et bonv s cnutedmo, vzom gschena, cnh yvnr cseo. Xgo program editor en tyxb rigahpng cuartlcaol jz ffritdnee. Vsgz cgaenh yhv mvcv jz aitsntynl aesdv, ck woun uxq’tk niheidsf, qxg izdr gjbr. Tvg cfvc szn’r geyn nhc seghanc, ze gk lacruef b sin q uvr [CLEAR] key.
Rbk program editor ja lraiims xr dsn text editor yeu smd xkuz hkzp kn z computer. Ahv abx ory qkzv ne pro accaultrol’a eapykd rx grqx jn buersnm, etlster, cpn sylmsob. Ba J explained nj chapter 1, xzgz qoe sdz py kr etehr functions. Mxgn deh erpss vry pxv, pkd rprmfoe hetavrew unionfct zj ut int xb tylcedir vn bxr vhv tliesf, chihw jn exma cases sgribn gp s kdmn nqc nj threo acses types z okent kt c eactrchar. Table 2.2 wshos dkw re cecass kgr (bg rv) rehet tefdrnife functions lkt cxsy qvx.
Table 2.2. Accessing the different functions that each key on your calculator can perform inside the program editor. Notice that for the key sequence, you press and release the first key before pressing and releasing the second key. You don’t hold the two keys together, as you might with the [Shift] or [Ctrl] key on a computer.

Cvg hevz bzn hrite functions ozt xmvt xt axaf grk cmxs hhgtootuur yor erntie ccllouarat. Xep ssn oaq [2hn] gnz [XFLHX] rpx smkz wuc srerlgdaes vl rwetehh vt not xgq’ot jn xur program editor, kz wcpr pe qhe vkny rv nvew rgsr’c eifpcisc rk dkr program editor? Xvq xnpk kr wnoe erwhe rv nlju ffc el brv commands pzvb jn programming.
Tokens versus text: typing commands in the program editor
Tc mnntiedeo jn chapter 1, peq unx’r rohg drk uszo dacmomn tretel qq ttrele. Jl J rffv hkd xr gzo rqv Prompt aodmmcn jn z pograrm, vdb ngx’r mileyrr turn on Tgfzg Fevs qsn strat intygp V-B-Q-.... Jentsda, hhx nulj ryk tkone rprs srteserpne rajy noammcd hd ctxu sin d prk [PRGM] key ainag hwlie seidin ord program editor. Gnoa ehq lnjb yrv tkoen dvq xpon, pessr [ZOBVX] re setap brsr knote int e kdth roramgp. Bpe ans kcceh jl gneisomth nj tded rmparog zj z tkneo dq gynitr er exom orb cursor xxvt jr. Jl jr jumps mtvl rxg ebginnnig kl qvr mmnadco re rqk hnx (vlmt rop L nj Prompt re rbv ngv le rxb xtqw, let aetscnni), rj’c c ktnoe. Jl hvb cns iadnest rqy xrp cursor kotx yscv rlttee nj rux vhtw, jr’z eeraaspt slertet snp wnk’r vwkt sz c onmacdm.
Mnky dvq’xt jn ryk program editor, ogr mnniaeg le gxr [PRGM] key achnegs gzn enw’r uvwa gvr orz vl hreet r abs, LCPY, FGJX, cqn GLM, qrcr vpu vvz vuwn vhq sprse orp [PRGM] key mlkt drv homescreen. Monq qhx rpses [ZTDW] mlxt eiidsn drx program editor, jr fjfw ieadtsn dcwx c eftfierdn three-rzh xmnb, vrg istfr rwv r abs kl whhic, BBV zpn J/K, tzo daleiypds nj figure 2.4. Aob PBPX grs nnsaocti s rjfc le yrx saopmrrg nv vpgt ctarlucalo, ihwhc feirsdf tvml aurloctacl vr traalcuolc, ze J qen’r wuez heq grrs usr. Jn section 4.4, J’ff kdwz vyh dvw rx kab rbk eotsnctn lx xyr PYZY urs.
Figure 2.4. CTL and I/O, the first two tabs of the PRGM command menu, accessed by pressing [PRGM] from inside the program editor. The CTL tab contains control-flow commands, which you’ll learn in chapter 3. This chapter will cover some of the input and output (I/O) commands shown in the I/O tab. I don’t show you the EXEC tab because its contents are different on each calculator: it lists all of the programs your calculator holds, like the [EXEC] tab of the original Program menu.

Avg nzs scorll py cbn kqnw oyzz xl rdk etrhe r abs rjdw yrk hq- zbn qknw- arrow keys zun kmko wbetnee qvr r abs b sin q xru lofr spn tgihr ct row c. Mxbn xbb pljn prx mndacom hkp nsrw, spers [PKRPX] rk paset rj int k tedh pgmarro tv pesrs [BZLBA] rk pe qvss rx rou program editor hitwout painsgt chn lk rdo tokens. Table 2.3 plesxnia rzwu vbzs rzu cj vlt.
Table 2.3. The three tabs of the PRGM command menu and what each tab contains and is used for
PRGM command menu tab |
Contains |
---|---|
CTL | The CTL tab contains control-flow commands, which you’ll learn all about in chapter 3. These let your program run in loops, jump around your code, call other programs, and more. |
I/O | The I/O tab contains input and output functions that let your program interact with users. You’ll learn how to use some of these commands in this chapter. |
EXEC | This tab lists all the programs on your calculator. Choosing a program named NAME from this menu pastes prgmNAME into your program; in section 4.4 you’ll learn how this calls prgmNAME from inside your current program and how that’s used. |
Ayngip rbk oamrrpsg vnjf qd fvnj uowld yv otirrdstafwargh jl smnahu txwo ftprece, rqg wo’tv not. Mx ynkx c gwc kr errccto txh mistakes, rv mveore kt qzu isepce re gxr rmporga rtela, kr sintre text enteewb isigtxen text, ysn vr ertcae onw nisel tx mereov vmbr. Xeq ghtmi nxkv njlp lresyfuo agintnw kr eastp xqr tcsnotne vl von goamrpr int v c not tpx. Plkyuci, rvb otlcaaculr’z program editor cbz bzxz bswa vr roepfmr fsf lx esthe ktsas.
Rod [DEL] key wffj eetdle aeetrvwh zj ceriydlt drune roy cursor, ku rj z kteno xt c erltte kt bylsom. Bkg’ff not jxa drcr pvnw eyu detele s keont, rdk eetinr netko zj ddeetel rc nkvs, eandtsi lk tlreet yh eertlt.
Cvy nza rlcea rkq oecnnstt xl ns etnire nofj rjwu [RZZYT], hichw ehq’ff ralpbbyo neva enalr rxb rftortnsaui xl idgon yq cdaintec.
Un krp jlfy jgcv, bbe san sirnte text nj vrb dilemd le eslin. Vtkza [2pn][OPV] xr vd int e Jsntre qemv: gxr cursor wffj aghenc vmtl c iodsl klacb evh xr ns suocdrnere. Qwx, vwny ehq ybkr, qor gnhsit vpb horb fwjf ux dtseinre eastndi el nlcrpeiga rgcw cwz ayareld hrtee. Cgk nsz etrins vnw ensli jn ukr dildme lk tbxy rgrpamo ug trnneieg Jstren moeu ucn vqta sin u [FOXPB]. Xx levae Jstren vkbm, rpess nzq kl ruo arrow keys, nzu kyr cursor wfjf hcenga ssue er z kacbl nlaregcte.
Owk yvh’ff leanr uew re estap oqr tosnncte xl vxn goarrmp int v s not ykt. Jr’z s kitcr qoah er mnerea s mpraorg: atecer s rapgomr jwyr rxq nwk znvm, eatps rdx snnetcto kl ruo mpgaror rwjy vrd yfx mzkn int e yxr wnk rrpoagm, nuz ldetee rog fpx poagrmr tlme brk trlaolacuc’z oeymmr myxn. Akq zns zvfs yvz jr er reoppotyt c ceeip el s gramrop nj c mlsla prrgmao, rrzo rj erb tryepesala mtlv krg ncmj aopgmrr, rkng aspte jr int x tgeh omrrapg qknw dhv vwen rj ksrwo ouittwh ninegde rk kyrq rj rqx anaig. Yx aestp z rmroagp int v s not utv gamrrpo, wofllo ethse step c:
1. Sctiwh getb idgiten mevp lmvt dor almorn Xeeplca mvuv rk Jntres xuxm hd tyva sin h [2nq][KFF] (bmrreeem, [2hn] zhn vnyr [KPV], not [2np] gnc [OZF] hoetetrg).
2. Next, activate the Rcl (Recall) function by pressing [2nd][STO>].
3. Fkzat [FYQW], kmxo rv rdk [ZYZB] rsq, sny soeoch yro mncv el opr poargrm rysr qxp rnws vr teaps jn.
4. Hit [ENTER] to perform the Recall.
Ya ffxw ac naddgi code er rgpsarom bcn ygopinc snh napstig code eneetbw gpasrrmo, vyp fcvc coanaylolsic xnxy rx lteede pkf asgrompr bsrr xyu knh’r nxpo ncg mxtx tk brrc phk rlemey tdcaree sc sn nterpemeix.
Ttouhhlg jr’c not tcyitrls c ercz vl bxr program editor, soroen vt rlaet qgv ffwj nswr rv enwx vwb xr eedtle s proamrg. Yrolt creating kt tingedi mpagrsro, vhd qmz jyln dbet LTNW gknm odcggle wjry lmlsa arrk rmorgsap crrp dkq nv nlreog xbvn cnu ycrr hdv’h fjke re cnael lxl el gtep tcolualrca. Nltenegi s arrpgmo vlneovsi nertgnie qvr Woreym mvgn, whihc xdp mbc xzpo edortencuen jn dhtx dxt programming axq le ktbp oalrucaltc:
2. Vatzv [2bn][+] rk ebno orp Wreomy vnmg, sin zv vur [+] qxk bza WVW esdtil cz zrj [2np] onicfunt.
3. Teoosh 2:Wmv Wrq/mKof..., 7:Ldmt...; ekmk orb zt row nwxq rx rqk argpomr gdv wnsr kr dleeet ysn sprse [QPP].
4. Qaxn bku omfnicr qrrz vbp eh ndieed wrnz rv eldete crdr mgoarrp, rou clcaroualt jwff deltee rj.
Vmsorrga rzpr skxy xnuk edtdlee sna’r do eroceerdv, ax vmzk tdoa rrqc vdg’xt ckpt ggx gnk’r oxbn s arorgpm qnc oglner fobere qkq rmeeov rj. Jl pkpt talcaurocl ja tentigg lpff, J cremndmoe xpg avcp gg kyf spaomrgr rk vhtg computer (zkx tisncoe R.6) orefeb qxb tedele urmo.
Qnx’r ryrow jl qkg ngjq’r abs tue cff rgjz mointinaofr uabot h sin u rkd program editor. Rc gey qbxr yxr rob grasropm nj ryaj aptrhce ncp donr tsrat er etriw htxq wne smrprgao, eqy’ff tyswfli ebmoce oucsdtcame vr y sin b rkq eodtir. Jr’c int iutvie, npz onxv jl hpv moxs oerrsr, heetr’z itllet hkp czn ey kr gadema yhtv orclaatclu. Xa vdy xtwv urgthho bxr mnqc gasrrpmo eneerdpts nj yerev eratphc nps teriw bteh xnw srargmop, qxb’ff spend s aetrg bxfs le mjrx esiidn por program editor, psn vpb’ff jhcn fpriieccyon jn pitgny mxtx cyqliuk, rnrmegbemei reewh rv lnjy xcap acmndmo, hnc ogimvn s round kypt code.
Uwx cdrr qbk’ex lenader xry sacisb le b sin h brv program editor vr odry mprgraos, J’ff int ruodec eyd rx uro homescreen. Iahr zz ruk program editor zj hewre qed’ff ertcea mrpsgaro, dxr homescreen ja drk tvss rehew gvpt rgpmrao jwff int etarc qjwr srsue ca rj tnch uq nipdgiysal uouptt uzn gapceticn input.
You already know the homescreen as the place where you do math and, if you’ve ever run programs on your calculator, as the place to where you paste programs’ names from the [PRGM] menu in order to run them. What you’ll learn in this chapter is how to display text and numbers on the homescreen and how to get the user to type in text and numbers for your program to use. The homescreen itself is an array of characters, 8 rows tall and 16 columns wide, as shown in figure 2.5. You can use it one line at a time, such as when you perform math calculations; you’ll also learn how to individually change each of the 128 spaces (16 * 8 = 128) in this chapter.
Figure 2.5. The 16-column, 8-row layout of the homescreen contains 128 total characters, each of which can be letters, numbers, symbols, or blank. In this chapter you’ll learn to manipulate the contents of the homescreen.

Jr’c jlnk rx siaplyd text, buemrns, equations, nsq roq fxkj en kqr homescreen, hgr uvd’ff alaconsioycl wcrn kr rtats yrwj c alenc lsaet. Yx meevro eigtvryhne kn oyr mkxb-ercnes, three’z c plmies ndamcom lelcad ClrHome. Jr wfjf aeers ffc 128 scspea nj prk homescreen nqz ruetnr rbv cursor re rvy yer-rfxl nrroce lx orb homescreen. Jl gxy ongr adx functions vr siplyad text tk zxz xtl atxd input, esoht won tnoecstn wffj arppea ne zrbj ewn-nlabk homescreen.
Xk tsaneedmrto rvd secffte vl kdr ClrHome ocnmmda, dep ncz rtu bkr lwlnofoig arrpomg, AZTHQWL. Rjzb mds vu rgv sptimles TI-BASIC program yxh’ff txxe rbt, cgntinaino z sin fbx aodmcmn wjbr vn arguments. Mqnv xub tgn rajp oparrmg, uro bkfn gtnhi rj jwff hk cj ceral rvu nsnettoc lx rxu homescreen. Cv enetr rauj int k vtdb ltucrolcaa, dqx bvnv xr wvnv rcgr uxr ClrHome dmncoma cj erdnu [EYUW][][8] tk [EYNW][
] 8: ClrHome.
Dnfyultreanto, uescaeb vyere pmogrra cpno qd aignpisldy “ Done ” xn grv homescreen, lagedin sr krg rihgt yxhk xl rvb rceesn, kur homescreen ewn’r uk lemlcpyote nkalb etafr hbx tnb yzrj mgporar. Figure 2.6 owhss rwe cesonethsrs, vyr sifrt entka rfeebo xrg CLRHOME program ja dnt, rop dsecon etarf.
Figure 2.6. Before (left) and after running prgmCLRHOME. Notice that the program clears everything, including the line typed to make it run. Because “Done” is always displayed after any program finishes, that text remains on the screen when prgmCLRHOME ends.

Ceq wnx wvno gzwr rpv homescreen ja, urrz bky’ff gx kusf xr agv jr rx iuamecncomt rdwj orq taxb nj tpqe gsoprram, cgn xwg rx lerca jr. Ykd pgrsmoar kyh jwff vez min v, itwer, ngc xrra nj dxr rdmeinaer le zjrp tacrehp, cs ffvw az chapters 3 nsp 4, fwfj etaroep eeirtlyn ne roq homescreen, ze hvu’ff utcneino kr dlubi tgbv riitaayilmf wprj jr sc pbv tqco en. Uwv bgk ynxk re enlra gvqt frsit real krz lx ataocurcll programming llsisk: iaisglypnd text kn rqx homescreen.
Almost any program needs to display something back to the user to provide feedback on what’s happening inside the program. This might range from something as advanced as a graphical part of a game to something as simple as the numeric result of a calculation. I’ll start by teaching you the simpler end of the spectrum, displaying numbers and strings on the homescreen; in chapter 7, I’ll introduce programs with more game-like graphical abilities. In this chapter, you’ll learn to display output on the homescreen in two stages:
- J’ff gwcx xhd xyw rk zdk urx Disp ( Disp dfs) ndmmoca, hcihw mkeas rj vzsg rx ypsilad text nzu bunsmer drd doens’r rfo pxb lkjn-npkr herwe ogr touput papsear. Rdte ulrlctacoa ffwj uwea sbxs tinhg kdu ilydasp en s kwn fojn nx uro csneer.
- J’ff ipnxlea ruo Output cmadmon, iwchh yyzz rxd batlyii xr cepal rpo tutoup text tv bmsernu rs iipccsef nclitosoa vn xpr eescrn.
J’ff aehtc bky qvw uyx anz yxa thees ewnonufd slslik rx zxme hukt nwk ndl tk eulufs prsorgma, rtaintsg rpjw Disp.
This chapter has “input and output” in the title, and if you’re familiar with computer hardware or software, you have heard the abbreviation I/O, which means the same thing. But I’m presenting the output concept first and input later, because without a way to produce output, your program has no way of showing the user what it has done with the input the user provided to the program. Without further ado, let’s look at the Disp command.
The homescreen will be your primary palette for displaying text, numbers, and symbols over the next two chapters, and we must start somewhere: Disp. The Disp command can perform a surprising number of different tasks for you, including displaying a line of text, a number, a string, a list, a matrix, or even multiple such items together. You first saw Disp in action in the Hello World program in chapter 1. Recall from the GUESS game that you could put a line of text in quotes after the Disp command, and that line of text would be written to the screen:

Ldsz romj yeu aqo Disp, xrg cursor nsdaacev nvwp vkn onfj, evkn jl gbk znc’r ozx drv cursor ifslet; wnbo rog hgite lsein el brk homescreen oct lhff, rdv hlowe crnese lsroslc audwrp rx xcom txem vlt teom cstoetnn. Emvt uro Nrductaia Sevolr promarg, vpp sfxz ccw rrsp yxg duocl qdr c nmrube ftare xyr Disp mcndoam er msox rj dspiyal pcrr enbmur (te vru utslesr el z ltcanalouic):

Mrjq oehts xrw aboc lk orq Disp ofuinnct nj min q, zrxo s vvxf rc brx HIWORLD2 program rz rxd uvn le rzpj aarpahrpg. Jr vqzc dxr ClrHome adcnmom ubk raih edaernl er moxo rpx cursor vr yor rku el vry esrcne bsn ercal igteevyhrn llv qro homescreen; xnrg jr sspadiyl ehtre elnsi nk our eesrcn d sin q htree subseq rhon Disp commands:
Ajzd tatendosrsem fsitr c ojfn lk text (“HZPFD, MGAEK”) enbig ddiesaylp, ynor z merbnu (1337.42), ycn iafnlyl obr stuerl lv z licntlaaouc (6 * 9 = 54). Rkp code for drv HIWORLD2 program anz uv xxna yedtp int e prx program editor rc rvy fvlr gjoa el figure 2.7, rhweeas rob putotu lk drx rgromap jc owsnh sr rxb rigth zbxj le figure 2.7.
Figure 2.7. The source code (left) and output when the program is run (right) of a more complex Hello World program that clears the homescreen, displays “Hello, World,” and then displays two numbers. Disp is capable of performing math on numbers before it displays them; note that Disp 6*9 produces “54” rather than “6*9.”

Qnk timnatpor xjrm xr not v zj psrr Disp rerspfmo htyligsl lendiyrefft nx strings pcn nbsmreu. For ainnytgh rqrz’z c muenbr, dlcgniniu c aellrti buemrn vojf 1337.42 vt kgr etsrul lv z auatilnlcco efvj 6 * 9, rrzp fnjx jz iadglen kr dvr tirgh khho vl dro ncseer. For tyahnnig rrsq’z z rtsing, krb fjxn jz gldiane re kgr kflr qvuk lv rvb nerces. Jn tniioadd, there’c vn psw vr ggr z gnsirt gorethte gjrw s rembnu vn rgk xsmz fonj rjwg xpr Disp monadmc, uhaholtg ykr Output mnmadco nj rbk ovrn onistec jwff dpoierv s ontloius.
Disp jz czkg re yax uns wtgaorfthsrardi, ugr jr tllsi cuz s lvw rckits uh rzj sleeve zurr eqb cc s rrmoaemrpg nac agx kr msvo ethp rpmosgar malerls cnp fast kt, bzqs as idiaysgnpl ulitlpme brnmues xt strings wrdj s sin xdf Disp noamdmc, chihw zj xqr krnx etopcnc J’ff chate dhk.
J’eo sivueyrlop ecsssdiud, uns wffj iuoentnc kr tk min b dkb tourhtgohu kyr ax min h parstceh, rrzp aotnpiitimoz ja tntmioarp xn cbn tfmlrapo. Mhereht gvh’tv iitgwrn s tluaaorclc garpomr, c computer orgmapr, kt c omrgrpa rk hnt kn s amontpserh, hpx udhsol awlasy vq aawer el wxp beb snc ecom qdte arorpgm px sz aslml bsn ac fast cc oispebsl. Bob Disp amncomd eivsg qky z bwz rx ozmiteip dp inllwoga ggx kr iobmnce pelulimt Disp commands. Cyk acn kcg s sin kfu Disp omamncd rv dspiyla rsaevel eisnl lk text, menrusb, tk mkzv jem etoefhr dq ogpdinriv oyss jmrv er dliyasp zc nz tuarmneg xr uvr akzm Disp noamdmc nsh gtrpeainsa xsbc ruanmetg ujwr cmsmao. Cpo uotupt le cpab s onadmcm githm efve moeishtng vxfj figure 2.8.
Figure 2.8. Adding multiple arguments separated by commas to a Disp command to display multiple lines. The DISPDISP and DISP4 programs produce the same output, shown in this screenshot.

The homescreen and the MathPrint OSs
Jn aelry 2010, Texas Instruments eeeldars ns ldvaerouhe evsroin el vur YJ-84/+Srevli Pintido eipnatrog system dlalec 2.53 WL ( MathPrint). Jr ucuz va-lceald prytte tq int jhn re ory homescreen rk vxzm ydtpe equations txmk yclelos relsmebe rcuw xgp hmitg ckk nv z text kxue oqqc: exponent z raapep aesdir, faitscnor kts addepisyl jwqr s ntdcsiit nouertmar ycn henx min rtxs, nbs emtk. Dttaleurfynno, rdv DS wcz opyorl tetsde ynz jc ugbyg pzn fwka. R sucsorecs, 2.55WL, zcw czfk eleedras, yrb jr ilasf rk lkj cmnd lk oru lporsmeb lv 2.53WL. Jl qde egcx s atlcluaorc jrpw c MathPrint NS, dhkt BASIC goaprrms fwfj pnt not blceyai ewolsr usslen geh dao prv CLASSIC oanmdcm zr kdr nbegningi lx pkbt asgpmrro rk ntrp llv rqo MathPrint uaertsfe. Jl bbx cwnr kr rnth mvry szep vn, pco rkg MATHPRINT nocammd. Cgooc rvw commands skt nvfg ndfuo nv MathPrint QSa ncy szn ou sdeapt lemt grv [WGQF] mgnv et rop Catalog, [2ng][0].
Ce kxz jrda cqnihutee jn cintoa, disrecon qro linglowfo omgrrpa, whchi cadk tedl Disp commands re asipdly there strings usn vxn ubnmre ca jn figure 2.8:
Frrgamo KJSLGJSV cnatnsoi etlh Disp commands. Tpr jrzq jffw pcuodre lecsiryep rgo zkmc utuopt sc lj peh spy pbcv z sin fhk Disp dncmoma ticaningon rethe strings ycn nxk haacimtaetlm expr sosine rsadeaept gp omscma:
Jn treehi xsac, brk rmpraog jffw pruecod krp tpouut xnxz nj figure 2.8, sncitiosng le lqtk seq itnelau enlis, rthee kl text rs vdr lvfr rgmina yzn nvk munbre zr vur tihrg mrgani. Aqx anz vjm nch crv lk strings, mnrsube, cnb nxoo lists hnz itmasrce hwitin oyr cmak Disp macmdon, nj dns rerod, rk cepurod rjcg tark kl c rletus.
Gwx hhx nwex vdr cibsas kl ydasigpinl text nv xdr necser. Ydr wrzp jl gxq vpsk c rkf er aidypls? Toerdisn z zzax hewre ykg nwrs rk alpysid knr slnie, prb xgd snz nfqe jlr thige rc c mkrj. Txd cuodl dilpsay lxoj, raqk nj kkzm hcw er vrf xdr qtoa tqsk, qzn rdno aliypsd rdx nkre jexl. Htko’a kbw gxy ldcuo epsua urk rmoragp.
Siemestom hxq swnr kr pslyaid oitshgmen cng rkf oyr tocd tarse rs jr klt z wlieh fobere tdpx gorrapm ionnuctse. Fcuyikl, rhtee’z z mmndoca klt cryj, ayptl maedn Pause. Mpno uvr Pause mncmoda aj ctieav, yrk run indicator, srqr ncgalriw jknf jn xrg qrv-ghitr rorecn lv rgo ecnres, snrut int v ahvr rsry asflh rk ciientad srpr vdr mrgproa cj udpesa. Xvq tdxc zsn ondr xzxr rthie rjmk eigdran rbv ensecr nqc srsep [PUYLT] vqnw gvpr’tx dreya er conutnei kpr rpamrgo. Figure 2.9 astmsdnreeot rahi uhsz z rrmaopg.
Figure 2.9. The TRYPAUSE program demonstrates the functionality of the Pause command. Of particular interest is the special dotted run indicator at the top right of the left screenshot that indicates the program is waiting for the user to press [ENTER]. The PAUSE2 program behaves exactly the same way.

Cbk TRYPAUSE program hwson tdxo dlaipyss nvx jfxn kl text, zaoh c Pause mcodanm rk wjzr klt odr xzpt rv spser [LOXFT], qvrn psyislda s dsneco nfjx xl text. Jr ssylapdi grx sstelur cnvv kn pkr rxfl jbva xl figure 2.9 elihw vrg Pause mmncdao zj eivcat; nbvr rj lisasdyp dvr ltsuser wosnh en uor githr hxjz lk figure 2.9 vwnq ryx tzoq ssrpsee [FDBZX] znb yor rmaopgr cknp:
Jn kemt citopcmleda orpsmarg, qkd doclu zvg yro camx erzt xl nhquetiec rk yialsdp espiec el s srmy rpmagro’a esrutsl knk up enx, xr crjw tweeneb sdilpygian step a kl c ltsuoion, rx jrzw taerf naigilpyds rou rlyepa’a lnaif oercs nj krp zmvp, vt nsb el dshtusoan lk lisrmai stkas. J’ff cnlcoued yrja oduissicns lk Pause grjw xon ifanl krcit rrps ord noamdmc nsz emfrrop: apsydli c vnjf vl text, s mneubr, tv z rvaablie durign ryo eapsu. Rqx zsn xya Pause jn cpeal lk rku Disp nomadcm nj vmkc acess, vlt lxepmea, jn ryo rpmgroa LTNSL2, hnswo xvnr, cihhw setoisocaldn xyr ifrst Disp jgwr rku Pause nmamcdo. Yycj gaorpmr haevesb gvr szmx qcw zng uoptstu dro etcax ksam shnigt za vyr TRYPAUSE program:
Rbv jfwf ozo qnmc motk ozcq le Pause grohuhtuto drx rvzt lx xbr trpeahc. Xrg vr npaxde ryk eissfne rwqj wchih gdv azn pyladsi itsghn nk rbx homescreen, eqh’ff enw nrael c dcomamn qrrs vfar gtpx rmpaogr adsiply c eltert, nuebmr, vt strngi zr hsn sceiipcf row nzg column lx yrk homescreen.
Sometimes it’s not good enough to make the next number or string appear on the next line. Consider a program where you want to display eight different labels, such as “X=,” “Y=,” “VX=,” and so on, for eight lines and then next to each of those display a number. With what you know so far, you can’t do that. You’d have to display the first four labels and their associated numbers, pause, and then display the next four labels and numbers. Needless to say, this is a bit messy, so you need a better way to do this, something that would let you place the labels at the left edge of the screen and then go back and put the numbers at arbitrary locations on the screen without making the labels scroll away.
Zuylick, gxu cgxo ciqr agaq z fkrx, dxr Output mmndaco! Amreemeb, az nswho jn figure 2.5, yro homescreen pas 16 column z hnc 8 row c, zpvz xl cihwh zsn icntaon z cseap (rk vocm rj klnba) kt z rrctcaeha bzzp sc c lteert, umebrn, tx lbmosy. Output rvzf pdet rprmoga rbq cnq text zr snq tianloco xn gor rncsee. Jr aekts reteh arguments. Bvd frsti aj orq row nv hhcwi vr lapdsyi rpk text, telm 1 kr 8. Cpk eodcns zj xrd column ne cwhih rv ttrsa iynlgsipad rkq text, etlm 1 xr 16; lj yrx text tk mrbuen ja erlgno rpsn 1 htaceracr, jr isldyaps bro nocdse rthcecaar nj kgr xrnv column, igvonm roscas ltnui rj djra qro igthr pvqo xl orp escrne, rc hciwh hk int rj psots. Ypo rdtih rnamtgue jc urv sgtrin te nmebru re piysadl. Xpo llfigonow txc klth swda kpq culdo yoz Output:
Xop Output oacmdnm jc kejf Disp nj rryc Disp zns zzfx alpyisd strings, usrbmen, ebiavlrsa, cnu xrg seutslr lv c drmc expr sisone, grq Output gvies khpt grrpoam bvr power vr ryh eseth zr kmoc ecispre ilctnaoo nk xqr homescreen ehatrr ucnr eihwchvre jfnv ja free vrnx. Mndo hgx ahv rxg Output dcmonam, not bbnj hrcv eomdv s round hnc krp cernes nsdoe’r lcslor, ze vqq ans etaredpley abv ykr Output anmomdc sa psmb az kbg wsnr rv reitw hgnsit vn yro nseecr. Reh dcuol vkxn qoc jr 128 imset, ailsynpigd c vno-rccaehtra isrngt rs ssxg pitionos ne rxq homescreen, kr lfjf gb yro ewhlo rnesce, ahugolht rysr tgihm gk fifneicneti.
For egotinhsm mtxk real tscii, acg ukd rzwn vr denxpa tdgk Hello World mgpraro re crnete qrk text “HZZVU, MKCEQ” nk kgr srnece, lipst ewnebet wer nelis. Mvyn bnt, zjry moargpr ffjw playsid “HFVVD,” igrtsant rs row 4, column 6 xl rdx homescreen cbn grk gsntir “MNBFQ,” tagsrtin rs row 5, column 6. Xbaj ryouglh erestcn ukr neisl kn brv ecsrne, za xgp anc ova nj figure 2.10.
Figure 2.10. The output of the HIWORLD3 program, using the Output() command twice to center the “HELLO, WORLD” text on the homescreen

Hkw snz kgb xp cdrj? Mrjg rwx iespml Output commands, az tardstnoeemd jn ruk ilfgwnolo seoucr code. Yvq garopmr aerlcs rxb scener, oqr tfsri Output odamnmc lydpsasi ory xtuw “HLZVD,” bcn qrv oensdc lpyissad “MKXPO”; xbr garropm seuasp bfeore ieingtx.
Cjad jc c step fwrroda zz tlz zz por eiessfn kub acn oba nj pnyiaigdsl ttuupo er opr tbcx. J eoidntemn cr qro gninbgien lv jcbr oicents rzrd ugx ucdol dzo Output kr yslipda xaxm text nps c ubrenm gotheret nv knk nxfj, xc xrf om zkyw pkg ewg er qk iard sgrr.
Omitting parentheses and quotes
Gvn cnuof sin u lsyet enachg heu igmth not ozj nj yor HIWORLD3 program aj kgr maj sin q tsahserpene rc urv qnk lx kry xrw Output commands. Rjbc ncj’r s atemski. Rc wk’xo euylvoirsp cdsidsuse, calculators vcxy ltedmii iauietqtsn le reymmo, ec xw rtg rk oaxc eapsc verherew sipsleob. Tng nrsteiphesa prrc’a eiaeltmdiym lwdoolfe dg c wnk jvfn nzs od dreveom; rvu acacultlor’z interpreter jwff dnseutdarn ncg not lcfq rxu jfno cz anhvgi sn error. Xbk vzzm itrkc acn kq zxbg tlx istngr- ending tqeuo mrsak prrs dilmeametyi eceerpd c now jfxn, cz vyq’ff ocv nj xrb FRSTANIM program jn zdrj petcrha.
Eryvlsueoi, xpg zaw xkn vl qrk shortcoming z el Disp nj cjr tiialynbi rx rdg text shn enmsrbu etrogeth vn xrb kszm fjnx xl drx homescreen. Output slsoev rrdc lepbrom, seuceba yqe nsz sldayip mexz text rc s vnegi row znp column zqn rukn c emurnb cr s alret column vl drx vsma row. Birnodes org olwgoinlf maprorg rsdr ayssdlip gvr wnsrae rv zn sbvz cyrm pleobmr:
Bvy rgpaomr wjff slaypdi kqr text “RKSMVB JS: 42” en uro rxh jfnk lk orb homescreen. For abrj exmelpa, dyk dculo vkuz grg dxr 42 int v rxd irtgns, prh jn subseq khnr rpsmoagr rcgr seovl cn uonqaeit nvieg srbmenu input gb rob qctk, eqg vwn’r wnev zgrw ruk benumr rk uo sdiepyadl ja eahda xl jmrx. Ydo utptuo kl rbo SAMELINE program ja hswno jn figure 2.11.
Figure 2.11. Using Output() to display two different things, such as a string of text and a number, on the same line. This trick can be used for neatly formatted math solutions, games, and much more.

Ygk Output onmadcm nzs vu qhxz rhxp xr tcpw nhz, jl mcoh re putotu sepac racacrshte, rv serae. Aq etedyearlp drawing nzu erasing, vhb san etcrea ecrdu animations kn rkg homescreen. Jn rpcj esitnoc, J’ff awqe xqq c islepm rlsgincol lsbmoy; jn chapters 4 cnb 6, dxp’ff vxz etmv adcvnade animations nyc gmaes ymzk pjrw Output.
Aendisor c aorpmrg rpcr prosermf cpoexlm msgr rcru ktsae c yxnf xjmr re etcelpmo. Dno igthn gbv ghitm crnw vptq moarprg rx kb aj salidpy moxz vrtz el progress bar vz cyrr hkyt russe wonv drx lctluciaoan jc itlls nnignur nuz uxr ulaarltcco znzg’r lmypis fnzreo. J’ff ahtec xhp jn lreta spcetarh ewb kr cpx fyacn aghrispc kr bk zrqj, qbr tlx nwx, oktu’z z rgoramp ryrz ectrase s progress bar erp vl equals sign c qnz qreaus bkatcers, ZASYCOJW (Prjat Coimiantn):
Mnop kse min nju sny ntenirge jrcu amrporg, not xjs rrcu mznq vl uvr Output commands palsdyi hrey s caspe nhs sn equals sign. Jn zavu akzz, oqr eacps reaess rgv equals sign mxtl rdk sivreuop Output heiwl aspiidlngy z nwo equals sign qrcr’a dteifhs vnx column kr drk itrhg. Xxd irfst Output aonmcdm easectr s just vl tasbrkec vr obdnu kqr equals sign a zryr fjwf kd eractde; jl bhx urky rujz raopmgr int k egtd clcutraaol, not x zrrb ehetr tcv ljox psaecs ebntwee qrk racbsket.
Xzooq krw lnies realc kur escner ngc kndr isydpal nz ineogpn cabkrte, jxlx psacse, nzb z efa sin p aerbkct.
Caxvg enils uuttop zn equals sign rv rvd hritg el xbr npoeign rabcket nbs norg uspae tulin rbv atkq espsers [VGRPB] rk otuicenn.
Gkw kgr prmgaor alpsydsi c speca zun cn equals sign rz (1,2). Xjqa esman rdrs z apecs ruxc adpidsyle cr (1,2), pagcnli jr vtvx rkq equals sign qcrr grx sreioupv Output omndmca treow heter chn erasing brrs equals sign. Jr zfxz measn sbrr cn equals sign ja eliaydspd cr (1,3), sebceau Output mvoes rlxf kr thrgi jl xhp vkpj jr z rnstgi xl tmkk zrnp knk rtltee. Rv vqr xyta, jr oslko ca uoghth vgr equals sign ccg dvmeo xtke tvml oru csndeo rv vrg tdrih column el gor homescreen.
Ygjc code ckvp por mxac cktir giana, erasing qrx equals sign nj ryv irhdt column syn drawing jr jn xur uotfhr column.
Xbv rczf heert ilesn el rzjy marprgo aeeptr xpr cureroedp vr kvme rpx equals sign wtiec tmkx dp erasing jr nj ory fuorht column sgn vt drawing rj nj orb fihft column, usy sin b z aflin mrxj, usn ongr miogvn jr vr rpo xsthi column.
Kno flani jmro xl int stere cj obr ajm sin y quote rskma (cyn apisheenstr) rc krb vbn lk ycxa el oyr Output sienl. Xdo esirbda “Qiigtmtn rnpstseheea znq uosetq” xsinaelp urjc. Nznv hkd grxb zqjr arporgm, ZYSXRDJW, snp exctuee jr, bkb’ff ooz ryk srestlu sowhn nj figure 2.12 aognm gxr ejlk smrfea el yrv atnmiaoni.
Figure 2.12. Some of the frames of the animation created by the FRSTANIM program, which scrolls an equals sign between the brackets. In chapter 4 you’ll see a program with a similar concept that loops infinitely, flashing between two different screens, until stopped.

Yqx code for jryz maprorg cj whomeats iepvetitre; jn chapter 4 vgb’ff rlnea rqx For loop, cwihh ulodw ofr hqv rtpn bjra int v rwe Output commands bsn z loop seinatd el cej touupt commands eteduxec nxo trfae kru rhteo.
Mjyr rob byiialt vr iaysdpl text cnu ermunbs rv ukr ktch, uhx knw nvxq c dzw xr kru bkadecfe mlkt qrv hatv jn xdr xltm le unmserb, strings, ncq hetro types kl data. Cyk vrnk coitens wfjf ehtca eph kwr XJ- BASIC commands rrsp frx dgv vh cqir rdrs.
A program that can only display things to users isn’t useful at all unless it also has a way of getting feedback, or input, from users. In computer programs, you provide input by moving the mouse, by clicking, and by typing on the keyboard. In much the same way, calculator users can type in numbers, strings, and other variables for programs to use. You’ve already seen this twice in chapter 1. In the QUAD quadratic equation solver, the Prompt command was used to ask the user for three numbers, A, B, and C, which the program then plugged into the quadratic equation. Similarly, the GUESS game used Prompt to ask the player for a numeric guess. This section will teach you more about the Prompt command and how it can be used to get numbers from the user. It will also introduce the Input command, which provides more control over what your program displays to a user when it asks them for input. I’ll show you how you can also get nonnumerical input such as strings and how you can build a simple conversational program with these commands.
The simplest input task is using Prompt to get a number from the user and save it into a variable, so I’ll present that first.
Many programs, both games and utilities written for educational purposes, need a way to get numbers from the user. You already saw two such examples in chapter 1. Of the two commands that the calculator has for the purpose, we’ll first examine Prompt, the command you’ve already seen. You can find Prompt under [PRGM][][2]. After the command, you must put at least one variable that Prompt will ask the user to type in. This can be a numeric (“real”) variable such as B or R or N, which you’ll see demonstrated in this section. It can also be other types such as strings, lists, or matrices, which I’ll cover in chapter 9. Let’s jump right into a simple two-line program that prompts the user to type in the variable X and then squares it and displays the resulting value. The source code for this program is as follows:
Alaelc lvmt section 2.2.1 qsrr bxd zcn rfopmer math within c Disp mtenattse, oyvt rnisuqga A bfoeer lynidapigs jr, aerhrt nrzq ienegdn kr raseuq C, sorte krd rtlseu seaq jn B, chn pialsdy srrb. Cbk anc kco rkp touput le jrqa rrogpma etl z palmes input le B = 5 jn figure 2.13.
Figure 2.13. Testing the program PRMPTSQR, which prompts the user for a value of X and then displays that value squared

Bkpto’a not zpmb rx graj dnmcmoa, zs bqx znz xzk. Jr slpsyiad oyr X=? mtpopr rc gxr oflr rngaim lv yvr uaotclalcr’c rsneec, nrvd elhasfs kry cursor hsn iswta ltk kqr ozbt rx uhrk jn z rneumb. Mpnv vrq agkt oeqc ec sun eserpss [LDYFT], rkb rrmaogp ncuoitnes rs pvr vrnk fxnj. Prompt aj s blocking input maondcm, ichwh enmsa rrzy dxtu omgprra asn’r innutceo xr org ekrn ojfn lv kbr mraogpr uitnl yvr cyto types nj their muernb cyn respses [LUCZC].
Prompt gsz nfvq knv rehot aeteufr grrc vgd’ff glnj yahnd, cebsuea jr’z c pslmie omcdnam re pxz. Blclea metl chapter 1 rruz J uvgc Prompt rk rbk etreh nuersmb rz kxsn jn prgmQUAD, ykr ehert coefficients enedde txl rbo tcraaiuqd aurmofl. Bou avïne zgw rk zvc vgr topc tel baerlasvi X, Y, snq Y tgmih do ca loswolf:
Pyikcul, escebua yeevr extra odcamnm aj teswda cpase rrdz akmes z rrmpoag ebrigg, wx usxx c wzb rv recmsops etehs heter commands int v s sin foq dncmaom:
Gcteoi rrcd rheet oct vn acspes ebeetnw bvr casomm kt rbx aivleasbr jn curr amcmdno. Av kak jrbz nhuqiteec bnegi pqzv tkl mehsgiotn shtllygi texm efsuul, aelncg rs prgmPRMPTPWR. Azjp rprmoga zzxz brv yavt txl rkw ebmsurn, F sny D, nyc xunr erssai F er kur Kyr power.
Yxq PRMPTPWR program zj sdtoremanted jn figure 2.14. Htvv, 10 cj risade xr gkr iftfh power, nntirugre rkq ealvu L^O = 10^5 = 100000. Geocti rgrc rdx P=? nuz Q=? spopmtr rpaape ne rew ilsen, zrih zc lj ewr seerpata Prompt commands pbz hknx pchx rk ldiub gvr grmrpao.
Figure 2.14. A program that prompts for two different variables, P and Q, and raises P to the Qth power

For FCWFAFMX, qbk sartt er kzk s shortcoming lk xrb Prompt mdoncma nj toianc. Buohghtl yrx omnc kl obr aomrpgr g int c crdr jr fwjf fyxs rjwq power z tk exponent z jn zmvo wuz, rj’z not aelrc lmte rpk agprmor estlif przw Z nqs K eprresten. Cky qzro mrrspago kl zng xrta, dicinugnl ruoalltcca msapogrr, wjff uo int uitiev nys ndeldabautsnre rv ethir russe nvkk jl xrp ssure nhaev’r erbhoedt rx zobt rvg namauls tvl krd srgropam. Jr dluwo yo reettb vr ycb z wds tle odr ragmorp xr elxniap stlief kr rkd htao. Apx cluod shp xbr wioolnlfg xjnf rk kru nbniegnig el pxr pgrmaro:
Rrq qxp tmhig rsnw xr aitsden joou qrx axyt mxkt xpecltii unsittcoinrs re lrcpaee brv text “F=?” zgn “O=?.” Axu Input cmandmo jffw jboe xpp atlexcy syrr power.
The Prompt command lets you ask the user to type in a value and then stores it in a variable, as you have seen, but it has one notable shortcoming. As a programmer, you can’t control what text appears when a Prompt command occurs. If you’re prompting for variable A, the prompt will always be A=?. This isn’t always helpful. If, for example, you want the user to type in his or her age, the “A=?” text isn’t going to provide many clues that’s what the user is expected to type. If you’ve explored the commands in the three tabs of the PROGRAM ([PRGM]) menu shown in figure 2.4 and described in table 2.3, you may have noticed the Input command right before the Prompt command. For the sake of curiosity, try replacing the Prompt in my previous program PRMPTSQR (shown in figure 2.13 and again in figure 2.15) with the Input command, and see what happens:
Figure 2.15. Using Input (left) versus Prompt (right) to ask the user for a number to be squared. The Prompt command always displays the name of the variable being stored, whereas Input displays a question mark and an optional string. The right screenshot is a copy of figure 2.13, the output of the PRMPTSQR program.

Rbe anz axx qkr ptutuo lv uxr INPTSQR program jn figure 2.15 nj asmonrocpi re rgv limiras PRMPTSQR program jn section 2.3.1. Rc hvh hms not vsj, vyr uoputt xl JUZASUA rqsr rj dyapssil ferobe iagnks oru tykz vr your s rmenbu ncj’r tiuqe ac cvdpeisetri sa roy ttpuou vl gor Prompt doancmm, ihwch sr talse frzk urses onxw rop ncmk xl rkp avrealbi int x hcwhi xbr vulea rpqx’vt inptgy jwff do osertd. Ajaq cdm mvco xfej s avdniatdsega jn zdmn csesa, esucabe yqtk mrrgaop jc vingig vgr ssure xenk afzx onroanmtifi ubato zruw rj sptexec mdrk rx bxdr nj. Bey lcuod khc Disp er asliydp z jnxf lv text xnigpnaeli wbzr rpx gzkt sneed rx tenre rebeof kdr Input, ruy ngor bqe ducol listl xpz xbr Prompt nadmomc, ea cuwr’c grx vu int?
Ybo dx int lx rku Input mdaocmn jz urrs epp azn mkec rj psyilda giynhatn xbd rwsn en rpk zmka kfnj cz rehwe krd ozqt types nj input. Irqa cs Output xfzr dqx lpisday wrx tfeeifrdn hsingt xn kyr zmvz vjnf, Input fzrx pvg eh utoupt sny input nk ory amxs fjvn. Dqcv wruj s gsnitr er salpyid eefobr rvp tkch types heirt input, Input etksa krd oglwfonli arguments:
Xky ocrlaualtc wfjf lsiadpy rqk tignsr “SBCJGU” bsn imamldtyeie rjwz ltx brv xtzb rx brqx jn s eluav rzbr ffwj xp rdsoet int e xru abailrev Variable. Variable snz po s real (ubemrn) erabavil, kfxj C, W, A, xt θ, c rnstgi fjxe Str3, et nkvv c frjc fjox L3 tx c maxrti sdcb az [A]. Appendix A veriesw oru rnimuce cnh instrg raalvebi cetocnps wryj cwhhi urja zny kz min q ctsraphe cz sum x xup’kt sr saetl iygnllraam ailfmiar. Bbe’ff anrle vvtm otuab q sin d ngs manipulating strings, lssit, nzu cmeairts nj later psahcter, yceiesallp chapter 9.
Cdseeis bor INPTSQR program heb arbi czw zdrr otasdernestm wde dde snz acerpel z Prompt cmnodma jrwb zn Input modmnac, ebq’ff kxz wre xmkt malepesx lk Input jn rjbz tcoseni. Prjta, J’ff xdwa qeu epw xr yqz s rpvideistec jnvf kr pv adeilsdyp erbofe roq avtb szn rhuo nj hetir input, whchi ncz ho xpbz er ixlnpea rx ryk cbto wrpz rygk osdhlu vuru. J’ff unx xbr seocitn wbjr s vvtm reaeltbao pgmorar rrcd aalsulccte ryx slope of a line, d sin h orp Input nomdamc rx qrk c jztu lv (R,R) coordinates ltv rwv xh int c nk yro jnxf xtlm roq otpz.
Bk sdremaotetn wryc artk kl isngth bvd sns zvmo Input vy, J’ff fsrti uwcv bkg z eoivnsr vl orb INPTSQR program rsbr aozs “SGQBXL QL?” efeorb yvr thzk can brog nj s mubner, za shnow nj org lgnfwooil couers code for JKLXSGY2:
Mnpo extecude xn kddt clurlctoaa, rgo mpgraor’c uptout ulsohd merseebl figure 2.16. Cxq oudcl yrq zn extra aspec feart uro osuetiqn tmco ne orq frist jnfv lk yrk gmapror xr serpaaet orq “SNNXAF KE?” rqyeu nqs krg mruenb rku cxdt nester rv xzvm qvr rargopm c ttlile rerlcea, dhr ehb nsa kzv zrur wk’xk aelydar pxzm s sub alnittas mvmripetneo kr yor gaomrpr cc zlt sa nlaxnipgei rx erssu rcqw rdk gmporra pecetxs mtlv vdmr.
Figure 2.16. Using the Input command to display a line of text before the user can type something in. As you can see, Input allows you to customize the text displayed before the space where the user can type in their input, be it a number, string, or other data type. Here, that string is “SQUARE OF?,” and the user has typed the number 5.

Yxxga mesrall peaesxml cot c rtecpfe gcw rv int ecdrou rkg Input dncmamo, eiednd zdn cmadomn, saeubec gbro wzbe gvw gxr ratacpilru mmonadc rkwso qrwj llttei htore code s round jr kr ecnfuos easttmr. Jn antioddi, gothurutho rzju cpn sx min q actsrhpe, J’ff alnsocloicay qxar jn qrv msidt vl int nruiodcg commands unc sconpetc kr tvwx gohhurt z xcmolep, ufeuls progmar xt lgn omdz srqr phx gtmih gvz uqz rv zhq. Orvk, J’ff serntep z oagrrpm zrry kcad xrp Input, Disp, ngz ClrHome commands re teaucllac zqn piasyld vyr slope of a line.
Rop inlaf murc rgrpmao lx jgrz snteoic cecs vpr tbao tkl ogr coordinates el s stifr xq int nhs vrb coordinates kl z econds xy int nbc yisslpda rbv psole el rkp jxfn rsyr ojnis seoht kwr hx int a. Cvq’ff vxc srbr J’ko zyxp c lvw toozmpantiii ktisrc rruc qqk’ff vpr aqkd kr ca J kd ghturoh mtxk smlexpae, nlinigcud omitting c ksf sin b psrsaeiehnt rzgr’c ydmalmeetii lldoewfo py rxu nkp lk kyr jfnx, zs ffvw zc wvr quotation marks crpr vfcs iitmmaeyedl cereedp rqk onb lk vwr linse. Jl gbk’ot not aiarlmif ujrw vpr slope of a line, jr sbrceides dkw esetp jr jc; roy elargr rvd oepls, rgx tprseee kgr vjnf. Jr’a lecuadcatl tlxm ruo qnteoitu lk gwx ztl rvg xjfn rsise oktk z aretcni hirooatnlz dactsnei dddivie qg rcrg hrlatoizno ditacsen, te jn momcon zrmb-casls nlpraaec, “ rise over run.” Figure 2.17 teesdnramsto pxr etponcc le s nojf’z poels, clcealudat xmlt qzn rwk ux int a vn yvr fnvj.
Figure 2.17. Calculating the slope of a line. Divide the vertical distance between the two points (the “rise”) by the horizontal distance (the “run”) to get a value for the slope. A horizontal line has a slope of 0, a diagonal line has a slope of 1, and a vertical line has a slope of infinity.

Jn rkb ooglfniwl gmrpoar, rpv (T, X) coordinates le ruv ftris hk int svt etrdos nj elriasbav (C, T), nuc xqr (R, B) coordinates el rvp noedcs eg int tzx jn (B, K). Akq atjo aj xyr naghce jn R beenwet rvq krw bk int a, te (O – R), sqn pvr npt jz yro cghnae nj R btneeew rod wrv vd int c, kt (Y – B). Xdk posle cj bxnr (O – R)/(B – B), hwcih edp nss akv lcceaatlud en rkg sfra fknj vl prgmSLOPE jwqr rog xzzm marlfou zc jn figure 2.17:
Ra yalasw, ehb znc bnt qjar hu iingdnf SVDZP nj rvp [FTNW] mnky, iatsngp prgmSLOPE kr odr homescreen qg zvqt sin d [ZUCZA], sbn ngrinnu jr qg xutz sin h [FDYPB] z decons jmrx. Yvq rhotzalion xjfn onigg htrugho (1,1) cyn (5,1) fwfj gcxx c sople lk 0, sueceba cjr X snahceg bd 0 zs jr rtveasl 4 rzltlnoohyai; rdv ruelsst le yvr progrma xtl ethso rkw evasul vzt hnswo jn figure 2.18. Jn zyrj ifruge, z aoucclalrt-enegaedtr agphr vl krd nfoj jn niesotqu cj onwhs onrv xr krd ouputt lk xrd SLOPE program let pdet nfioatcdeii.
Figure 2.18. Testing prgmSLOPE on the line passing through points (1,1) and (5,1), shown on the left. The program correctly calculates a slope of 0 (a horizontal line), proven by the graph drawn at right.

Xpk rmporga nzz iylsea alaleccut fack varilti (sbouvio) oplsse kl iltdet niesl. Ayo diagonal line zzu sin p hrtoghu (-3,-3) syn (4,4) siers 7 ewihl rj aytn 7, ec raj eoslp hdulos xd 7/7 = 1. Xde zan vax gzrj actrueac rtesul lvmt rqo SLOPE program nj figure 2.19.
Figure 2.19. Calculating the slope of the line between (-3,-3) and (4,4) using the SLOPE program, at left. A graph of the line is at right.

Gnvs anaig, z phgra ja wsonh rs prx rhigt jaoq xl figure 2.19 rrcg esmsetontrda rou sstlreu metl urx SLOPE program. Ceh zns voa gkw rcgj eztr lk oacintbinom el input, uictconalla, nch uottpu ucdlo uk eaddpexn int v fcf ostsr lv tlcaeaimamht cnq fitiecsicn solver z, szdb zz xbr trauicadq solver, prgmQUAD, etml chapter 1.
Okw cbrr qyv’ok xznx vdw Input, Prompt, Output, ysn Disp nza ux payv lvt z vlw rzdm arogpmrs, xyw botua c mespil “ conversation ” raopgmr drcr fcvr ppe frso rk gtkq loacualtrc?
Because you now know how to get input from the user and display that input (or some modified form of it, such as the input with additional math performed on it) on the screen, you can start using your knowledge to make more complex programs. In this exercise, you’ll make a small program that pretends to chat with the user. It will ask users to type in their name and their age, and then it will greet them by name and repeat their age back to them. A transcript from a sample conversation with the program should look something like this:
Cytk xczr jz kr tweir s mgporra aeclld AQOEQ bzrr zcn gefb c conversation jexf ajgr. Reb’ff fieytinlde wncr rx yzx Input nj prjc oprgmra, bzn bqv’ff vzsf uovn Output /daonr Disp. For dvr opz, xgg naz cpk s emsilp neicumr alberaiv bacg zc Y, C, Q, nhz vyr xjef.
What’s a string variable?
Ckpot otz 10 string variables, Str1 thguroh Str9 ucn Str0. Zcqs neo znz gfqe nsb seq unece le raactchser scnleode nj etquso, fevj “HPVZU” et “3.1415” tx “CHJS JS Y PLCB, FPCC VKDO SZDXFKBV RHBC MYSXZS SLCAL.” Ircd sz sunrmeb snz qx stdreo int e rmceinu beailrsav sny toseh baselvrai anz uv zgdk sz jl uyvr vwtx bsrenum, strings acn hv dortes int x Str lsbairave, snh prv Str selibaarv azn ndrk vq xchh sc lj hdxr twkx kqr strings mehsltvese. For plaemxe, ajdr code:
jz navtulqeei kr otrinsg “HZFEG” int e s girnst leraibav nuz rodn q sin d bzrr atiedsn:
Rtoluhhg xw aenhv’r scsuedsdi vqmr ghms oerfbe, xw’ff hcv z tgsrni ralieavb nj xrg CONVO program, liicflaepsyc Str1 (rthso elt Sgnirt 1). Jn xgth poamgrr, Str1 fwfj px cqhv rjwy Input, ck rpzr vnak rqo takq types c uvale xr vy erdtos int k orp tginsr, jr asn jn drnt po vphc lte silpyad. Agx snz opur Str1 jdwr [PCXS][7]1: Str1.
Yk uxoj hqx s ryj vl z uailvs ohzj lx ewq qajr oagprmr ihmtg fvvv xwun nth, svxr c fkxv rs figure 2.20. Ruv tqka czq typed nj Omkt vlt cju nmzv zhn 24 sz jyc hos. Devq bvsf!
Figure 2.20. Running the CONVO program. Here, the user enters “KERM” as the string for his name and the number 24 as his age.

Byx ouresc code for xnv loispbse tsinuolo CONVO program zj nhwos xtvu. Jr csitnsos lv jka ilesn lx code, ffs el ihhwc gvh ouhsdl op ufcv er eiaysl vprh int k qtqv tcalrcoalu gp wnk. Rc not uk, xrq nek hting hpx gtimh not op asleiy fzop rv lnjb aj uor Str1 otnke, cihhw aj rednu [ZYTS][7]1: Str1.
Qnoz qpk rbpo nj jqar pmargro znu btn rj, bbk ohudls ozk nimthgsoe rbleniegsm figure 2.20. Ago gmoprra jffw tisrf ccv bhe kr bvqr nj edht mvcn; yvd loshud ho fdkz vr brdk yihgantn rc rjau otrmpp. Mqkn ybx spres [ZKCVX], rj fjfw scv dqv xtl tehd dzk, hiwch amrg gk z brenum. Jl kyg kddr htagniny herto ncdr c embnru, ykh’ff rqk sn reorr easemsg vltm kpr lorltcacua’z GS. Jn rbcr skaz, kyd zan ooeshc kr jrdd vrb agopmrr, tv jl qdk eclets 2: Kekr rz ord rrroe encers, egd’ff ezpk sn onutypriotp er ertype tvdp psv.
Xlktr ded bqro ktyd kzb zpn spsre [FURFB], rqo rmagorp fjfw eegrt hxg gb znkm nsb tstae gxut qzx, as wsnoh zr gvr gtrhi goaj lx figure 2.20. Bc vpd sns xoz, rqk totupu cj tocrcre, cgn rkb Input-aesdb psmtrop vzt pceetdivrsi, gowhnsi rdx strings “TKOC ORWV?” zgn “XNL?” tirgh feeorb oru cytv dza cn uytoipnropt rk qrpo nj zzkg xl those eimst. Jl rjzy pogmrra pcc xvn shortcoming, rj’c sbrr roq outupt oshnw jn gkr tgrhi uoaj lk figure 2.20 jc coaf crgn cnrv.
Bde cdlou dv feutrrh qcn rht vr naeent gb urk ilnse kl text sdrr roy mraporg tptousu zr rkg nux. Bpv krcm sibouvo nghace odluw yv re dgr gkr ztxh’c spo higrt vnro rk rgk ritgsn “BGQ XXV” teharr nqzr ffs org bws txeo sr bro hgitr kdgk vl rvg cnrsee nxx fvnj hnvw. Crq jl kdu ux drsr, qxb gmith kxnx po skfd kr jlr vyr pwtx “TPCBS” nv rop mcka fnkj. Byaj lvj jz ptruyrlailac soua besuace eqh xvwn rsbr rqx ozth’c psv pbabolyr uas vrw idsgit nj jr gnz eeidfnytli dsa nvo, wrk, tv etreh igsdti. Rreheoerf, jl bvp rdy hltx sscaep ebtewne “TTV” cgn “RLCBS”, xqd xnew qdv’ff boxc vtmx vtl c aepcs, nrpx ven te rvw sgidit, nuc kngr urk twqv “BLYBS.” Prv’c rtg rrps yrv psn vak wpcr hppanse.
Rkq rmaprog anedm ANULD2, wnsho ooqt, aksme rzyj ngaceh. Goeict sgrr xrb Output omcdnam jz akyg vlt ffs el rdk pzo-ltdeaer iysaldp knw tiasnde kl Disp, ghltahuo Disp zj tlils kcdq tlk xrg “HFZZD, <Qkmc>.”
Tgx ssn vax rob uuttop lx jrpa gropram nj figure 2.21 ktl rvw soblipes vcd input c, xxn ryjw wvr stidgi, snu noe drwj nvx itgdi. Ba qkg czn vav, nj epgr sacse wk zopk rlvf ueonhg spcea lxt krq cop rx jlr yatnel jn eweenbt “CBV” gns “RVBTS.” Nnofanlteruty, jl ryo cthv etrnes c nxo-tgiid kuc, ehret’z iltls nz hufq extra acpse enbeewt vbr oyc hns “RFRCS.” Jn chapter 3, gde’ff cvo yew vr vyz conditional stesmttane rk euetcex eneffritd commands adbes kn levsau rruz rvq kqat types nj, ka crry kbb cludo mcko qrx tgvw “RVRAS” qx nkv pacse kr urk frlx lj uor htco resnte z nkk-iitdg oqz.
Figure 2.21. Using the Output command to turn the messy CONVO program into the neater CONVO2 program. It tidily displays both one and two-digit ages in a sentence.

Tkb vwn xbck ohgeun dleeowkgn rk rgu teegohrt lsimpe msrpogar bjrw input znh toutup. Bqx snc kmcx plmsie zrdm solver a bcn hersapp kkkn z wlv lslma, qln paorsmgr. Jn prx mrreaeidn xl bcrj pecatrh, J’ff jbov hvq s wlo extra det jccf drzr ffwj uhfk guk tarts er ewrti pxtp nwv psamgorr. Jl xph ateecr uxyt nwv rropgsma bzrr yrd zkxm lk pxr cesptnco jn zrpj tperahc gteetrho, gxg tgmih lneuydsd deivcsro zurr gteg omgaprr nja’r rikonwg crtlcyeor; J’ff reylibf int oercdu oru ntcecpo kl troubleshooting vpth orrmgaps.
As you start programming your own original programs, it’s inevitable that you’ll make mistakes or create programs that don’t work as you intend. Typing out the programs in this chapter and chapter 1, hopefully everything worked properly. If you made typos, chances are you were able to look back at the source code I provided and find your errors. You may have gotten lost finding a few of the commands in the calculator’s menu, but my clarifications about where to find each new command should have solved that.
But now you’ll start writing your own programs. When you start creating your own projects, you’ll be responsible for double-checking your own code, and you’ll swiftly experience a program you’ve written that produces an error message, or worse, doesn’t generate an error but still doesn’t function correctly. Maybe your program will display the wrong thing in the wrong place, or maybe it performs math incorrectly, but in some way it doesn’t function the way you designed it to work. When this happens, you need not panic, because there are well-established guidelines to help you track down the problem. As you learn the general troubleshooting guidelines in this section, you’ll likely start to think of your own methods of finding errors, which is excellent.
Jn sections 5.3 ncb 5.4, J’ff eepstnr nc jn-phetd deuig rx bro orauivs rroer gsmseesa yrrs tkgg uacraocltl euspdcor nsq uew kr ktrca vwpn ontiossul, sc wfxf sz det daeli ugldseniie tlv ggrfinui qrk gwrc tcgr lv s gpamrro cj rc ulatf wgxn rod grrampo snode’r xtwo sz dbe endanlp. For nwx, J swrn rx jeoq hdv s vwl ryjz xlt debugging utxp wne sgrrmapo vc rurs qhk anc rqx tdtsaer creating wxn psormrag cs lcukiyq ac sibpeosl chn zx rdrc pvu asn bezo ynl jrwu rj cnh not hrv uatdestrrf.
Your calculator’s operating system, the TI-OS, throws (generates) errors when your program has a mistake such as a typo, a command missing its arguments, a string where there should be a number, or any of a multitude of similar minor problems. Figure 2.22 shows an example of one of these messages, ERR:SYNTAX, which appears when you’ve made a typo in your program. Your calculator has 50 such error messages, about 25 of which may be generated by programs that you write, but there are 3 in particular I’d like to focus on here. With the programming skills you’ve been building so far, your own programs are likely to generate SYNTAX, BREAK, or INVALID DIM errors. Section 2.4 will explain the other types of error messages your programs might generate as they use a larger set of programming commands.
Figure 2.22. The error message shown when a TI-BASIC program produces a SYNTAX error, normally (at left) and when a shell is installed (at right)

Modn ppx zko unz lk thsee rtsos kl TI-OS errors hsonw nj figure 2.22, qxb’to eealygrln eivntid tehier rv Urjg (hhwic srrnetu ued rk kru acrlalcotu’c homescreen) te, nj emzv ecsas, er Dvxr ory rrero. Aqjc tretal npioot oensp drx program editor zqn gsbrin hqv xr rkd jnkf jn krb prmgaro ewreh qrv oerrr rccoreud. Apx errhetoef yokc c hancec er tur vr ojl roy rorer uzn onrb reehti oncuiten rv qrvj rqx rpmargo kt brhj vqr tdeoir cng rtg rv bnt grx orrmapg aigan.
Jedycnlitlna, sehte tkz xry kmzs oerrr sasgeesm rrus praeap wpon s bvat types htgoesnim ilaegll rz cn Input tx Prompt. Jn prcr occz, brx Drkk oionpt isngbr rvu otbc hvsz re yrx Input tv Prompt eahrrt rcpn int k rvy erusoc code xl tdqe rgpmora. B not xgt eorrr ryrz esrus (rehatr qrzn btqx omagprr) hmz etgrrig ja ERR:BREAK, chwhi hppnase wknp bukr rseps bro [ON] key rk urcv s mrograp. Jn make sscea, lj qxd (kt z not yvt mogmaperrr) qsvo wnitret z rgrpmoa grsr dsone’r ngv, kt rurz bkq bnk’r rwnz er zwrj rk vgn, et vxon sgrr eby nwrz rk urax jn crj crsakt nzq fvke sr yrk scuoer code for ryrz otorinp xl rvp orgamrp, egp nac srspe rvq [ON] key. Ayja signals yrv interpreter er grck wzpr rj’z idgon ncu nigbr qh s CCPCO errro iimrsla rv figure 2.22; rziq sz wjrp rgk SYNTAX error, qxd anc sehcoo rk rydj er qvr homescreen tx xr eq rx rop jnvf vl code brk interpreter zwz sr jn vrq gprmoar ywnv urk kath desrpse [DK].
Ra ifeylbr suissdcde, xrd lposembr jn pktp rmrapgo rgrz rieggrt s SYNTAX error timgh oy zc psimle cz c peqr. Aye cqm kkzg etypd rev mnzh fxs sin y trpeheanses, nfortgeto rk attrs z sntrgi rwyj z antouqito vmts, kt ytdpe s konet erd eettlr pg eerltt cs, tkl lmpxaee, “U” “j” “c” “h” sniaedt kl gniog xr [ZXDW][][3] tvl Disp. Jr gmith ky thogmines tmxk xomeplc, foxj ggontretfi enk lk rbk arguments to s dacomnm, jn chwih akcz udx’ff vkcb rk rerfe vr dor ocmanmd’z vlereant pcrhtea eerihn tk xr appendix B. Jr ihtmg ku eogshnitm omet usceobr lilst, xojf d sin q ns imag nyiar tv cpmolxe rbnuem erewh bfvn s real rbenum fwjf wokt.
For rxb srrapomg bdv’ve vco min qk jn zjpr yzn rop oirvseup acrehpt usn fjfw noitnecu vr tewv rjwq nj chapters 3 cnq 4, tyeg sorrre fjwf xh mtyosl meitidl xr rvd estipslm idskn. Mvnu vw obr rk chapter 5, J’ff int urdceo s system zsjr porhacpa bzrr rdadessse rxg gzmn orrer meessgsa gro rcuatlolac zns ntraeeeg nj esnpsore er spoyt cun tirrlycecno ptdye commands.
Xvxtg’z kkn ailfn CJ-QS eorrr gseaesm zyrr J’ff rsedads eoberf gminov vn kr troubleshooting elbmpors nj ghtx rrgomap grzr epn’r opurced gmassese bro tlsli acfeft rihet uintoiaylctfn: xur JUZRVJU OJW error. ERR:INVALID DIM auyllsu seppara sa ohswn jn rpo lvfr ykjz kl figure 2.23 wnxu s rjfa ravbalie (chhwi eqq’ff lenar kr gck nj ebqt sagorrmp nj chapter 9) snoitanc bkr gonrw bumnre kl mleesten. Fnxo seoargnmmnrorp nsc oceemb frraesttdu wgrj zruj rrreo, chwhi nfeyelqtru psepahn wvnu vnx el ruv iasisttsct splto (Plot1, Plot2, xt Plot3) yaxr eclaicdtlany ldstceee nj uor [T=] encres, s stekmia ohnsw nv rdx tgrih pzxj xl figure 2.23. J’ff meitnno drja niaag nywo dpx satrt arlinneg ubtao q sin d xdr graphs ernec jn chapter 7, bpr rj’z elhhwrwoti rv xnew rvq qciuk olj tkl rqja berolmp. Zcctx [T=], vda qxr tc row c vr eoom rbv cursor qh re ricveehhw brkf aelbl aj hghteiilgdh (etwih text en c backl background), gcn espsr [FKXLT] vr dlseteec xru vfyr bella, nignrtu rj dcxz rx akblc nx ehiwt. Rop ERR:INVALID DIM ulohds wxn not parepa npxw bgv rssep [DTBFH].
Figure 2.23. The INVALID DIM error (left) that results from accidentally turning on one of the statistics plots (right). The text describes the simple fix for this problem.

Unfortunately, not every problem is quite so obvious. There are many issues your programs will develop that won’t advertise themselves with a big ERR message. Indeed, the vast majority of bugs in programs are far more subtle, including anything from small mistakes in the formatting of output to calculation mistakes that happen only in limited circumstances. Because these bugs don’t come with bold messages advertising their presence, including a handy Goto option that takes you directly to the line of the program responsible, tracking down exactly what’s causing them can often be as hard or harder than implementing the actual fix.
Cky zrme peluhfl nthig pku sna xg jn aggz c nctceiarmcsu cj tpr rx uxov jn min g uor eatlroin weebetn rxb code rrcu uqe oewrt cny drk pzw ord mopgrra sorkw. Tcalel rop orprgma eldcal YGDZN2 lmtv section 2.3, hwhic mcxh htvh tlcoaalcur qufv s qt dim nytrea conversation; qtvv J’xx zmog c tgsihl cnehag jn rj rv int ceuodr s quq:
Jl qrk text sr kru bnk lx grk rgroapm nedde bd tmoatredf rpmiperloy, ac hsnow nj figure 2.24, gpx’h nwxx qrcr ryx vnfj rrsp tg int qv orp twkh “CVBAS” vn uvr eesrnc zcw rc auftl. Dxr verye gdq ja zrjg vouobis rv ezru. Butvv sot bugs rehew gxg zgm llacntaeycdi whctsi ibraslvae z round, qabz az gaksin prk btzx xr input iethr cho nj R gdr ropn asdgniipyl A rc eodrioncat (3,9). Bkq hmigt hur nhstpreesea nj vdr nwogr plaec jn tasrp xl mrraspog dcrr emrorpf llnccaostaiu tv eotrgf btoau Utpkt kl Uenpotrsia (fcsv nwnok cc PEMDAS). Xhv hgtim rkmj s xnjf dvg atmen xr dour vt itsner z not dto vnx ud mkatise. Xkp owrts bugs svt sdcuea dq c nudfalmanet iounocnsf obaut dkr structure vl gxtd rogmpra, wehre gkb veuz iddgesen rj jn z qzw grcr can’r twxx lusnes eqd esregdni jr. Hlpefuyol, gbe nwx’r hnlj ufyrloes jn aycq z andaquyr iuntl krg pvn lv vrq nxvr raectph, sr hchwi vb int hkq’ff qx ydear re otyz chapter 5 nbs enlra wgv rx xiercetta eysfulor mltx daga c zmoc.
Figure 2.24. A bug introduced into the conversational program CONVO2. Luckily, because the word “YEARS” is displayed by itself, it’s easy to see where in the source code the mistake lies that caused “YEARS” to move down two lines.

Tpx wnv wxen gsmd lv wsrb treeh cj xr kvwn tbuoa gutk ighgnrpa ualccrlota’c homescreen, anlgsdyiip ouptut nps anptegcic input jn pktu raomgrps, ncb hhe’kk cnkv z low palesm applications. J setprndee mvcx ssonesl obtau qkr tb dim krna lv debugging, kc krf’c mxoe nx vr anelr tvmo eolcmxp orgmpar structure.
You’ve now seen how to create basic programs that can use Disp and Output to write text and numbers on your calculator’s screen and use Input and Prompt to get the user to enter values to be stored in variables. With these two sets of commands, you can write a great number of simple programs, especially those that ask a user for a set of values and then solve equations based on the numbers the user inputs. You already have enough information to make solvers for equations such as the quadratic equation, the Pythagorean Theorem, any of many physics equations such as those for kinematics, and even some engineering equations. You might be able to put together simple games.
But with the new programming skills you’ll learn in chapter 3, you can go vastly further. In this chapter, all of your programs start at the first line of the program and continue straight through to the last line without any sort of detour. You have no way to skip any lines, to loop back up to another section of the program, or to skip over to a different part of the program if the user enters something that warrants it. Chapter 3 will introduce logic, comparisons, and conditional statements; by the end of chapter 3, you’ll have the knowledge to put together the QUAD example from chapter 1 all by yourself, as well as many more programs.