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?
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 (79.62 KiB) Viewed 12947 times
Last edited by rbytes on Tue Mar 26, 2019 3:34 pm, edited 1 time in total.
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?
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.
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 ?
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
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)