Field is not recognised

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9785
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Field is not recognised

Post by dunbarx » Mon May 08, 2023 7:49 pm

CAsba.

Try this. Make a new field, and name it "12345". Now in the message box:

Code: Select all

put "XYZ" into fld 12345
There is no such field, even though the name of that new field is indeed "12345".

LC will not take such a description and use it as a name. It will first try to use it as a field number, and you do not have twelve thousand-odd fields, so LC cannot find that field and tells you so.

Stop, just stop using numbers unless you really know what you are doing. There are definitely reasons to use numbers, but not as names, You might loop through all the fields in the card by:

Code: Select all

repeat with y = 1 to the number of fields
  put y into fld y
end repeat
But that is NOT using numbers as names.

Craig

CAsba
Posts: 389
Joined: Fri Sep 30, 2022 12:11 pm

Re: Field is not recognised

Post by CAsba » Tue May 09, 2023 12:16 pm

Still not got this working...
Firstly, and this works, a field populated with data (taken from a datagrid) is put into the field arraydata.
The field arraydata is used to populate fields in a document, and then is put into a field that is created and named with the number of the document; this field is for the making of a duplicate of the document should it be ever needed. So far, so good.

Secondly, and this doesn't work, I test if the retrieval of the archived field can be used to make a duplicate copy of the document.
The user inputs the required document number, in this case, 500041. The system should put the data in the field 500041 into the field arraydata for populating the fields of the duplicate document.
The code is

Code: Select all

ask " Enter the work order number to be re-called (numerals only))"titled (fld "fieldboxtitle" of cd "template1")
   put it into tAnswer
   put the text of fld "text of tAnswer" into fld "arraydata"
tAnswer is 500041.
There is a field named 500041.
There is a field named arraydata.
The order number entered is 500041.
I have tried both suffixing and prefixing the number to avoid LC problems, but neither strategy worked.
I also suffered an unexpected and immediate shut down whilst experimenting with possible options (??!!??)

Klaus
Posts: 13878
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Field is not recognised

Post by Klaus » Tue May 09, 2023 12:36 pm

Code: Select all

ask " Enter the work order number to be re-called (numerals only))"titled (fld "fieldboxtitle" of cd "template1")
put it into tAnswer
## in tAnswer is the text that the user entered into the ASK dialog

## So this does not really make sense -> fld "text of tAnswer"?
put the text of fld "text of tAnswer" into fld "arraydata"
That is why I suggested -> put tAnswer into fld "arraydata"

What exactly did you try with "have tried both suffixing and prefixing the number to avoid LC problems, but neither strategy worked."?
At least you should now know that using a NUMBER as the name of an LC object is asking for trouble, right? :-D

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9785
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Field is not recognised

Post by dunbarx » Tue May 09, 2023 3:18 pm

CAsba.

You should have caught me out on not putting quotes around the field name (12345 should have been "12345").

It would not have mattered, though. :wink:

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9785
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Field is not recognised

Post by dunbarx » Tue May 09, 2023 3:23 pm

CAsba,

There comes a time when we all have to sit back and rethink the way we are building our little gadgets.
put the text of fld "text of tAnswer" into fld "arraydata"
This would have rung warning bells even in my thick head the instant I saw it, and I mean that I was the one who wrote it. That reads, to me, as if I need a "do" construction to make sense of it.

I suspect that there are bad references, that is, overly complicated and involuted ones, built into your code, and I really suggest you redo them from scratch. You might find that your thinking was sound, and the variable names and references are the culprits.

Craig

CAsba
Posts: 389
Joined: Fri Sep 30, 2022 12:11 pm

Re: Field is not recognised

Post by CAsba » Tue May 09, 2023 5:09 pm

I guess I'm going to have to store the data for each numbered document, not in a field, but in a designated datagrid. Hopefully there's a solution there.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9785
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Field is not recognised

Post by dunbarx » Tue May 09, 2023 6:50 pm

CAsba,

