Classic Computer Magazine Archive COMPUTE! ISSUE 58 / MARCH 1985 / PAGE 120

Automatic Atari DATAIine
Generation

Robert E. Miller

Location 842 in Atari computers allows the computer to perform a clever trick called the dynamic keyboard. What this means is "that a line can be entered into the computer automatically from the screen. "Automatic Atari DATAIine Generator" uses this technique to make data line entry less tedious.


One of the more interesting features of the Atari is the dynamic keyboard capabilities of POKE 842,13, discussed in Bruce Frumker's "Restoring Data and Updating Data on the Atari" (COMPUTE!, August 1981). The small tutorial program discussed here illustrates a few of the possibilities.
    The sample program allows storage of information in DATA lines when keyed in at "prompt" pauses. It provides a search function for printing data on the screen (or on other printers), based on the first string in the data set. Stored data can be edited-that is, corrected or changed using routines based on POKE 842,13.

Useful For Nonprogrammers
All DATA lines are written and deleted under program control, avoiding the problems inherent in typing in "line number, data, and commas." This approach is particularly useful when programs are to be run by nonprogrammers. The program incorporates "block deletion" of lines as discussed in the August 1981 article.
    As explained by Frumker, the activity of writing or deleting DATA lines can be hidden from the user by setting the luminances of the background and characters on the screen to the same level if the display is objectionable. It was not suppressed here since it is instructive to observe the action and allows the checking of each entry.
    String data is referred to as "first, second, and third word"; but "name", "address", etc., could be handled in the same manner. Additional explanation is included in the program description and in remarks in the listing.

The Data Storage Sample Program

Lines

5-64 Title display call, initialization, and menu development.
66-70 Branch to appropriate subroutine.
80   
Repeat menus after return from subroutine.
500-510 Closing title call, screen clearing.
600-655 Subroutine to list all entries directly.
1000-1070 Search subroutine, simply searches data using first string as the key.
2000-2100 Preparation of data for line entry subroutine. Subroutine 25010 writes prompted entries into a DATA line which has a line number in cremented from previously written DATA line. Note that no further keyboard DATA inputs are required to write DATA lines because POKE 842,13 allows reading from screen. The line number is repeated as the first data item to allow incrementing after locating previous bottom DATA line.(Thanks to Frumker.)
3000-3300 Preparation of data for entry correction subroutine. This subroutine retrieves an entry ("first, second, and third word" in this example), requests revised entry, repeats new entry to insure that correction is as desired, and then branches to 25010 to automatically write a new DATA line.
4000-4999 DATA storage lines written by 25010 subroutine-could be a larger block if desired. A few entries are included as samples.
6000-6290 Preparation for entry deletion subroutine. Branches to 32000 to delete DATA line chosen and hence entry. Sets up line number for use in 32000.
7000-7060  Program title display subroutine.
8000-8040 Closure display subroutine.
25010-25060 Enter strings and line number into a DATA line which is stored by dynamic keyboard action.
32000-32150 Block deletion subroutine. Allows automatic line deletion based on beginning and ending line numbers as in Applesoft or in a manner similar to Atari LIST line no. x, line no. y. POKE 842,13 is again the key since it, in effect, "presses the RETURN key" when a line number is onscreen. The routine is used in this program to delete a single line specified in subroutine 6000, that is, STLIN equals ENLINE. The deletion routine can be used directly with GOTO 32000 after direct entry of STLIN and ENLINE.


Automatic Atari DATAline Generator

Refer to "COMPUTE!'s Guide For Typing In Programs" article before typing this program in.

NF 5 GOSUB 7000:REM TO DISPLAY TITLE
CP 8 DIM D$(15),E$(15),F$(15),A$(15)
     ,B$(15),C$(15),Y$.(5),T$(15)
OC 10 GRAPHICS 0
HF 20 GRAPHICS 0:? "SELECT OPERATION
      BY NUMBER"
JE 30 ? :? :?
JJ 32 ? "(1) {RVS}SEARCH{OFF} FOR ENTRY"
KG 34 ?
GG 40 ? "(2) {RVS}NEW{OFF} ENTRY"
KH 44 ?
PL 50 ? "(3) {RVS}CORRECT{OFF} EXISTING ENTRY"
KG 52 ?
MC 56 ? "(4) {RVS}LIST ALL{OFF} ENTRIES"
KL 57 ?
LL 58 ? "(5) {RVS}DELETE{OFF} ENTRY"
KF 60 ?
LF 62 ? "(6) {RVS}QUIT{OFF}"
CC 64 ? :?
LM 66 INPUT SELECT
FH 70 ON SELECT GOSUB 1000,2000,3000
      ,600,60005500
