Newline

In NEWLINE numerical information can be entered with ease from the keypad since all separating commas are added by the program. Each data item is entered individually and stored in the same data line until you type in #. A # indicates completion of data entry in the current line and causes the next line number to be displayed. Each line number is incremented by 10. Entering END stops data from being entered and causes the data lines to be written to a disk file named TEMPXFER. If you discover that you made a mistake on the previous item of data, just type XX instead of the next data item and you can type that item over again.

If N EWLIN E is to be used without the character limitation routine suggested below, it would still be wise to insert a caution line following line 10160 to alert you that the line is nearly full. For example:

10165 IF LEN(T$(N)) => 240 THEN PRINT "WARNING "

(The character limitation number—240 above—depends on the nature of the information being entered.)

You may want to use the following suggestions which can be successfully added to the primary routine.

1. Add a live keyboard input subroutine to limit the length or nature of individual items and to control the length of the line.

2. Customize the input process at lines 10060 through 10120 to provide descriptive prompts for the information required in a particular application.

3. When lines are to be entered consecutively without any interval, eliminate the prompt for the starting line number and have the program set the starting line. For example, using an assigned data block with a single item on each line:

1999 DATA END

Read and discard the data lines already in place with a counter variable, and set SN equal to 1000 plus the counter variable.

4. Display operator instructions for continuation of the main program just before line 10190.

110 CLEAR 5000

112 DEFINT A-Z

114 CLS

115 PRINT"ADD DATA LINES TO THE RESIDENT PROGRAM:"

116 PRINT

10010 0PEN"0",1,"TEMPXFER" 10030 INPUT"STARTING WITH LINE NO. ";SN 10040 FOR N=1 TO 100 10050 PRINT

10060 PRINT"Entering Line Number "SN

10110 PRINT

10120 INPUT"Enter Data Item ";D$ 10130 IF D$="#" THEN GOSUB 10200 : NEXT N

10140 IF D$="END" OR D$="end" THEN GOSUB 10200 : GOTO10180

10150 IF D$="XX" OR D$="xx" THEN GOSUB 10280

: GOTO 10120 10160 T$(N)=T$(N)+D$+", " 10170 GOTO 10120 10180 CLOSE 10190 MERGE"TEMPXFER" 10200 1 *** TO WRITE LINE TO FILE *** 10205 Z$=SN$+" DATA " 10210 CLS

: IF T$(N)=Z$ THEN SN=SN-10 : N=N-1 : RETURN 10220 L=LEN(T$(N))-2 10230 T$(N)=LEFT$(T$(N),L) 10240 PRINTT$(N) 10250 PRINT#1,T$(N) 10260 SN=SN+10 10270 RETURN

10280 1 *** ITEM CORRECTION ROUTINE *** 10285 Z$=SN$+" DATA " 10290 IF T$(N)=Z$ THEN N=N-1 : SN=SN-10 : FL=1 10300 L=LEN(T$(N)) 10310 FOR X=(L-2) TO 1 STEP -1 10320 IF MID$(T$(N),X,1)=","THEN 10500 10330 NEXT X

10340 IF FL=1 THEN PRINTT$(N) : GOSUB 10400 : RETURN 10350 T$(N)=SN$+" DATA " 10360 PRINTT$(N) 10370 GOSUB 10400 10380 RETURN

10390 ' *** PRINT LINE FOR CORRECTION ROUTINE *** 10400 PRINT"CORRECTION OF PRECEDING ENTRY" 10410 FL=0 10420 RETURN

10500 ' ** PREPARE LINE FOR CORRECTION **

10520 PRINTT$(N)

10530 GOSUB 10400

10540 RETURN

0 0

Post a comment