OK, your documents are simply numbered. Just make a way to store them in fields. The sample stack allows you to enter a document number (here limited to "123, 124 and 125". It then puts a random number into the field you choose. This is just to show it works. You of course will place your data into that field.

To get stuff out, enter the document number, and the "data" appears.

It is just a dodge to allow you to "number" your fields strictly according to the document number.

Now make everything fancier, and you are done.

Craig
UsingNUmberedFields.livecode.zip
(1.16 KiB) Downloaded 80 times
Last edited by dunbarx on Tue May 09, 2023 6:58 pm, edited 1 time in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9785
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Field is not recognised

Post by dunbarx » Tue May 09, 2023 6:57 pm

CAsba.

Look at the script of the buttons. See how the simple idea of prepending an "F" to the number, in either direction, and which is the only part you care about, dodges the issue of referencing a field BY number.

The "F" is an integral part of the process, but never appears anywhere.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9785
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Field is not recognised

Post by dunbarx » Wed May 10, 2023 2:15 am

CAsba.

Rereading your very first post, it occurs to me I may have no idea what you are really trying to do.

Is it that, ideally, you want to take a document that is identified by an integer, and store the information on that document in a field that has that integer as its name? The little stack I posted does just that. But then, why that particular methodology?

Craig

CAsba
Posts: 389
Joined: Fri Sep 30, 2022 12:11 pm

Re: Field is not recognised

Post by CAsba » Wed May 10, 2023 12:18 pm

Hi Craig,
Many thanks for your continued interest. I am sorry to say that, having downloaded your stack, I couldn't run it - there is a problem with my Windows setup, it keeps asking me what app I should use to run it, and refers to LC v.9.6.9 which caused me a problem and which I removed, but windows still makes reference to it, even though it's removed entirely and I'm using LV v 10. So, sorry I couldn't make use of it, any chance you could put the code in a reply ?
Your last missive has got my intention 100% correct. My methodology is as it is because there are potentially 130 fields to retain for each document, but in reality, around 30 - 40 will be used. Alternate methodology would be a datagrid, which I am considering, but the field method would be simpler (if I could get it to work !)
What other method were you thinking of ?

CAsba
Posts: 389
Joined: Fri Sep 30, 2022 12:11 pm

Re: Field is not recognised

Post by CAsba » Wed May 10, 2023 3:14 pm

Klaus,
Your suggestion

Code: Select all

put the text of fld tAnswer into fld "arraydata"
with a bit of juggling to gety there, now WORKS !
That's great,
Many thanks.
(Phew....!!)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9785
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Field is not recognised

Post by dunbarx » Thu May 11, 2023 2:34 pm

CAsba.

Couldn't upload a zipped standalone, file too large.

If you want to recreate the stack a screenshot is attached. There are only two handlers. This is for the upper button:

Code: Select all

on mouseUp
   ask "Enter document number"
   if it is not in "123124125" then exit to top
   
   put random(99999) into fld ("F" & it)
end mouseUp
and this for the lower:

Code: Select all

on mouseUp
   ask "Enter document number"
   if it is not in "123124125" then exit to top
   
   answer fld ("F" & it)
end mouseUp
Craig
Screenshot 2023-05-11 at 9.31.50 AM.png.zip
(79.22 KiB) Downloaded 70 times

Klaus
Posts: 13878
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Field is not recognised

Post by Klaus » Thu May 11, 2023 2:58 pm

Hi CAsba,
CAsba wrote:
Wed May 10, 2023 12:18 pm
Hi Craig,
Many thanks for your continued interest. I am sorry to say that, having downloaded your stack, I couldn't run it - there is a problem with my Windows setup, it keeps asking me what app I should use to run it, and refers to LC v.9.6.9 which caused me a problem and which I removed, but windows still makes reference to it, even though it's removed entirely and I'm using LV v 10...
??? :shock:

Open LC 10, then use the menu -> File -> Open stack... and navigate to the stack in question!
Doubleclicking a stack file is NOT the only way to open a stack, although many Windows users may think so... 8)

Best

Klaus

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”