Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
No INPUT?
#1
hi there,
There is no "INPUT" keyword in the ZXBASIC's list, so I guess it's not implemented. However, I got no error on compiler output about "input" (if I use it) yet it does not compile the program. I tried "input a" and it gives "Syntax Error. Unexpected token 'a' <ID>" and does not complain about input. Whatever, there is no documentation on input, or I couldn't be able to locate where it is.

So, what is the equivalent of sinclair basic "INPUT" command? I just need to ask an user to type a name or number, do I need to program whole input funciton with inkey(undocumented) and print, or there is an easy way to do it?
Reply
#2
Input isn't directly supported, no. It's one of a very short list of Sinclair Basic commands that is externalized. The problem is that the Sinclair Basic input command is a very complex beast - it includes most of the functionality of PRINT for example - and it also stops the computer dead while it's waiting for input. Further, ZX Basic treats the whole screen as one with 24 lines, not a lower area and an upper area.

Boriel decided not to include it directly because there are other ways of getting user data, such as inkey.

However there is a library function that implements the heart of it - #include <input.bas> at the start of the program to add that functionality in.

You can then use variable$ = input(MaxLength) to get an input cursor the user can type at and delete mistakes. It returns a string, and it allows up to MaxLength characters. It will put an input cursor at the most recently used print position; so use PRINT AT just beforehand to position it. You can certainly do print at 23,0 to put it where you'd be used to having it - though it may misbehave if the user is allowed to type more than a whole line.
Reply
#3
ref Wrote:So, what is the equivalent of sinclair basic "INPUT" command? I just need to ask an user to type a name or number, do I need to program whole input funciton with inkey(undocumented) and print, or there is an easy way to do it?
Input can't be implemented (easily) in compiled programs. But there is an INPUT function which works much like FreeBASIC input.

You need to use #include <input.bas>:
Code:
#include <input.bas>
A$ = Input(20) : REM Read 20 chars (waits for enter)
PRINT "You wrote "; A$
Input(n) won't let the user to type more than N chars.
Reply
#4
I added documentation for INKEY for you.

Note that almost (but not quite all) undocumented words are 100% Sinclair Basic compatible. Priority is being given to incompatibilities with Sinclair Basic, since it is assumed that most users have a working knowledge of Sinclair Basic before starting to program with this compiler; and the Sinclair Basic Manual at <!-- m --><a class="postlink" href="http://www.worldofspectrum.org/ZXBasicManual/">http://www.worldofspectrum.org/ZXBasicManual/</a><!-- m --> can be used as a reference for most of the documentation holes.
Reply
#5
britlion Wrote:I added documentation for INKEY for you.

Note that almost (but not quite all) undocumented words are 100% Sinclair Basic compatible. Priority is being given to incompatibilities with Sinclair Basic, since it is assumed that most users have a working knowledge of Sinclair Basic before starting to program with this compiler; and the Sinclair Basic Manual at <!-- m --><a class="postlink" href="http://www.worldofspectrum.org/ZXBasicManual/">http://www.worldofspectrum.org/ZXBasicManual/</a><!-- m --> can be used as a reference for most of the documentation holes.
I completely agree.
Note, I'm currently attending the Tenerife Lan Party 2010 event <!-- m --><a class="postlink" href="http://www.tenerife-lanparty.com/2k10/">http://www.tenerife-lanparty.com/2k10/</a><!-- m -->
I'll try to give a short presentation (if possible) of the ZX BASIC compiler. There's a retrocomputing zone (Spectrum, MSX, Amstrad, Commodore) so hope some people might be interested. :roll:
Reply
#6
yes, I know input is a complex command, and I understand why yu didn't include it.

I suggest you to include some workarounds about missing keywords in wiki, so people know what to do incase they need to use a command. Afterall we are all sinclair basic users.

Thank you for your help! I'll be using your compiler in the future, and bring more questions to here, obviously Smile
Reply
#7
ref Wrote:yes, I know input is a complex command, and I understand why yu didn't include it.

I suggest you to include some workarounds about missing keywords in wiki, so people know what to do incase they need to use a command. Afterall we are all sinclair basic users.

Thank you for your help! I'll be using your compiler in the future, and bring more questions to here, obviously Smile

Glad to have you here, ref! I already realized that your confusion over input might not be limited to just you, so I added a line for INPUT in the reserved words list - noting it's an add-in function; as well as gave it a page. That does remind me that ATTR and POINT are in the same category, of course.
Reply
#8
britlion Wrote:
ref Wrote:yes, I know input is a complex command, and I understand why yu didn't include it.

I suggest you to include some workarounds about missing keywords in wiki, so people know what to do incase they need to use a command. Afterall we are all sinclair basic users.

Thank you for your help! I'll be using your compiler in the future, and bring more questions to here, obviously Smile

Glad to have you here, ref! I already realized that your confusion over input might not be limited to just you, so I added a line for INPUT in the reserved words list - noting it's an add-in function; as well as gave it a page. That does remind me that ATTR and POINT are in the same category, of course.
There is a #include <sinclair.bas> that contains SCREEN, POINT, INPUT and other Sinclair ZX Spectrum functions not included with the compiler. This is because ZX BASIC aims to be a multi-architecture compiler (MSX, Amstrad...), so in the future, MSX people might need #include <msx.bas> Tongue

Anyway, most of the original Sinclair BASIC is included (READ, DATA & RESTORE planned!)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)