String input and use of LINE

See all articles from Sinc-Link v3 n6
Author(s): David Hoshor
Publication: Sinc-Link
Pub Details: Sinc-Link v3 n6 (Volume 3, Issue 6)
Date: November/December 1985
Pages: 11

As you probably know, the keyword “LINE” is used when you are saving a program and you want it to auto-run at a specific line number. You save the program using:

SAVE "progname"LINE 10

if you want it to start at line 10.

If LINE is used in conjuction with the INPUT command, you can ask for string input, but without the quotation marks surrounding the cursor. Try this simple program:

10 INPUT "Enter your name"; LINE n$

and you will see that the cursor appears without quotation marks. The normal STOP keyword will not stop input when LINE is used. You must type CAPSHIFT 6 to stop the program at the INPUT prompt.

Now suppose that you want to use the string variable n$ from the above INPUT line to make the prompt more personal. The line:

20 INPUT "Enter how much money you have in your pocket ";n$;" " LINE a$

won’t work, because it will assign the string value of the money to the variable n$ when n$ is supposed to be the person’s name. Instead enclose the string to be printed within parenthesis like this:

20 INPUT "Enter how much money you have in you pocket ";(n$);" ";LINE a$

and the string n$ will be printed and the variable a$ will have the amount of money in your pocket assigned to it.

I hope you will find these hints helpful. They were obtained from the October issue of YOUR SPECTRUM.

David Hoshor