AD 80 GOTO 20
NN 500 GOSUB 8000
BH 510 GRAPHICS 0
GO 520 END
EN 600 REM TO LIST ALL ENTRIES
LM 602 RESTORE
GN 605 TRAP 650
AD 610 READ LN,A$,B$,C$
GB 620 ? A$,B$,C$
GN 625 GOTO 610
OB 650 ? "__________________________
       ___"
EP 651 ? :? "TO CONTINUE PRESS {RVS}RETUR
       N{OFF} ":INPUT T$
IA 655 RETURN
OE 1000 REM SEARCH FOR ENTRY SUBROUT
        INE
DK 1002 FLG1=0
EG 1004 GRAPHICS 0
GK 1005 ? "INPUT FIRST WORD OF ENTRY
        TO BE FOUND"
IA 1007 ? :?
ON 1008 RESTORE
NC 1009 INPUT T$
HK 1010 ? : ?
MG 1011 TRAP 1065
CP 1020 READ LN,A$,B$,C$
GC 1030 IF A$=T$ THEN 1050
MB 1040 GOTO 1020
IC 1050 ? "FIRST WORD IS---";A$:FLGI
        =1
AH 1052 ? "SECOND WORD IS---":B$
EC 1054 ? "THIRD WORD IS---";C$:?
MD 1060 GOTO 1020
NI 1065 IF FLG1=0 THEN ? "{RVS}NO{OFF} ENTRY F
        OUND":FOR WAIT=0 TO 500:NEXT
         WAIT
EI 1066 ? :? "SEARCH FOR ANOTHER ENT
        RY?"
BL 1068 INPUT T$:IF T$="Y" THEN GOTO
         1000
KI 1070 RETURN
NC 2000 REM TO PUT ENTRY IN A COMPUT
        ER GENERATED LINE
EF 2002 GRAPHICS 0
MN 2005 ? "INPUT FIRST WORD":INPUT A
        $
AE 2007 ? "INPUT SECOND WORD":INPUT
        B$
MG 2009 ? "INPUT THIRD WORD":INPUT C
        $
ON 2015 RESTORE
GL 2020 TRAP 2050:REM CATCHES LAST E
        XISTING LINE NUMBER
CA 2030 READ LN,D$,E$,F#:REM LN=LINE
         NUMBER
ME 2040 GOTO 2030
MH 2050 LN=LN+2:IF LN?=4999 THEN STO
        P
EK 2060 GOSUB 25010:REM BRANCHES TO
        AUTOMATIC LINE WRITING SUBRO
        UTINE
CA 2070 ? :? :? "ANOTHER ENTRY?"
NH 2080 INPUT Y$
KC 2090 IF Y$="Y" THEN 2000
KD 2100 RETURN
HN 3000 REM TO CORRECT AN ENTRY
EF 3001 GRAPHICS 0
OJ 3002 RESTORE
OI 3004 ? "INPUT FIRST WORD OF CURRE
        NT ENTRY"
LN 3005 INPUT A$
AK 3010 FLG=0
ME 3015 TRAP 3100
MJ 3020 IF FLG=1 THEN GOTO 3120
DL 3021 READ LN,D$,E$,F$
ND 3030 IF D$=A$ THEN GOSUB 3200
MF 3040 GOTO 3020
EE 3100 ? "ENTRY TO BE CORRECTED NOT
         FOUND.DO YOU WANT TO TRY AG
        AIN?"
NC 3110 INPUT Y$
KC 3115 IF Y$="Y" THEN 3000
GH 3117 GOTO 20
KG 3120 RETURN
PE 3200 REM TO PRINT OLD DATA TO ASS
        URE PROPER LINE IS BEING COR
        RECTED AND TO MAKE NEW ENTRY
EH 3210 GRAPHICS 0
ED 3220 ? "#1 OLD IS---";D$
EN 3222 ? "#2 OLD IS---";E$
EL 3224 ? "#3 OLD IS---";F$
GF 3230 ? "IS THIS THE DATA TO BE CO
        RRECTED?":INPUT Y$
OC 3240 IF Y$="Y" THEN GOTO 3260
MI 3250 GOTO 3020
MN 3260 GRAPHICS 0:FLG=1
FG 3262 ? "INPUT CORRECTED FIRST WOR
        D":INPUT A$:IF A$="" THEN A$
        =D$
IN 3270 ? "INPUT CORRECTED SECOND WO
        RD":INPUT B$:IF B$="" THEN B
        $=E$
FB 3280 ? "INPUT CORRECTED THIRD WOR
        D":INPUT C$:IF C$="" THEN C$
        =F$
KF 3282 ? "IS THIS THE CORRECTED ENT
        RY YOU DESIRE?":?
DP 3284 ? "FIRST WORD---";A$
HG 3286 ? "SECOND WORD---";B$
DI 3288 ? "THIRD WORD---";C$
GL 3289 INPUT T$:IF T$<>"Y" THEN GOT
        O 3262
