CALL subprograms

From Ninerpedia
Revision as of 20:55, 27 October 2014 by Stephen Shaw (talk | contribs) (New article with examples of user written sub programs for Extended Basic)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The TI99/4a used SUB PROGRAMS, used with the word CALL, such as CALL SOUND, CALL COLOR, CALL HCHAR - these are samples of sub programs built into TI BASIC.

The various Extended BASICS added additional CALLs and sometimes modified the TI CALLs a little. Other modules (for example Personal Record Keeping) added CALLs to TI BASIC programs when inserted.

In addition to the many supplied CALLs you can define your own CALLS in Extended BASIC.

Example User written Sub Programs

The ability to write a program in such a way that you CALL up your own sub-programs, such as:

CALL SETUP 
CALL INSTRUCT 
CALL PLAY 
CALL HIGHSCORES 

CALL's are used all the time even in TI Basic, such as CALL CLEAR, CALL HCHAR, and so on. In Extended Basic you can write your own.

For a very large selection you can do no worse than refer to Jim Petersons NUTS AND BOLTS disks, but in the meantime here is a selection of routines for you from Peter Hutchison. nks Peter.

If you have a disk system, save each of these on disk in MERGE format and then just merge them into any program you wish to use then in.

CALL PUTAT

This command uses the whole screen (32 x 24) rather than the limited 28x24 used by DISPLAY AT. Form: CALL PUTAT(row, column, string) Sample use: CALL PUTAT(5,1,"HELLO TI USERS EVERYWHERE")

Code 
27000 SUB PUTAT (R,C,T$) 
27010 IF R<1 OR C<1 OR T$="" THEN SUBEXIT
27020 R=MIN(R,24) :: P=1 
27030 IF R>=24 AND C>32 THEN PRINT :: R=24 :: C=1 
27040 IF C>32 THEN R=R+1 :: C=1
27050 CALL HCHAR(R,C,ASC(SEG$(T$,P,1))) 
27060 IF P>=LEN(T$) THEN SUBEXIT 
27070 C=C+1 :: P=P+l :: GOTO 27030 
27080 SUBEND 


CALL SAVECHAR / CALL LOADCHAR

These commands will save the definitions of the characters 96 to 127 into an array PAT$ and then use the array to restore the definitions. Examples: CALL SAVECHAR(PAT$()) and CALL LOADCHAR(PAT$())

Code: 
27220 SUB SAVECHAR(PAT$()) 
27230 FOR C=96 TO 124 STEP 4 :: EL=C/4-23 :: CALL CHARPAT(C,P$(EL)) :: NEXT C 
27240 SUBEND 
27250 SUB LOADCHAR(PAT$()) 
27260 FOR C=96 TO 124 STEP 4 :: EL=C/4-23 :: CALL CHAR(C,P$(EL)) :: NEXT C 
27270 SUBEND 


CALL HSCROLL

This command can he used to scroll text along a line on the screen Form: CALL HSCROLL(row, column, length_disp1ayed, text$) Sample: CALL HSCROLL(5,9,10,TEXT$) Note: Text is limited by the system and the code below to a length of 240 chars!

Code 
27300 SUB HSCROLL(R,C,L,H$) 
27310 M$="-------"&H$&"-------" 
27320 IF LEN(M$)<L THEN 27310 
27350 FOR A=1 TO LEN(M$)-L+1 
27340 DISPLAY AT(R,C)SIZE(L):SEG$(M$,A,L) 
27350 FOR B=1 TO 15 :: NEXT B :: NEXT A 
27360 SUBEND 


CALL GET

This command will return the CHARACTER of the key pressed, or a nul if no Key is pressed. Form: CALL SET (KEY$)

Code 
27380 SUB GET (K$) 
27390 CALL KEY(O,K,S) 
27400 IF S=0 THEN K$="" ELSE K$=CHR$(K) 
27410 SUBEND