Page 1 of 1

field examples

Posted: Sun Feb 17, 2019 9:35 pm
by PaulKnight
Hi,

I've been studying the field commands and example in the manual (5.8) but am getting a bit confused. The example runs on my iPhone, but its overly complicated for my needs.

I just need to input some text into a box, and capture the data in a string.

Can anyone point me to a simple example anywhere please?

Many thanks,

Paul :-)

Re: field examples

Posted: Sun Feb 17, 2019 9:45 pm
by rbytes
Here's one I whipped up just for you.

Code: Select all

N$="test" 'name of field
GRAPHICS
GRAPHICS CLEAR 1,1,1
DRAW COLOR 0,0,0
DRAW TEXT "What is your name?" at 200,120
DRAW TEXT "Press return when ready" at 200,160
FIELD N$ TEXT "" AT 200,200 SIZE 300,50
FIELD N$ SELECT 0
DO SLOWDOWN
UNTIL FIELD_CHANGED (N$)
DRAW TEXT "Hi, "& FIELD_TEXT$(N$)&". Nice to meet you." AT 200,280
PAUSE 3
END

Re: field examples

Posted: Sun Feb 17, 2019 9:56 pm
by PaulKnight
Wow!

Thanks AGAIN rbytes - and such a speedy response!

That is EXACTLY what I needed. Do you know if there are any documents with simple examples Iike these for beginners like me? I can get my head around these code snippets much more than those containing functions etc... Once I've grasped the basics, then the more complicated stuff is easier to follow.

Perhaps its just me who struggles, but your simplified examples really help! Maybe there is a gap in the current documentation that we could gradually plug with these code snippets?

Thanks again,
Paul :-)

Re: field examples

Posted: Sun Feb 17, 2019 10:21 pm
by rbytes
There are a couple of places to look for examples. Have you tried the Libraries folder in Basic Programs? Many of the posts are about one single command or function. We could also use the Basic Docs and Books section to post some examples.

Re: field examples

Posted: Tue Mar 26, 2019 2:45 pm
by rbytes
Mr. K, the example I gave in this thread should probably be move to For Beginners

Re: field examples

Posted: Fri May 15, 2020 7:43 pm
by ZXvet
Can anyone explain to me what the do slowdown is for?

Is it anything to do with why In my very very simple first program (a useless program just trying to get to grips with this language) the button press is glitchy, doesn't always seem to "take".

36 BUTTON "again" Title "GO" AT 100,50
37 IF BUTTON_PRESSED ("again") THEN GOTO 15
38 GOTO 37

Does this artless loop happen so fast that the input isn't always registered ?

Re: field examples

Posted: Fri May 15, 2020 8:18 pm
by Mr. Kibernetik
ZXvet wrote:
Fri May 15, 2020 7:43 pm
Does this artless loop happen so fast that the input isn't always registered ?
In this loop your button press is registered as soon as button is pressed.

Re: field examples

Posted: Fri May 15, 2020 9:55 pm
by ZXvet
That's fine, but about 1 time in 4 nothing happens on pressing the button even when the button changes colour on being touched.

I figure it must be something I'm doing wrong but there is no apparent pattern to it that would be a clue

Re: field examples

Posted: Fri May 15, 2020 10:12 pm
by Mr. Kibernetik
ZXvet wrote:
Fri May 15, 2020 9:55 pm
That's fine, but about 1 time in 4 nothing happens on pressing the button even when the button changes colour on being touched.

I figure it must be something I'm doing wrong but there is no apparent pattern to it that would be a clue
There are many examples of buttons usage in Examples folder in the smart BASIC app.
You can check them to see how they work.