Switch from GRAPHICS to Text Output

User avatar
GeorgeMcGinn
Posts: 435
Joined: Sat Sep 10, 2016 6:37 am
My devices: IPad Pro 10.5in
IMac
Linux i386
Windows 7 & 10
Location: Venice, FL
Flag: United States of America
Contact:

Re: Switch from GRAPHICS to Text Output

Post by GeorgeMcGinn »

That's about the basic, yes. Which is why I added a button, because if you hit enter on the last question, it will execute your code and not give you a chance to change any of your responses.

Here is another spin on this. Suppose you want to instead of always having the input box at the top of the screen.

This code is from Ricardo, and it is a simple Q&A where it asks a question waits for your input, then prints a response before going to the next question.

davey110 wrote:
Wed Feb 08, 2017 9:39 pm
Thank you. I read the help notes, but couldn't quite get it all together. Now I see how to integrate the FIELD commands, as in the following code:

x$="Type here"
1 FIELD "name" TEXT x$ AT 200,200 SIZE 200,60 ' draw the field box
FIELD "name" FONT SIZE 50 ' optional
FIELD "name" SELECT ' selects any text already in the field, so it will delete when you start typing new input. Optional.

2 DO
3 UNTIL FIELD_CHANGED("name")=1 ' waits for input
4 x$ = FIELD_TEXT$("name") ' read the new text in the field

The numbered lines are the essential commands. The other 2 lines are "cosmetic", or optional, depending on what you need.

Thanks for getting me on the right track.
ricardobytes wrote:By repeating the code WITH different FIELD names, you can GET a sequence of prompts AND answers. The limit ON my iPad is about 4 interactions IN LANDSCAPE MODE. Since the FIELDS prevent the SCREEN from scrolling up, it starts getting jumpy after the answer TO the 4th question. Also, the KEYBOARD disappears each TIME you press ENTER IN a FIELD, AND THEN pops up again FOR the NEXT question.

Code: Select all

prompt$=""
FIELD "z" TEXT prompt$ AT 1,35 SIZE 300, 25
FIELD "z" FONT NAME "Courier"
FIELD "z" SELECT
PRINT "What is your name?"
DO 
  UNTIL FIELD_CHANGED("z")
  SLOWDOWN
  Answer$=FIELD_TEXT$("z")
  'FIELD "z" SELECT
  PRINT!PRINT!PRINT "Hello, "&Answer$
PAUSE 1
FIELD "y" TEXT prompt$ AT 1,148 SIZE 300, 25
FIELD "y" FONT NAME "Courier"
FIELD "y" SELECT
PRINT!PRINT "Where do you live?"
DO
  UNTIL FIELD_CHANGED("y")
  SLOWDOWN
  Answer$=FIELD_TEXT$("y")
  PRINT!PRINT!PRINT Answer$&" is a nice place."
PAUSE 1
FIELD "x" TEXT prompt$ AT 1,259 SIZE 300, 25
FIELD "x" FONT NAME "Courier"
'Field "y" back alpha 0
FIELD "x" SELECT
PRINT!PRINT "How long have you been a Forum member?"
DO 
  UNTIL FIELD_CHANGED("x")
  SLOWDOWN
  Answer$=FIELD_TEXT$("x")
  PRINT!PRINT!PRINT Answer$&" is a long time!"
PAUSE 1
FIELD "w" TEXT prompt$ AT 1,376 SIZE 300, 25
FIELD "w" FONT NAME "Courier"
FIELD "w" SELECT
PRINT!PRINT "What is your favorite feature of the Forum?"
DO 
  UNTIL FIELD_CHANGED("w")
  SLOWDOWN
  Answer$=FIELD_TEXT$("w")
  PRINT!PRINT!PRINT "Yes, "&Answer$&" is a nice feature."
PAUSE 1
FIELD "v" TEXT prompt$ AT 1,488 SIZE 300, 25
FIELD "v" FONT NAME "Courier"
FIELD "v" SELECT
PRINT!PRINT "Have you posted any programs?"
DO 
  UNTIL FIELD_CHANGED("v")
  SLOWDOWN
  Answer$=FIELD_TEXT$("v")
  PRINT!PRINT!PRINT "Interesting."
PAUSE 2
END
George McGinn
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)

Post Reply