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

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

Field is not recognised

Post by CAsba » Mon May 08, 2023 12:26 pm

HI,

Code: Select all

set itemdelimiter to TAB
   lock screen
   create fld "temp"
   set the loc of fld "temp" to "786,138"
   put fld "arraydata" into fld "temp"
   create fld "temp2"
   put item 1 & tab of line 1 of fld "arraydata" into fld "temp2"
   set the name of fld "temp" to the text of fld "temp2"
   delete fld "temp2"
   set the loc of fld "500039" to "786,138"
   unlock screen
In the above, I should explain that in line 7, item 1 of fld arraydata is 500039, and I want to set the name of fld temp to 500039. There now is a physical fld 500039, verified by both the property inspector and its listing in the project browser. However the line 'set the loc...' has no effect, (error, no such object) and if I refer to fld "500039" in other coding, I get an error 'no such object'.
How can I "endorse" the field to be recognised by the system ?

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

Re: Field is not recognised

Post by CAsba » Mon May 08, 2023 12:45 pm

Hold on, I think I found it - in testing this I inadvertently made numerous fields 500039, so I'd better get rid of them all and test again !! Sorry for that !

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

Re: Field is not recognised

Post by Klaus » Mon May 08, 2023 12:51 pm

Hi CAsba,

NEVER EVER name a field, or any LC object, with a NUMBER!
LC does nto differ between an objects name and its number this way and is looking for a field with that NUMBER!

Best

Klaus

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

Re: Field is not recognised

Post by CAsba » Mon May 08, 2023 4:25 pm

Hi Klaus,
First of all, I was wrong in guessing that the fault was in having multiple files of the same name, 500039. I deleted all the files 500039 in the project browser, but the problem I raised still remains; a single field 500039 exists, both physically - I can see it and it's verified by the property inspector, and it appears (once) in the project browser.
Secondly, your advice - never use a number to identify a field - is a major inconvenience as I wanted the user to be able to request a duplicate copy of a document by specifying the document number to be duplicated, which referes to the field with that document's data. Is it still a no-go if I add, say, a suffix to the number ?

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

Re: Field is not recognised

Post by CAsba » Mon May 08, 2023 4:28 pm

I should have added that the single field 500039 raises error message No Such Object when any code pertaining to it is used.

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

Re: Field is not recognised

Post by Klaus » Mon May 08, 2023 4:35 pm

Hi CAsba,

that was more a general warning! :D

Since you probably don't have 500038 objects on your card, that may be no problem.
And yes adding a PREfix to the name like -> f500069 is a good workaround!

Best

Klaus

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

Re: Field is not recognised

Post by CAsba » Mon May 08, 2023 5:10 pm

Hi Klaus,
All this is preceded by the main problem...

Code: Select all

set the itemdelimiter to tab
   ask " Enter the work order number to be re-called (numerals only))"titled (fld "fieldboxtitle" of cd "template1")
   put it into tAnswer
   #put tAnswer into fld "change"
   #put the text of fld "text of fld "change"" into fld "arraydata"
   put the text of fld "text of tAnswer" into fld "arraydata"
   
This (rubbish) code may explain what I'm trying to do.
I have a field, 500039, that holds data, for use of making a duplicate document (where the original may have been lost). 500039 also is the number of the document. So, the user enters the document number, and with that information I want the system to put the text of the field of the same name (number) into a field "arraydata".
It's got me stuck! Any ideas ?

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

Re: Field is not recognised

Post by Klaus » Mon May 08, 2023 5:38 pm

Sorry, don't get it?!
Script looks OK.

Maybe you mean:

Code: Select all

...
##  put the text of fld "text of tAnswer" into fld "arraydata"  
put the text of fld tAnswer into fld "arraydata"
...
?

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

Re: Field is not recognised

Post by CAsba » Mon May 08, 2023 5:47 pm

I put

Code: Select all

