contact - please use subject="pc99 page" to avoid spam trap!
This page contains articles on the TI99/4a. There is a brief linked index to help you find something useful.
Web article two- published March 1999
Tips on programming menu choices; Using the various TI99/4A graphics programming packages with examples; how to use Basic PRINT USING; Jim Peterson's Tips No 65
TIPS was a commercial clip art program for the TI99/4A.
The TIPS program allows you to input the name of a graphic - but it goes a little farther than that. You do not have to key in the full name of the graphic, just enough to identify it. If there is more than one possible match, the program selects the first possible.
For example, if the graphics on file are ANT, APE, APPLE, when you select A you will have an ANT, if you type AP you will have an APE and for APP you get an APPLE.
We can copy this into our Basic programs when a typed selection is required, like this:
1 ! AS TIPS CHOICE 2 ! 3 ! INPUT AS LITTLE AS IS 4 ! REQUIRED TO IDENTIFY 5 ! CHOICE 6 ! 7 ! FIRST MATCH IS 8 ! SELECTED IF MORE THAN 9 ! ONE CHOICE 10 ! 92 ! 93 ! DATA IS SORTED 94 ! 100 DIM A$(25) 110 DATA BACK,BAG,BOA,BODY,BOND,BONE,CAB,CABIN,CABINET,CAKE,CAR,CARD, CARE,CAROL,CARP,CART,CASE,CASK,CAT,,, 120 FOR T=1 TO 19 :: READ A$(T):: NEXT T 130 REM 140 PRINT "SELECT FROM": 150 FOR T=1 TO 19 :: PRINT A$(T);" ";:: NEXT T 160 PRINT "":"":"":"" 170 REM 180 INPUT B$ 190 LA=LEN(B$) 200 FOR T=1 TO 19 210 IF B$=SEG$(A$(T),1,LA)THEN 240 220 NEXT T 230 PRINT "UNABLE TO MATCH":"":"" :: GOTO 140 240 PRINT "MATCHED ON ";A$(T):"":"":"":"" 250 GOTO 130 260 END
100 ! AS PC CHOICE 110 ! 120 ! INPUT AS LITTLE AS IS 130 ! REQUIRED TO IDENTIFY 140 ! CHOICE 150 ! 160 ! FIRST MATCH IS 170 ! DISPLAYED. TYPE MORE 180 ! IF REQUIRED OR USE 190 ! ARROW KEYS E&S (WITH 200 ! FCTN KEY! ) 210 ! 220 ! 230 ! DATA IS SORTED 240 ! 250 DIM A$(25) 260 ! 270 DATA BACK,BAG,BOA,BODY,BOND,BONE,CAB,CABIN,CABINET,CAKE,CAR,CARD, CARE,CAROL,CARP,CART,CASE,CASK,CAT,FORD,FORK,FORT,,, 280 FOR T=1 TO 22 :: READ A$(T):: NEXT T 290 REM 300 PRINT "SELECT FROM": 310 FOR T=1 TO 22 :: PRINT A$(T);" ";:: NEXT T 320 PRINT "":"":"":"" 330 PRINT "after first letter typed, use fctn e and fctn x to move up and down list or carry on typing":"":"": 340 ROW=24 :: COL=3 350 CALL HCHAR(ROW,COL,30):: CALL KEY(5,X,Y):: IF Y>0 THEN 370 ELSE CALL HCHAR(ROW,COL,32):: GOTO 350 360 ! 370 CALL HCHAR(ROW,COL,X):: COL=COL+1 :: B$=B$&CHR$(X):: LB=LEN(B$) 380 ! 390 FOR T=1 TO 22 400 IF B$=SEG$(A$(T),1,LB)THEN DISPLAY AT(24,1):A$(T):: GOTO 460 410 ! 420 IF B$<A$(T)THEN T=T-1 :: CALL SOUND(100,140,4):: DISPLAY AT(24,1 ):A$(T):: B$=SEG$(B$,1,1):: LB=LEN(B$):: GOTO 460 430 ! 440 NEXT T :: CALL SOUND(100,200,4):: T=22 :: DISPLAY AT(24,1):A$(T) 450 ! 460 ! FIRST LETTER CHOSEN 470 ! NOW IS IT WHAT WE WANT? 480 CALL HCHAR(23,3,32,28) 490 CALL HCHAR(23,3,95,LB) 500 ! 510 CALL KEY(5,X,Y):: IF Y<1 THEN 510 520 IF X=13 THEN 640 ! GOT IT 530 IF X=11 AND T>1 THEN T=T-1 :: DISPLAY AT(24,1):A$(T):: B$=SE G$(A$(T),1,LB):: GOTO 460 540 IF X=11 AND T<2 THEN CALL SOUND(200,200,4):: GOTO 460 550 IF X=10 AND T<22 THEN T=T+1 :: DISPLAY AT(24,1):A$(T):: B$=SE G$(A$(T),1,LB):: GOTO 460 560 IF X=10 AND T=22 THEN CALL SOUND(200,200,4):: GOTO 460 570 IF X=8 AND LB>1 THEN B$=SEG$(B$,1,LB-1):: LB=LEN(B$):: GOTO 390 580 IF X=9 AND LB<LEN(A$(T))THEN B$=SEG$(A$(T),1,LB+1):: :: LB=L EN(B$):: GOTO 390 590 ! 600 IF X<32 THEN 390 610 ! 620 CALL SOUND(100,800,13) 630 B$=B$&CHR$(X):: DISPLAY AT(24,1):B$ :: LB=LEN(B$):: GOTO 390 640 CALL CLEAR :: PRINT "CHOICE WAS":"":A$(T) 650 RUN
TI Logo was designed for the TI99/4, and in the absence of pixel graphics, utilised a routine which continually redefined characters (or tiles) as you drew on the screen. Sooner or later you ran out of characters, and in the colourful terms of TI Logo, you ran out of ink!
Back in 1982, we were blessed with a routine in TI Basic which allowed high resolution graphics plotting, continually redefining characters, thanks to Peter Brooks, a felow founder member of the first UK user group. This was painfully slow, and as TI Basic does not have CALL CHARPAT had to make use of a large string array, and also boolean algebra had to be done the hard way.
Then along came Extended Basic, which I think most people now have? And Gary
Harding rewrote Peter's routine making use of CHARPAT and OR. The program below
is an example of its use. The maths is placed in a subroutine, so the only
variable you need to avoid in your inserted routines is S, which keeps track of
which character we are redefining.
100 ! hi res plotting - ti ex bas only 110 ! after brooks, harding etc. 120 ! initialise: 130 S=31 :: FOR C=0 TO 14 :: CALL COLOR(C,16,2) :: NEXT C 140 CALL HCHAR(1,1,S,768) :: CALL SCREEN(2) 150 ! 160 ! 170 ! 180 ! YOUR PROGRAM HERE 190 ! 200 ! 210 FOR COL=40 TO 140 STEP 100 :: FOR ROW=20 TO 160 220 CALL PLOT(ROW,COL,S) :: NEXT ROW :: NEXT COL 230 ! 240 FOR RAD=0 TO 6.5 STEP 0.0125 250 CALL PLOT(36*SIN(RAD)+99,36*COS(RAD)+76,S) :: NEXT RAD 260 ! 270 ! 280 ! 10000 GOTO 10000 10010 STOP 10020 ! 30000 SUB PLOT(R,C,S) 30010 IF R>190 OR C>254 THEN SUBEXIT 30020 IF R<1 OR C<1 THEN SUBEXIT 30030 R=INT(R+.4) :: C=INT(C+.4) 30040 Y=INT(R/8+0.875) :: X=INT(C/8+0.875) 30050 H$="0123456789ABCDEF" 30060 B=C-X*X+8 :: P=2*R-16*Y+16+(B<5) 30070 IF B>4 THEN B=B-4 30080 CALL GCHAR(Y,X,H) 30090 IF H>31 THEN 30120 ELSE IF S=143 THEN SUBEXIT 30100 S=S+1 :: D$=RPT$("0000",4) :: CALL CHAR(S,D$) 30110 CALL HCHAR(Y,X,S) :: H=S :: GOTO 30130 30120 CALL CHARPAT(H,D$) 30130 N=(POS(H$,SEG$(D$,P,1),1)-1)OR(S^(4-B)) 30140 D$=SEG$(D$,1,P-1)&SEG$(H$,N+1,1)&SEG$(D$,P+1,16-P) 30150 CALL CHAR(H,D$) :: SUBEND 31000 ! ORIGINAL ROUTINE TIDINGS OCT 1982
The program below is a routine for a chaotic graphics plot, and really does
take a very long time to finish! The end result is interesting as total order,
represented by a single line, becomes total chaos after repeated bifurcation.Super Extended Basic requires that you have the 32k ram attached, and you enter
the graphics mode by typing the command sequence:
CALL FILES(2) NEW CALL INIT CALL DRAWNPLOT
10 ! high resolution graphics using 20 ! triton super extended basic and 32k ram 30 ! after brooks, harding etc 40 ! 100 CALL LINK("GCLEAR") 110 ! ORBITDGM PROGRAM 120 ! OR insert your program here: 130 FOR C=-2 TO 0.25 STEP .00625 140 X=0 :: M=160*(C+2) :: FOR I=0 TO 200 150 X=X*X+C :: IF I<50 THEN 170 160 N=(180/4)*(2-X) :: CALL PSET(M,N) 170 NEXT I 180 CALL LINK("MOVE",80,160) 190 CALL LINK("LABEL","Press E to Exit") 200 CALL LINK("SHOW") 210 STOP 10000 SUB PSET(X,Y) 10010 CALL LINK("MOVE",X,Y) :: CALL LINK("DRAW",X,Y) 10020 SUBEND - - - - -
100 CALL GRAPHICS(3) 180 REM 190 CALL WRITE(0,160,80,"* done *") 200 REM 10010 CALL POINT(1,X,Y)
100 CALL LINK("CLEAR") 180 REM 190 CALL LINK("PRINT",160,80,"* DONE *") 200 REM 10010 CALL LINK("PIXEL",X,Y)
100 CALL LOAD(-31890,56,0) :: CALL LOAD(-31964,56,0) 105 CALL LINK("CLEAR") :: CALL LINK("SCR2") 180 REM 190 REM 200 REM 10010 CALL LINK("POINT",16,X,Y)
100 REM CIRCLES 110 REM JE CONNETT/PWH MOON/S SHAW 1990 120 SIDE=20 130 REM 140 CALL LINK("CLEAR") 150 FOR I=1 TO 150 :: FOR J=1 TO 150 160 X=I*SIDE/150 :: Y=J*SIDE/150 :: C=INT(X*X+Y*Y):: D=C/2 :: IF D-INT(D)>.1 THEN 180 170 CALL LINK("PIXEL",I+20,J+20) 180 NEXT J :: NEXT I 190 PIC=PIC+1 :: A$="DSK2."&STR$(PIC) 200 CALL LINK("SAVEP",A$) 210 SIDE=SIDE*1.2 :: GOTO 140 220 ENDReturn to top of page
100 CALL LINK("CLEAR") 110 H=240 :: V=180 120 REM 130 REM 140 X=6.10 150 Y=6.00 160 REM 170 REM 180 FOR L=1 TO 3299 190 NX=1-Y+ABS(X):: NY=X :: X=NX :: Y=NY 200 A=100+X*7-Y*7 210 B=70+X*7+Y*7 220 CALL LINK("PIXEL",A,B) 230 NEXT L 240 CALL LINK("PRINT",180,180,"END") 250 X=8.30 :: Y=8.02 260 FLAG=FLAG+1 :: IF FLAG>2 THEN 260 ELSE IF FLAG>1 THEN X=8.56 :: Y=3.76 :: GOTO 160 ELSE GOTO 160 ----------------------------------------- 100 CALL LINK("CLEAR") 110 H=240 :: V=180 120 REM 130 REM 140 X=-.100000000001 150 Y=0 160 REM 170 REM 180 FOR L=1 TO 5299 190 NX=1-Y+ABS(X):: NY=X :: X=NX :: Y=NY 200 A=100+X*14-Y*14 210 B=60+X*14+Y*14 220 CALL LINK("PIXEL",A,B) 230 NEXT L 240 CALL LINK("PRINT",180,180,"END") 260 GOTO 260 =========================================== ==========================================
100 PRINT -56.7;109.2850 110 PRINT USING "####.# ###.####":-56.7,109.285 RUN this program and it looks like this: -56.7 109.285 -56.7 109.2850
Pound signs take the place of a digit or sign. So in line 110 above, I printed -56.7 with the field "####.#". -56.7 has only three characters to the left of the decimal point, so the initial character is left blank; the second one is where the minus sign went. Numbers are always aligned with the decimal point. If there isn't one, it's assumed to be at the end.
If there's a minus sign in the field, it always goes at the beginning. It indicates that you want the minus sign to appear immediately to the left of the number if it is negative. However, this is the same thing another pound sign would do, so you never really need to use a minus sign (except for a more advanced purpose to be discussed later.) In other words, "-##.##" does the same thing as "###.##".
The decimal point indicates where you want it to be. The number of pound
signs you put to the left of it dictates how many digits you want to the left;
the number you put on the right indicates how many decimal places you want.
The decimal is always printed even if there are no pound signs after it.
If there are fewer digits in the value to the left of the decimal point than there are in the field, spaces are used to fill it out. If there are too many, the computer will refuse to print your value and fill the field with asterisks (*). This means your value is too high and/or there isn't enough places in your field. This includes the minus sign, if any.
If there are fewer digits in the value to the right of the decimal point than there are in the field, zeroes are used to fill in the remainder. If there are too many, the computer will estimate the number to the number of places given. So .## can be used to estimate to the nearest 100th, .# to the nearest tenth, and if there are no decimal places, it will estimate to the nearest unit.
Below is a table of how various values will be printed with various
The left side represents the value; across the top are the fields.
# ## ### #.# ##.## ###.### 2 2 2 2 2.0 2.00 2.000 -13 * ** -13 *** ***** -13.000 9.671 * 10 10 9.7 9.67 9.671 125.678 * ** 126 *** ***** 125.678 -.385 * -0 -0 -.4 -.39 -.385 -3.05 * -3 -3 *** -3.05 -3.050
Why anyone would use DISPLAY USING without any values is beyond me.
Anyway, if it reaches the end of the string, and there's more values to be
printed, it goes to the next line and starts over at the beginning of the
string. So it's ok if the number of fields doesn't match the number of
Going back to syntax, if you want to use the format "I HAVE $###.##", you have three ways of doing it:
120 IMAGE I HAVE $###.## 130 PRINT USING 120:M 140 A$="I HAVE $###.##" 150 PRINT USING A$:M 160 PRINT USING "I HAVE $###.##":M
The IMAGE statement must be on a line by itself. The computer ignores it
when it comes to it in a program the same as it does the DATA statement, so you
can put it anywhere.
Circumflexes are used to denote scientific notation which leads us to the next section....
You may want the number to come out in scientific notation (E format) even if the number normally wouldn't. To do this you put four or five circumflexes at the end of the field. Four means you want two digits in the exponent; five means you want three. If you put less than four, they will be treated as text; if you put more than five, the first five will be used, and the rest will be treated as text.
There's a little something different about E format. It always reserves
the first character for the sign, so you'll need at least two #'s in the
mantissa (or precede the field with a sign). Using the same numbers as above,
the table can be amended thusly:
##^^^^ ####^^^^ #.####^^^^^ 2 2E+00 200E-02 .2000E+001 -13 -1E+01 -130E-01 -.1300E+002 9.671 1E+01 967E-02 .9671E+001 125.678 1E+02 126E+00 .1257E+003 -.385 -4E-01 -385E-03 -.3850E+000 -3.05 -3E+00 -305E-02 -.3050E+001
Time to switch to another concept. USING can also be used to format text
values. No bells or whistles here, though. Any field that can be used to
format a number can also be used to format text. Text is just left-justified,
and all characters within a field are treated the same. I can give you a
table, but I assure you, it's quite boring:
### ###.### -###^^^^ BOB BOB BOB BOB JOHN *** JOHN JOHN 25% OFF! *** ******* 25% OFF!
170 IMAGE ##### HAS $###.##. 180 PRINT USING 170:"MARY",123.4 This will print: MARY HAS $123.40.
Another problem you may have is suppose you want to concatenate two fields, say ## with ###. If you put them together, you get #####, and the computer will see that as one field. Well, you could try using "##-##". The computer will then recognize that as two fields, ## and -##. But if your second field can have three digits, this won't work. If this is the case, you will need to split up the format string into two PRINT USING statements.
Perhaps like this:
190 PRINT USING "##":A; 200 PRINT USING "###":B
+# +### +###.##^^^^ 2 +2 +2 +200.00E-02 -13 ** -13 -130.00E-01 9.671 ** +10 +967.10E-02 125.678 ** +126 +125.68E+00 -.385 -0 -0 -385.00E-03 -3.05 -3 -3 -305.00E-02
200 IMAGE ###x^2+##x+## 210 PRINT USING 200:2,7,10 220 PRINT USING 200:-15,-11,1 230 PRINT USING 200:+9,33,-14 This will print: 2x^2 +7x+10 -15x^2-11x +1 9x^2+33x-14
240 DEF MF$(X)=" $"&RPT$("#",LEN(STR$(INT(X))))&".##"
There's another manual correction that must be made (although it may have
been made already in some addendum I don't know about). The syntax for PRINT
USING with files is wrong. I won't reprint it here because I don't like
glorifying the incorrect. The correct syntax is as follows:
PRINT [#file-number,[REC record-number,]USING format:print-list That translates specifically as something like: 250 PRINT #1,USING 200:A,B,C 260 PRINT #2,REC 15,USING 200:A*4,B*4,C*4
PRINT USING is very good for printing to a printer because the printer has
so many more columns to print in. So there is a good chance that you may have
a program in which a particular PRINT USING is only being used to print to the
printer and never to the screen.
If this is the case, there is another solution to the concatenated field problem mentioned in the last section. You can print some unprintable character between the two fields. The computer will then recognize them as two fields but they will be together on the printout! Something like this would be typical:
270 A$="##"&CHR$(0)&"###" 280 PRINT #1,USING A$:A,B
ALL KEY(0,K,S):: IF S<>0 THE No. 65 N 30004 30003 NEXT T :: GOTO 30001 Tigercub Software 30004 IF POS(V$,CHR$(K),1)=0 1N6 Nnuyngwood Ave. THEN 30001 ELSE K$=CHR$(K) ZxCdmbus, OH 43XY3 30005 SUBEND ********* And for a demonstration of the use of that subprogram, My three Nuts & Bolts here is a little game that disks, each containing 100 no one will ever play to the or more subprograms, have end - been reduced to $5.00. I am out of printed documentation 100 DISPLAY AT(3,6)ERASE ALL so it will be supplied on :"THE ULTIMATE TEST":"":" An on disk. swer the question with a num My TI-PD library now has ber according to whether the well over 500 disks of fair- number or color shown," ware (by author's permission 110 DISPLAY AT(8,1):"or the only) and public domain, all note sounded, was 1stor 2nd arranged by"category and as or 3rd, etc." full as possible, provided 120 DISPLAY AT(23,6):"PRESS with loaders by full program ANY KEY" :: DISPLAY AT(23,6) name rather than filename, :"press any key" :: CALL KEY Basic programs converted to (0,K,SS):: IF SS=0 THEN 120 XBasic, etc. The price is ELSE CALL CLEAR just $1.50 per disk(!), post 130 DATA 2,BLACK,3,GREEN,5,B paid if at least eight are LUE,9,RED,12,YELLOW,14,PURPL ordered. TI-PD catalog #5 E and the latest supplement is 140 FOR J=1 TO 6 :: READ C(J available for $1 which is ),C$(J):: CT$=CT$&CHR$(J):: deductible from the first W$=W$&CHR$(J+48):: NEXT J :: order. T=2 :: DL=500 :: V$="12" 150 RANDOMIZE :: T$,NN$=CT$ It is a bit of a nuisance :: FOR J=1 TO T :: X=INT(RND to have to hit Enter after *LEN(T$)+1):: X$=SEG$(T$,X,1 inputting a single character ):: T$=SEG$(T$,1,X-1)&SEG$(T such as Y or N for "yes" or $,X+1,255):: Y(J)=ASC(X$) "no". CALL KEY accepts a 160 X=INT(RND*LEN(NN$)+1):: single character without X$=SEG$(NN$,X,1):: NN$=SEG$( Enter, but has no blinking NN$,1,X-1)&SEG$(NN$,X+1,255) cursor to tell you that it :: S(J)=ASC(X$):: NEXT J :: is waiting. I should have FOR J=1 TO T had this one in my Nuts & 170 Z(J)=INT(89*RND+10):: FO Bolts years ago - the CALL R K=1 TO J-1 :: IF Z(J)=Z(K) KEY WITH CURSOR subprogram! THEN 170 R is the row, C is the TAB 180 NEXT K :: NEXT J :: CALL position, V$ is the valida- CLEAR :: CALL COLOR(3,16,1, tion string, such as "YyNn", 4,16,1) and the character selected 190 FOR J=1 TO T :: CALL SCR is returned in K$. EEN(C(Y(J))):: CALL SOUND(-9 99,110*S(J),0):: DISPLAY AT( 30000 SUB CALLKEY(R,C,V$,K$) 12,12):Z(J):: FOR D=1 TO DL 30001 CALL HCHAR(R,C+2,30):: :: NEXT D :: NEXT J FOR T=1 TO 3 :: CALL KEY(0, 200 CALL CLEAR :: CALL SCREE K,S):: IF S<>0 THEN 30004 N(16):: CALL COLOR(3,2,1,4,2 30002 NEXT T :: CALL HCHAR(R ,1):: X=INT(3*RND+1):: W=INT ,C+2,20):: FOR T=1 TO 3 :: C (T*RND+1):: ON X GOTO 210,23 ====================================== END OF TIPS PAGE ONE ======================================= 0,210 FCTN Z instead of & to under 210 IF X=1 THEN Q$=C$(Y(W))E line, FCTN C instead of @ to LSE IF X=3 THEN Q$=STR$(Z(W) double-strike, and FCTN A ) instead of * to call a value 220 DISPLAY AT(12,1):"WHICH added file. I don't know why WAS ";Q$ :: GOTO 240 Texas Instruments didn't do 230 CALL SOUND(1,30000,30):: that in the first place, and DISPLAY AT(12,1):"WHICH WAS I wonder why the McGoverns ?" :: FOR D=1 TO 200 :: NEXT didn't make that fix. D :: CALL SOUND(500,110*S(W Now, can anyone tell me ),0) how to replace the ^, which 240 CALL CALLKEY(12,20,V$,K$ tends to disappear, and the ):: Q=ASC(K$)-48 period, which will make the 250 IF Q=W THEN DISPLAY AT(1 whole line disappear if it 5,12):"RIGHT!" ELSE DISPLAY happens to be at the begin- AT(15,12):"WRONG!" ning of the line? 260 IF Q=W THEN DL=DL-50 ELS E DL=DL+50 If you are one of the few 270 IF DL<100 THEN DL=500 :: who are still interested in T=T+1 :: V$=SEG$(W$,1,T) recreational computing - the 280 GOUO 150 use of the computer to solve 290 SUB CALLKEY(R,C,V$,K$) puzzles and math problems 300 CALL HCHAR(R,C+2,30):: F just for the fun of it - you OR T=1 TO 3 :: CALL KEY(0,K, might be interested in Rec- S):: IF S<>0 THEN 330 reational and Educational 310 NEXT T :: CALL HCHAR(R,C Computing, published 8 times +2,20):: FOR T=1 TO 3 :: CAL a year at xyz tyulet Terrace L KEY(0,K,S):: IF S<>0 THEN (REC is no more alas) . The 330 annual subscription is $36. 320 NEXT T :: GOTO 300 Program listings are in dia- 330 IF POS(V$,CHR$(K),1)=0 T lects of Basic other than TI HEN 300 ELSE K$=CHR$(K) but usually not hard to con- 340 SUBEND vert. That is where I found this I have warned repeatedly ridiculously short, simple over the years, in these and fast card shuffling rou- Tips and in Micropendium and tine. elsewhere, that printing program listings through the 100 DIM C(52) Funlweb Formatter usually 110 FOR X=1 TO 52 :: C(X)=X results in garbled listings :: NEXT X that cannot be keyed in cor- 120 FOR X=52 TO 1 STEP -1 :: rectly - but I still see the I=INT(RND*X+1) garbled listings published. 130 T=C(I):: C(I)=C(X):: C(X Here is a fix to the Funlweb )=T :: NEXT X FO file that will partially solve the problem - In the same place, I read Boot DSKU. Select 1. File a routine to extract a root Utilities. Select 5. Find to 16-digit accuracy instead String. Enter filename FO of the 8 digits available and the drive number. Enter on a PC from the basic for- H for hex. Enter the string mula ROOT=NUMBER^(1/POWER). 2A23214026 . Enter replace We don't need it - our obso- string 7C2321605C . When the lete 16k 16-bit computer can string is found, enter R for give us 14-digit accuracy replace, then CTRL W, hit from the basic formula! Enter twice to accept the defaults. Thereafter, use The same publication gave ================================================= END OF TIPS PAGE TWO ====================================================
me the idea for this little can peek behind the curtain, game - opens one of those you did not pick, and shows a goat. 100 DISPLAY AT(3,6)ERASE ALL Then he offers to let you :"THE GAME OF N":"":"You and change your choice. Should the computer will take tu you switch, stand pat, or rns adding to a num- ber to does it make no difference? reach a goal." You now have a 50-50 bet, 110 DISPLAY AT(8,1):"If you so it makes no difference, reach the goal, you win. Yo right? But some very distin- u get to go first andyou sho guished mathematicians were uld be able to win almost saying you should switch, so every time." I wrote this computer simu- 120 RANDOMIZE :: N=INT(RND*1 lation to prove them wrong. 5)+15 :: R=INT(4*RND+3):: S= Key it in, run it, and be R+1 :: D=N-INT(N/S)*S :: T=0 surprised. Do figures lie? 130 DISPLAY AT(13,1):"The go Do computers lie? Is there al is";N:"":"Maximum input i something wrong with my sim- s";R :: DISPLAY AT(19,1):RPT ulation? $(" ",96) 140 DISPLAY AT(17,1):"Your n 100 CALL CLEAR umber?" :: ACCEPT AT(17,14)S 110 DATA CAR BEHIND,A PICKS, IZE(1)VALIDATE(DIGIT):A :: I HOST SHOWS,A WINS,B WINS,C W F A<1 OR A>R THEN DISPLAY AT INS (15,1):"" :: GOTO 130 120 FOR J=1 TO 3 :: READ M$ 150 T=T+A :: DISPLAY AT(21,1 :: DISPLAY AT(J,1):M$ :: NEX ):"Total is";T :: IF T=N THE T J :: FOR J=12 TO 14 :: REA N DISPLAY AT(23,1):"YOU WIN! D M$ :: DISPLAY AT(J,1):M$ : " :: GOSUB 190 :: GOTO 120 : NEXT J 160 IF N-T<S THEN P=N-T :: T 130 FOR J=1 TO 1000 :: RANDO =T+P :: DISPLAY AT(19,1):"Co MIZE :: X=INT(3*RND+1):: DIS mputer adds";P :: DISPLAY AT PLAY AT(1,13):X !RANDOMLY PL (21,1):"Total is";T :: DISPL ACE CAR AY AT(23,1):"COMPUTER WINS!" 140 A=INT(3*RND+1):: DISPLAY :: GOSUB 190 :: GOTO 120 AT(2,13):A !PLAYER CHOOSES 170 IF T=0 THEN P=D ELSE IF 150 E=INT(3*RND+1):: IF D=X (N-T)/S=INT((N-T)/S)THEN P=I OR D=A THEN 150 :: DISPLAY A NT(R*RND+1)ELSE Y=N-T :: P=Y T(3,13):D :: ! HOST PICKS CU -INT(Y/S)*S RTAIN WITH GOAT 180 T=T+P :: DISPLAY AT(19,1 160 IF A=X THEN AA=AA+1 :: D ):"Computer adds";P :: DISPL ISPLAY AT(12,7):AA ! A DOES AY AT(21,1):"Total is";T :: NOT SWITCH GOTO 140 170 B=INT(3*RND+1):: IF B=A 190 DISPLAY AT(24,8):"PRESS OR B=D THEN 170 ANY KEY" :: DISPLAY AT(24,8) 180 IF B=X THEN BB=BB+1 :: D :"press any key" :: CALL KEY ISPLAY AT(13,7):BB ! B SWITC (0,K,S):: IF S=0 THEN 190 EL HES SE T=0 :: RETURN 190 C=INT(3*RND+1):: IF C=D THEN 190 REC also printed a puzzle 200 IF C=X THEN CC=CC+1 :: D which seemed so simple that ISPLAY AT(14,6):CC ! C CHOOS I could not see why. It goes ES RANDOMLY like this - 210 NEXT J A game show host shows you three curtains. Behind one Here is an improved ver- is a new car, behind the sion of a program that was other two are goats. You in a Tips long ago, to strip choose one. The host, who out the extra blanks from a ===================================== end of tips page three ======================================== Filled and Adjusted Funlweb and change any line reading Formatter file - OPEN #1:"DSK1.FILENAME" - or whatever - to read - 100 DISPLAY AT(3,6)ERASE ALL OPEN #1:DEV$&".FILENAME" :"TIGERCUB UNFILLER":"":" To (don't forget the period be- remove extra spaces from":" fore the filename!). Now you a TI-Writer text which has": can load the program from "been Filled and Adjusted by any drive and it will open " the file on that same drive! 110 DISPLAY AT(8,1):"the For matter, prior to":"reformatt * STRING ASSIGN DEVICE NAME ing." * PLACES DEVICE NAME IN AN 120 DISPLAY AT(15,1):"Input * XBASIC STRING file? DSK" :: ACCEPT AT(15,1 * HARRISON SOFTWARE 6):IF$ :: OPEN #1:"DSK"&IF$, * 8 OCTOBER 1990 INPUT * FOR USE WITH ALSAVE AND XB 130 DISPLAY AT(17,1):"Output * TAKES ONLY 42 BYTES MEMORY file? DSK" :: ACCEPT AT(17, STRASG EQU >2010 17):OF$ :: OPEN #2:"DSK"&OF$ WS EQU >20BA 140 LINPUT #1:M$ :: P=1 DEF DEVICE 150 X=POS(M$,"a",P):: IF X=P DEVICE THEN P=P+1 :: GOTO 150 * USE OUR WORKSPACE 160 X=POS(M$," ",P):: IF X= LWPI WS 0 THEN PRINT #2:M$ :: GOTO 1 * GET THE CRU BASE IN R12 80 MOV @>83D0,R12 170 M$=SEG$(M$,1,X)&SEG$(M$, * GET ROM ADDRESS FOR DEVICE X+2,255):: GOTO 160 * IN R2 180 IF EOF(1)<>1 THEN 140 :: MOV @>83D2,R2 CLOSE #1 :: CLOSE #2 * ENABLE THE ROM LDCR @ONES,0 While a program is run- * ADDING 4 PUTS US AT THE ning, the computer periodi- * LENGTH BYTE cally pauses for a fraction AI R2,4 of a second to do a "garbage * FIRST PARAMETER collection", getting rid of LI R1,1 information it no longer * NOT AN ARRAY VARIABLE needs, to make room in memo- CLR R0 ry. If this pause occurs at * ASSIGN DEVICE NAME TO A a critical moment in program * STRING execution, it can cause pro- BLWP @STRASG blems. Thanks to the Sydney * CLEAR CRU, DISABLE ROM User Group in Australia, LDCR R0,0 here is a CALL LOAD which * LOAD GPL WORKSPACE will force a garbage collec- LWPI >83E0 tion just before that criti- * RETURN TO GPL INTERPRETER cal point - B @>006A CALL LOAD(-31885,144,"",-318 * WORD TO TURN ON ROM IN CRU 58,81,169,152,0) ONES DATA >0101 END Here is a neat one from Bruce Harrison. Key it in, (you can skip the lines that Getting short on memory, start with an asterisk) and so more next time. assemble it, then use ALSAVE to imbed it in any program that opens a disk file. Put Jim Peterson CALL LINK("DEVICE",DEV$) at the beginning of the program ===================================Bruce Harrison is no longer with us.