Text on location?
Text on location?
Hi,
Is there a command to place text on a certain location on the screen?
Or should we use the graphics screen for this?
Greetings,
Is there a command to place text on a certain location on the screen?
Or should we use the graphics screen for this?
Greetings,
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: Text on location?
Yes, to print text at a specific location you need to use graphics mode and graphics functions.
Text mode is for a serial text output, like on a typewriter.
Text mode is for a serial text output, like on a typewriter.
- 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:
- Contact:
Re: Text on location?
Here is some quick code i wrote to test the very thing you asked.
You can print your input question "What is your name" by the input box, but I was just testing the FIELD commands.
You can do this without being in GRAPHIC mode, but it will not look as professional, especially if you are looking to sell on iTunes.
Hope this helps.
George
EDIT: I didn't realize this question was 4 years old! I will have to check how my forum is displayed
I used the DO loop just out of convience, as this would cause a 100 percent CPU usage if you let it go without any input.
You can also look at SmartBASIC's ability to capture keystrokes.
You can print your input question "What is your name" by the input box, but I was just testing the FIELD commands.
You can do this without being in GRAPHIC mode, but it will not look as professional, especially if you are looking to sell on iTunes.
Hope this helps.
George
EDIT: I didn't realize this question was 4 years old! I will have to check how my forum is displayed
I used the DO loop just out of convience, as this would cause a 100 percent CPU usage if you let it go without any input.
You can also look at SmartBASIC's ability to capture keystrokes.
Code: Select all
prompt$=""
FIELD "z" TEXT prompt$ AT 1,350 SIZE 300, 25
FIELD "z" SELECT
PRINT "What is your name?"
DO
UNTIL FIELD_CHANGED("z")
Answer$=FIELD_TEXT$("z")
FIELD "z" SELECT
PRINT Answer$
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)
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)
- rbytes
- Posts: 1338
- Joined: Sun May 31, 2015 12:11 am
- My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet - Location: Calgary, Canada
- Flag:
- Contact:
Re: Text on location?
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,130 SIZE 300, 25
field "y" font name "Courier"
FIELD "y" SELECT
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,220 SIZE 300, 25
field "x" font name "Courier"
'Field "y" back alpha 0
FIELD "x" SELECT
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,310 SIZE 300, 25
field "w" font name "Courier"
FIELD "w" SELECT
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,400 SIZE 300, 25
field "v" font name "Courier"
FIELD "v" SELECT
PRINT "Have you posted any programs?"
DO
UNTIL FIELD_CHANGED("v")
slowdown
Answer$=FIELD_TEXT$("v")
PRINT!PRINT!Print "Interesting."
pause 2
end
END
- Attachments
-
- IMG_5857.PNG (143.26 KiB) Viewed 6034 times
The only thing that gets me down is gravity...
- Dutchman
- Posts: 851
- Joined: Mon May 06, 2013 9:21 am
- My devices: iMac, iPad Air, iPhone
- Location: Netherlands
- Flag:
Re: Text on location?
With the command 'FIELD_CURSOR_POS(…)' from version 5.5, it is rather simple to realize an "Inline-Input'-function with Text-fields.
See viewtopic.php?f=24&t=828&p=8779#p8779
See viewtopic.php?f=24&t=828&p=8779#p8779
Code: Select all
'Inline Input Field
'with safe prompt
'by Dutchman, april 2016
n=1
DO
Prompt$="Request "&STR$(n,"#")&": "
Field$="In_"&STR$(n,"#")
Answer$=Input$(10,75+n*25,400,22,Field$,Prompt$)
PRINT "Input";n;"=";Answer$
n+=1
until n>3 OR Answer$=""
END
DEF Input$(x,y,w,h,Field$,Prompt$)
FIELD Field$ AT x,y SIZE w,h
FIELD Field$ FONT SIZE h-6
CALL InputPreset(Field$)
FIELD Field$ SELECT
prompt=LEN(Prompt$)
DO
IF FIELD_CURSOR_POS(Field$)<prompt THEN FIELD Field$ TEXT Prompt$
SLOWDOWN
UNTIL FIELD_CHANGED(Field$)
Txt$=FIELD_TEXT$(Field$)
T$=RIGHT$(Txt$,LEN(Txt$)-prompt)
RETURN T$
END DEF
DEF InputPreset(name$)
FIELD name$ BACK COLOR 0,1,0
FIELD name$ FONT NAME "Verdana"
FIELD name$ FONT COLOR 0,0,1
END DEF
Last edited by Dutchman on Thu Jan 19, 2023 3:33 pm, edited 1 time in total.
- 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:
- Contact:
Re: Text on location?
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.
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
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)
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)
-
- Posts: 814
- Joined: Tue Apr 09, 2013 12:23 pm
- My devices: iPhone,iPad
Windows - Location: Groningen, Netherlands
- Flag:
Re: Text on location?
Thanks for sharing, Ton. Nice and paricularly usefull for input queries in pages.Dutchman wrote:With the command 'FIELD_CURSOR_POS(…)' from version 5.5, it is rather simple to realize an "Inline-Input'-function.
- Dutchman
- Posts: 851
- Joined: Mon May 06, 2013 9:21 am
- My devices: iMac, iPad Air, iPhone
- Location: Netherlands
- Flag:
Re: Text on location?
No thank you, keeping the PDF-manual updated gives me enough extra work. Even the size is already large and requires commercial printing. I suggest you contribute to a PDF document entitled "Examples of smart programming". The forum-members you mentioned will certainly assist in correcting and cleaning your proposals.GeorgeMcGinn wrote: … If you would like, I would like to see more examples in the next version of the manual, and I am willing to help …
- rbytes
- Posts: 1338
- Joined: Sun May 31, 2015 12:11 am
- My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet - Location: Calgary, Canada
- Flag:
- Contact:
Re: Text on location?
I ran your code on my iPad, George, and the fields and text were not in sync. The second question was at the top of the screen with the first field under it. Once I had filled in all of the fields, the keyboard disappeared and text and fields got back in sync. The image shows what my screen looked like when the program finished.
I am working on another concept that doesn't require multiple fields. It should allow for unlimited question-response interaction on screen, similar to what you would see on a chat page, and what many other Basic versions can provide. I have seen past posts where this feature was requested. Still some issues to solve, but I will post it when it's ready.
I am working on another concept that doesn't require multiple fields. It should allow for unlimited question-response interaction on screen, similar to what you would see on a chat page, and what many other Basic versions can provide. I have seen past posts where this feature was requested. Still some issues to solve, but I will post it when it's ready.
- Attachments
-
- IMG_5923.PNG (159.97 KiB) Viewed 5984 times
The only thing that gets me down is gravity...
- 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:
- Contact:
Re: Text on location?
Yes, in a way. In order to get the cursor in the first field, it had to be displayed last. I have another program that puts all of the input on the screen at once, highlights the field to be filled, and executes on the enter of the last field, which should fix that issue. It wasn't my better coding as I was still experimenting and figuring out what the FIELD_CURSOR_POS(N) does.
I look forward to your your other concept.
I look forward to your your other concept.
ricardobytes wrote:I ran your code on my iPad, George, and the fields and text were not in sync. The second question was at the top of the screen with the first field under it. Once I had filled in all of the fields, the keyboard disappeared and text and fields got back in sync. The image shows what my screen looked like when the program finished.
I am working on another concept that doesn't require multiple fields. It should allow for unlimited question-response interaction on screen, similar to what you would see on a chat page, and what many other Basic versions can provide. I have seen past posts where this feature was requested. Still some issues to solve, but I will post it when it's ready.
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)
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)