entry field error after 9 fields

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

entry field error after 9 fields

Post by trags3 » Fri Apr 11, 2014 7:12 pm

I have a card with 11 text entry fields that need to be numbers.
I have code for each text box to check for the enter key, return key and to make sure each key pressed is a number.
When the enter or return key is pressed focus is sent to the next desired entry field.
The code I am using is:

on returninfield
focus on field misc2
end returninfield

on enterinfield
returninfield
end enterinfield

on keyDown theKey
if theKey is not a number then beep
else pass keyDown
end keyDown

After pressing the enter Kee in the 10th field I get an error message as follows:

field "misc2": execution error at line 2 (focus: not a valid control), char 1

I don't know what to do.
thanks

Tom

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: entry field error after 9 fields

Post by FourthWorld » Fri Apr 11, 2014 7:28 pm

Where is the variable "misc2" defined?

It may be simpler to just turn on the autoTab property for each field, and then the engine will take care of the tab-on-return behavior for you automatically.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Re: entry field error after 9 fields

Post by trags3 » Fri Apr 11, 2014 7:57 pm

misc2 is the name of the next entry field and works and is different for each field and allows focus to be in the order I want.
Thanks that works. I didn't have the "tab on Return" property checked in the offending field.
The only problem now is how do I change the order of which entry field gets the focus on the tab key.
I have removed all the code except for the On keyDown message.

Thanks

tom

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: entry field error after 9 fields

Post by Simon » Fri Apr 11, 2014 8:10 pm

Hi Tom,
The fields are focused in layer order.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: entry field error after 9 fields

Post by dunbarx » Fri Apr 11, 2014 8:12 pm

Hi.

You can change the layer order of the fields, so the natural progression works for you, or you can place a tabKey handler in each field that explicitly focuses on the next field you want.

Are your fields really named as numbers? This is not good practice at all. Could you rename them something like "f1,f2,f3..."? These are much easier to manage. If your fields are named in the desired order, can you write a single tabKey handler in the card script that does the refocusing? It would be a terrific learning exercise. Do try. Write back if you get stuck.

Anyway, know that a little re-thinking is really powerful sometimes.

Craig Newman

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Re: entry field error after 9 fields

Post by trags3 » Fri Apr 11, 2014 10:42 pm

I have tried to change the level of the entry fields on the card unsuccessfully.
I tries script at the entry box level and at the card level.
The code I tried is:
set the layer of "SellerN" to 1
set the layer of "PropAddr" to 2
set the layer of "City" to 3
set the layer of "salesprice" to 4
set the layer of "MortPayoff" to 5
set the layer of "commissionp" to 6
set the layer of "TransactFee" to 7
set the layer of "HOATrans" to 8
etc
Help Please
Tom

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: entry field error after 9 fields

Post by Simon » Fri Apr 11, 2014 11:20 pm

Hi Tom,
You must include the object with that name e.g.
set the layer of field "SellerN" to 1

Using the Project Browser you can drag the objects to new layers, for simple stack it often works but I find it flaky.

The best way I find is to use the Inspector and set the layer in "Size & Position"

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Re: entry field error after 9 fields

Post by trags3 » Fri Apr 11, 2014 11:27 pm

Thanks Simon, I just realized that as you posted the answer.
It sucks to be a noob

Tom

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: entry field error after 9 fields

Post by Simon » Fri Apr 11, 2014 11:58 pm

Hey Tom, don't worry with liveCode you will learn very quickly.

My favorite gotcha's:

Code: Select all

repeat with x = 1 to the number of lines in tVar
if "Remove this sad little line" is in line x of tVAr
delete line x of tVar
end if
end repeat
That one is great because it almost works and looks very reasonable.

Code: Select all

offset("b","abacadabra",2) -- returns 6
That "2" is characters to skip but it doesn't work the way I expect

And one that never actually got me but comes up here too often is that global variables have to be declared everywhere they are used.

When you come to any of those and get stumped just ask here.

Simon
Edit:
myPlants.zip
LC 6.5
(2.21 KiB) Downloaded 201 times
This is the other big thing that comes up, saving the state of your standalone. You must write to a separate file to save changes. You haven't gotten to that point yet but I can tell you will ;)
Keep that stack handy.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Re: entry field error after 9 fields

Post by trags3 » Sat Apr 12, 2014 2:05 am

Thanks a lot Simon.
I really am learning pretty fast.

Tom

Post Reply