EG 3290 GOSUB 25010
HA 3292 ? :? "DO YOU WISH TO CORRECT
        ANOTHER ENTRY?":INPUT T$
KF 3294 IF T$="Y" THEN 3000
KG 3300 RETURN
IM 4000 DATA 4000,EPSILON,RHO,GAMMA
JA 4002 DATA 4002,MILLER,3907 MAIN,F
        ORT WORTH TX.
BL 4004 DATA 4004,COMPUTER,COMPUTE!
        MAG.,SEPT. 1981
KH 4006 DATA 4006,JONES,938-3456,A/C
        817
HE 4008 DATA 4008,SMITH W.R.,406 OAK
         ST.,DETROIT MICH.
EP 6000 REM . TO DELETE AN ENTRY
EI 6001 GRAPHICS 0
DM 6002 RESTORE
OL 6004 ? "INPUT FIRST WORD OF CURRE
        NT ENTRY"
MA 6005 INPUT A$
AN 6010 FLG=0
MK 6015 TRAP 6100
MP 6020 IF FLG=1 THEN GOTO 6120
DO 6021 READ LN,D$,E$,F$
NJ 6030 IF D$=A$ THEN GOSUB 6200
ML 6040 GOTO 6020
MN 6050 GOTO 6120
KD 6100 ? "ENTRY TO BE DELETED NOT F
        OUND.DO YOU WANT TO TRY ALAI
        N?"
OK 6110 INPUT Y$.-IF Y$="Y" THEN 6000
GK 6117 GOTO 20
KJ 6120 RETURN
FD 6200 REM TO PRINT OLD DATA TO ASS
        URE PROPER LINE IS BEING DEL
        ETED AND TO MAKE NEW ENTRY
EK 6210 GRAPHICS 0
EG 6220 ? "#1 OLD IS---";D$
EK 6222 ? "#2 OLD IS---";E$
ED 6224 ? "#3 OLD IS---";F$
ME 6230 ? "IS THIS THE DATA TO BE DE
        LETED?":INPUT Y$
OI 6240 IF Y$="Y" THEN GOTO 6260
M0 6250 GOTO 6020
BF 6260 FLG=1
PM 6270 STLIN=LN:ENLINE=LN
EF 6280 GOSUB 32000
LB 6290 RETURN
EK 7000 GRAPHICS 2
NA 7010 POSITION 4,3
FN 7020 PRINT #6;"DATA STORAGE"
NH 7030 POSITION 7,5
PC 7040 PRINT #6;"SAMPLE"
DH 7050 FOR WAIT=0 TO 100:NEXT WAIT
KN 7060 RETURN
EL 8000 GRAPHICS 2
ND 8010 POSITION 5,4
FJ 8020 PRINT #6;."GOODBYE!"
DG 8030 FOR WAIT=0 TO 100:NEXT WAIT
KM 8040 RETURN
LB 25010 REM AUTOMATIC DATA LINE GEN
         ERATION
CJ 25018 ? CHR$(125)
BA 25020 ? "CDOWN;l";LN:"DATA ";LN;",
         ";A$;",";B$;",";C$:REM THIS
          IS THE DUMMY LINE SET UP W
         HERE DATA IS ENTERED
KH 25024 ? :? :? :?
LF 25025 ? "CONT"
CL 25030 ? :? :?
AA 25035 POSITION 0,0
NI 25040 POKE 842,13:STOP
FI 25050 POKE 842,12
NN 25060 RETURN
AN 32000 REM TO DELETE A GROUP OF LI
         NES
KF 32021 IF STLIN>=32000 THEN 32000
NH 32022 IF ENLINE>=32000 THEN 32000
IM 32023 ? :? "STARTING LINE= ";STLI
         N
IO 32024 ? "ENDING LINE= ";ENLINE
HI 32025 FOR ERASE=STLIN TO ENLINE
LJ 32030 ? CHR$(125):REM CLEARS SCRE
         EN
GI 32040 ? "{DOWN}";ERASE:REM {DOWN}
          APPARENTLY MOVES CURSOR DO
         WN."ERASE" IS THE LINE NUMB
         ER BEING DELETED THIS PASS.
AL 32050 ? :? :? "CONT":REM MUST HAV
         E THIS TO WORK.APPEARS TO S
         TART IT AFTER STOP COMMAND
PM 32060 POSITION 0,0
PE 32070 POKE 842,13:STOP :REM APPAR
         ENTRY PUTS INTO "RETURN MOD
         E"
GF 32080 POKE 842,12:REM PUTS BACK T
         O NORMAL MODE
KN 32090 NEXT ERASE
IE 32095 GRAPHICS 0
BN 32100 ? "ANOTHER DELETION?"
AD 32105 INPUT T$
AN 32108 IF T$="Y" THEN GOTO 6000
NL 32150 RETURN