Page 1 of 1
Is indirect addressing possible?
Posted: Wed Oct 24, 2018 10:56 pm
by ajperks
A text field is called Fld1
Can I put the text Fld1 into a variable and use that as the Field name?
It doesn't seem to work
Code: Select all
put "Fld1" into temp
put fld temp into fld "target"
Re: Is indirect addressing possible?
Posted: Wed Oct 24, 2018 11:02 pm
by ClipArtGuy
This is working as expected here in 9.01 on Ubuntu 18.04
Re: Is indirect addressing possible?
Posted: Thu Oct 25, 2018 12:13 am
by quailcreek
Work fine on my Mac.
Re: Is indirect addressing possible?
Posted: Thu Oct 25, 2018 2:56 am
by dunbarx
I don't see how any of that other stuff could work.
Two possibilities:
1-
Code: Select all
on mouseUp
put "Fld 1" into temp
put temp into fld 2
end mouseUp
This puts "Fld 1" into fld 2.
2-
Code: Select all
on mouseUp
put "Fld 1" into temp
do "put " && temp && "into fld 2"
end mouseUp
This puts the contents of fld 1 into fld 2.
Was any of that what was intended?
Craig Newman
Re: Is indirect addressing possible?
Posted: Thu Oct 25, 2018 3:34 am
by FourthWorld
The text of a field is a property, like width, height, and the others. While it's sometimes useful to be able to use the shorthand form of "put fld 1 into fld 2", the complete form of addressing a field property is useful here:
Code: Select all
put "MyFieldName" into tFld1
put the text of fld tFld1 into fld "SomeOtherField"
Re: Is indirect addressing possible?
Posted: Thu Oct 25, 2018 9:45 am
by ajperks
OK, I have found the problem.
The difference is between a software generated name and an explicit one when placed in a variable.
If the software generated name has invisible characters, the name you see is not the name the computer sees.
What I could do with is a quick running and clean bit of code that removes the letters Field from (say) Field2 (the clicked field and gives me the number 2 although the range might be up to and including 100) and no trailing spaces.
Re: Is indirect addressing possible?
Posted: Thu Oct 25, 2018 12:45 pm
by Klaus
If you tell us what you are trying to do, maybe we can come up with a smart solution.
Re: Is indirect addressing possible?
Posted: Thu Oct 25, 2018 5:19 pm
by FourthWorld
We move data between fields often. An example of a name containing characters preventing this, along with the code that isn't working, would be helpful.
Re: Is indirect addressing possible?
Posted: Fri Oct 26, 2018 10:04 am
by AxWald
Hi,
ajperks wrote: ↑Wed Oct 24, 2018 10:56 pm
Can I put the text Fld1 into a variable and use that as the Field name?
It doesn't seem to work
Code: Select all
put "Fld1" into temp
put fld temp into fld "target"
This works here (LC 6.7.10):
Code: Select all
put "myFldName" into myVar
put "Hussah!" into fld (myVar)
put fld (myVar)
This works, too:
Code: Select all
repeat with i = 1 to 4
set the textstyle of btn ("c" & i & "_btn") to "plain"
set the visible of grp ("G_" & i & "_grp") to false
The parentheses are not always required (i.e. sometimes it works w/o - just as with quotes for names), but help a lot to remember that this is a "constructed name".
For sure you must make certain that the name is spelled correctly - for this I omit anything but alphanumerics and "_" in my names, especially spaces.
At last, be sure to use the correct address - often it's a lacking "of me" or "of this cd" that causes confusion ...
Have fun!
Re: Is indirect addressing possible?
Posted: Fri Oct 26, 2018 12:01 pm
by ajperks
Hi, Indirect addressing fields is entirely possible but care is needed to avoid including any spaces or other invisible codes into the name. In my case, it was Field(space) a number (space) The trailing space caused a lot of problems.
I needed to address a column of 100 fields, all enclosed in a group with a vertical scroll bar. The Flds were Named Field 1 … Field 100.
The address was placed in a variable.