field examples

Post Reply
PaulKnight
Posts: 19
Joined: Mon Jan 21, 2019 9:27 pm
My devices: iPhone SE
Flag: Great Britain

field examples

Post 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 :-)

User avatar
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: Canada
Contact:

Re: field examples

Post 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
Attachments
F76F7C3E-0ACE-4FB1-87C7-BC19F651555B.png
F76F7C3E-0ACE-4FB1-87C7-BC19F651555B.png (79.62 KiB) Viewed 8359 times
Last edited by rbytes on Tue Mar 26, 2019 3:34 pm, edited 1 time in total.
The only thing that gets me down is gravity...

PaulKnight
Posts: 19
Joined: Mon Jan 21, 2019 9:27 pm
My devices: iPhone SE
Flag: Great Britain

Re: field examples

Post 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 :-)

User avatar
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: Canada
Contact:

Re: field examples

Post 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.
The only thing that gets me down is gravity...

User avatar
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: Canada
Contact:

Re: field examples

Post by rbytes »

Mr. K, the example I gave in this thread should probably be move to For Beginners
The only thing that gets me down is gravity...

ZXvet
Posts: 3
Joined: Fri May 15, 2020 5:52 pm
Flag: Great Britain

Re: field examples

Post 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 ?

User avatar
Mr. Kibernetik
Site Admin
Posts: 4782
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: field examples

Post 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.

ZXvet
Posts: 3
Joined: Fri May 15, 2020 5:52 pm
Flag: Great Britain

Re: field examples

Post 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

User avatar
Mr. Kibernetik
Site Admin
Posts: 4782
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: field examples

Post 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.

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: field examples

Post by GeorgeMcGinn »

I think if you put SLOWDOWN in your code, it should work.

SLOWDOWN does what it says, slows down the CPU and is used exactly for code like keystroke captures or button presses.

Here is the HELP on it:

SLOWDOWN
makes CPU idle for a short time period, thus reducing power consumption. This command can be used in waiting cycles, for example when waiting for button press, and also in looping places where execution speed is not as important as low power consumption. For example, this program uses CPU at 100% while performing simple looping:
1 GOTO 1
and this program leaves CPU almost idle although looping much slower because of short CPU pause in SLOWDOWN command:
1 SLOWDOWN
GOTO 1

George

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
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