put the text of fld tAnswer into fld "arraydata"
and got 'No Such Object'

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

Re: Field is not recognised

Post by Klaus » Mon May 08, 2023 6:01 pm

OK, I have of course no idea what the user might enter into the dialog...

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

Re: Field is not recognised

Post by CAsba » Mon May 08, 2023 6:34 pm

I should have said, imitating a user I entered 5000039.

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

Re: Field is not recognised

Post by CAsba » Mon May 08, 2023 6:36 pm

I mean 500039

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

Re: Field is not recognised

Post by CAsba » Mon May 08, 2023 6:46 pm

Code: Select all

set the itemdelimiter to tab
   ask " Enter the work order number to be re-called (numerals only))"titled (fld "fieldboxtitle" of cd "template1")
   put it into tAnswer
   #put tAnswer into fld "change"
   #put the text of fld "text of fld "change"" into fld "arraydata"
   #put the text of fld "text of tAnswer" into fld "arraydata"
   put tAnswer into fld "arraydata"      ## This put 500039 into arraydata
   put the text of fld tAnswer into fld "arraydata"
## This got error message 'No Such Object'

tAnswer is shown to be an object in the penultimate line
Fld "arraydata" is shown to be an object in the penultimate line
fld "500039"is shown in the project browser, is visible, and property inspector confirms its name.

But...
put the text of fld tAnswer into fld "arraydata" ## This got error message 'No Such Object'

This is Difficult !

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:24 pm

CAsba.

What Klaus meant, here and there, and something you must pay attention to, is that without a certain amount of context there is no way to understand what issues you might have.

For example, I made a new stack and put this in a button:

Code: Select all

on mouseUp
   set the itemdelimiter to tab
   ask " Enter the work order number to be re-called (numerals only))"titled (fld "fieldboxtitle")
   put it into tAnswer
   #put tAnswer into fld "change"
   #put the text of fld "text of fld "change"" into fld "arraydata"
   #put the text of fld "text of tAnswer" into fld "arraydata"
   put tAnswer into fld "arraydata"      ## This put 500039 into arraydata
   put the text of fld tAnswer into fld "arraydata"
end mouseUp
My stack had to have a field "boxTitle" as well as a field "arrayData", but there is no way I could have a "fld tAnswer" since that is not defined until after the user enters a number in the ask dialog.

And by the way, there is no filter to assure that only numbers are entered, but that is another story.

Anyway, I was able to put the result of the dialog into fld "arrayData", but the handler then stopped because there was no field with the name that the user (me) typed. The handler ran into what is known as a "runTime" error. LC does not know if an object is missing until it runs. This is in contrast toe a "compileTime" error, where syntax problems prevent LC from even being able to compile a script in the first place.

Bottom line, and I know you are still relatively new to LC, though your energy to learn and work is very satisfying, you have to ask yourself if what you are posting can be reasonably understood and tested by the others on this forum. Try to run what you post in a new stack. That will show you, for example, where certain referenced objects simply do not exist. That exercise alone might lead you to finding the errors. You might then post a modified handler that addresses the issues you think are tripping you up.

Keep at it!

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 » Mon May 08, 2023 7:36 pm

Continuing, though not addressing your original problem:

1- Why set the itemDelimiter?

2- Why first put tAnswer into fld "arrayData" and then right away put the text of fld tAnswer into fld "arrayData"?

And remember, there is no fld 'tAnswer", at least until the user sets its name. And recall what Klaus said, NEVER use a number to reference ANY control of ANY kind. LC uses numbers for that purpose all on its own, and you will be sorry if you do that. So never mind that you do not filter for numerical entry. Do something else to access certain fields of interest . If you want help with filtering for some other purpose, write back.

I recommend, since I see that using work order numbers might be very attractive, that you instead use numbers something like "W12345" and "W12346". That way you can still "reference numbers" but will not step on the toes of LC, which also is using numbers to identify controls. This only takes a little more work.

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”