May June 1980 - Commodore Computers
May June 1980 - Commodore Computers
May June 1980 - Commodore Computers
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
MAY/JUNE. I 198O. <strong>1980</strong>. ISSUE 4. COMPUTE. 77 n<br />
PETGETWITH<br />
FLASHING<br />
CURSOR<br />
Gary Greenberg<br />
35-63 SOth St.<br />
Jackson Hts., , NY 11372<br />
There are many reasons why some programmers<br />
prefer to use the GET statement for keyboard input<br />
rather than the INPUT statement. ent. One reason of<br />
interest to many beginners is that the ,he GET statement<br />
can help prevent falling out of the program<br />
when the wrong response is made. For example,<br />
pressing RETURN as a response to INPUT causes<br />
you to fall out of the program. Similarly if you<br />
call for a numeric variable and type an alphabetic<br />
character, again you are in trouble.<br />
The GET statementt works by checking the keyboard<br />
input buffer for the next character. However, H without the benefit of appropriate software routines,<br />
the GET statement collects only one character, does<br />
not provide a cursor for a prompt, does not print<br />
the character on the screen and does not permit you<br />
to erase the result before entering 'he the data.<br />
Additionally, the statement is executed so rapidly<br />
you will probably not be able to enter it in time to<br />
get it accepted. You do not use a carriage return<br />
to signal the end of the entry.<br />
A number of magazines have provided software<br />
pieces to enable you to use the GET but they do<br />
not permit you to delete and correct the entry before<br />
entering it into the program. The following program<br />
permits you to use the GET statement instead of the<br />
INPUT statement. It will permit you to have a<br />
flashing cursor and it will permit you to delete<br />
and correct entries before committing them to the<br />
computer. You use the carriage return to signal the<br />
end of your entry. You will not fall out of your<br />
program if you respond with a carriage return.<br />
program if you respond with a carriage return.<br />
Program Listing<br />
Program Listing<br />
100 PRINT'WHAT " IS ANSWER?";:GOSUB A 1000<br />
110 PRINTZ1$:Z1 PRINTZIS,ZI = ~ VAL(ZI$),PRINTZI<br />
VAL{Z1S):PRINTZ1<br />
1000 REM GET WITH FLASHING CURSOR<br />
1010 ZS . ····,ZIS = ....<br />
1010 ZS -"":Z1| =""<br />
1020 IU2U PRINT"R ' R rd" rcl";:FORI :: FOIU 0: = I TTOO 35:NEXTI<br />
Gary Greenberg<br />
35-63 80th St.<br />
1030 PRINT"cl";:FORI I'RI Nr 'd " "FORI = - I 1 ·f TOO 35,NEXT 35:NEXTII<br />
1040 [040GETZ$:IFZS=""THEN1020<br />
GETZS, = .... TH EN 1020<br />
1050 REM ERASE ENTRY CHECK<br />
1060 IFZS IFZ$ < > CHR$(20)THEN HRS(20)THEN 1110<br />
10<br />
1070 IF2I-""THEN I FZS •.. " EN 1020<br />
1080 ZZ . =LEN(Z1$):IF LEN(ZIS), IF ZZ < I 1 THEN 1020<br />
1090 ZIS-LEFTS(Zl$,ZZ-l|:PRINT"d";<br />
= I S.ZZ- I ), I' ·· d ··:<br />
1100 GOTO 1020<br />
1110 IFZS =CHRS(13) OR ZS Z$ =CHRS(141) THEN 1150<br />
1120 PRINT ZS Z$; ,<br />
1130ZIS Z1$=Z1$+Z$ · ZIS + ZS<br />
1140 GOTO 1020<br />
1150 GETZ8:IF ZS, ZS Z$ ~ -- ····THEN ""THEN 1150<br />
50<br />
1160 RETURN<br />
The program is a subroutine that can be called in<br />
place of any INPUT statements. Here's how it works_<br />
works.<br />
LINE 100: The print message is used as a prompt.<br />
GET does not provide a question mark and you will<br />
have to put it into the PRINT statement if you<br />
want it. After the prompt is printed the program<br />
jumps to the subroutine,<br />
subroutine.<br />
LINE 110: This line is the line after the subroutine<br />
is executed. You can use any program statements you<br />
wanl. want. The one here is just an illustration. The PRINT<br />
Z Zl$ 1 $ is redundant since it is printed out in the subroutine.<br />
The VAL statement is used to convert the<br />
STRING to a NUMERIC. You should note that the<br />
subroutine leaves the cursor immediately after the<br />
entry. If you want a linefeed you will have to<br />
insert a I"PRINT:" I I' in line 110.<br />
LINE 1000: The subroutine starts here.<br />
LINE 1010: 10: Z$ will be used to collect the data<br />
typed in. ZI$ Zl$ will be used to build a string out of<br />
the data entered. This line initializes both strings<br />
as Nulls s (empty).<br />
LINES 1020-10.30: 1020-1030: These lines simulate the cursor.<br />
The two FOR-NEXT routines are time delays. . To<br />
speed up the flashing cursor, , shorten the loops.<br />
To slow down the cursor, , increase the number of<br />
loops. . The PRINT statements produce a REVERSE<br />
FIELD, SPACE (becomes a solid block in Reverse<br />
field), REVERSE OFF, CURSOR LEFT. This is<br />
followed by the delay and then PRINT SPACE<br />
and CURSOR LEFT again followed owed by a delay. By<br />
using different characters instead of the space character<br />
you can create some interesting cursors. This<br />
produces an interesting wig-wag effect.<br />
LINE 1040: The GET checks the keyboard buffer.<br />
If it is empty (null s'ring) string) it starts the cursor<br />
flashing again while it waits for data. Once a<br />
character has been entered the program moves on to<br />
the next line where it begins s to examine the nature<br />
of the character entered.<br />
LINE 1050-1060: These lines check for a ""delete".<br />
LINE 1070: If ""delete" is entered and there is no<br />
data entered the program returns to the flashing<br />
cursor.<br />
LINE 1080: If data has been entered this line<br />
checks to see how long the data is. This check is<br />
to make sure that the I' "delete" does not go past<br />
the beginning entry point on the screen_<br />
screen.<br />
LINE 1090: The last character in the string is<br />
deleted. You can continue to delete characters until<br />
you have erased the whole string, and the program<br />
keeps checking for the delete every time you make an<br />
entry.<br />
LINE 1100: You return to the flashing cursor<br />
waiting for the next entry.<br />
LINES 1110-1140: These lines first check to see if<br />
you have hit "carriage return" or shifted "carriage<br />
return". rn " . If not, then the program adds Z$ to Zl$ Z 1 $ to