EDITED: Image added
I like the two examples, and quite frankly, these help understand more about the one-line descriptions that are vague in how they work or when to use them.
In this example below, I decided to put all 4 input fields and allow the user to enter them all before processing the results. I do have to add a SUBMIT button instead of relying on detecting a change in the last field.
I have taken ricardobytes' code and changed it up, so that it displays the text and input box for all 4 questions, then executes a GOSUB to gather the inputs and print them out.
My question is on the FIELD_CURSOR_POS statement. I code it exactly as the manual says, and I get a SYNTAX ERROR. I've changed it so all the FIELD statements used N$, O$, P$ and Q$ as shown in the sample in both the online and manual (which is actually the same).
Am I using the FIELD statement to place the cursor in the right box, or is there a bug with this statement?
BTW: Dutchman, thanks for your sample code, as it shows good coding and optimizes running it. All manuals I have seen have example code like you, DAV, ricardobytes, me and others posted showing people how specific statements work. I have many examples that I've noted (privately) when converting my PowerBASIC code to SmartBASIC. If you would like, I would like to see more examples in the next version of the manual, and I am willing to help with providing code and even the detailed writeups for the work I have done and am doing. Let me know if you are interested.
Screen Image Link:
https://www.dropbox.com/s/otz41az7r4pdp ... 3.png?dl=0
Thanks for all your help,
George.
Code: Select all
prompt$=""
Answer$=""
PRINT "What is your name?"
' FIELD_CURSOR_POS("y")
FIELD "y" TEXT prompt$ AT 1,128 SIZE 300, 25
FIELD "y" FONT NAME "Courier"
FIELD "y" SELECT
PRINT!PRINT!PRINT!PRINT "Where do you live?"
FIELD "x" TEXT prompt$ AT 1,214 SIZE 300, 25
FIELD "x" FONT NAME "Courier"
'Field "y" back alpha 0
FIELD "x" SELECT
PRINT!PRINT!PRINT!PRINT "How long have you been a Forum member?"
FIELD "w" TEXT prompt$ AT 1,304 SIZE 300, 25
FIELD "w" FONT NAME "Courier"
FIELD "w" SELECT
PRINT!PRINT!PRINT!PRINT "What is your favorite feature of the Forum?"
FIELD "v" TEXT prompt$ AT 1,400 SIZE 300, 25
FIELD "v" FONT NAME "Courier"
FIELD "v" SELECT
PRINT!PRINT!PRINT!PRINT "Have you posted any programs?"
' Display Inut Name Box
FIELD "z" TEXT prompt$ AT 1,35 SIZE 300, 25
FIELD "z" FONT NAME "Courier"
FIELD "z" SELECT
PRINT!PRINT!PRINT!PRINT "Results of input boxes:"
' We need to prevent a fall through, so we wait until last field is entered.
DO
SLOWDOWN
UNTIL FIELD_CHANGED("v")
GOSUB GetAnswers
STOP
'Get and print out all the answers
GetAnswers:
' DEBUG PAUSE
Answer$=FIELD_TEXT$("z")
PRINT "What is your name: "&Answer$
Answer$=FIELD_TEXT$("y")
PRINT "Where do you live: "&Answer$
Answer$=FIELD_TEXT$("x")
PRINT "How long have you been a forum member: "&Answer$
Answer$=FIELD_TEXT$("w")
PRINT "Yes, "&Answer$&" is a nice feature."
Answer$=FIELD_TEXT$("v")
PRINT "Interesting: "&Answer$
RETURN