Changing fields properties with script
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Changing fields properties with script
Hi,
I need to change the visible property of some fields using script.
The fields are named ab1,ab2,ab3 ....
I have tried numerous versions of this basic code.
Before I put it in a loop I just tried 1 field.
on mouseUp
put "1" into x
put "ab" & x into dfld
answer dfld -- the answer comes back ab1
show fld"&dfld" of this card
OR ALTERNATELY
set the visible of fld"&dfld" to true
end mouseUp
I messed around with several alternatives to the fld designation to no avail.
Tom
I need to change the visible property of some fields using script.
The fields are named ab1,ab2,ab3 ....
I have tried numerous versions of this basic code.
Before I put it in a loop I just tried 1 field.
on mouseUp
put "1" into x
put "ab" & x into dfld
answer dfld -- the answer comes back ab1
show fld"&dfld" of this card
OR ALTERNATELY
set the visible of fld"&dfld" to true
end mouseUp
I messed around with several alternatives to the fld designation to no avail.
Tom
-
- VIP Livecode Opensource Backer
- Posts: 4003
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Changing fields properties with script
Hi Tom,
try
Kind regards
Bernd
try
Code: Select all
on mouseUp
put "ab" into dfld
put dfld & "1" into dfld
set the visible of field dfld to not the visible of field dfld
end mouseUp
Bernd
Re: Changing fields properties with script
Hi Bernd,
Sorry but that doesn't work. I am using LC 9.5.1 on a Windows 10 Computer. I haven't tried on my Mac but I am suspicious that the Computer is the culprit. I rarely go to the MS product for these things.
I'll try on the Mac!
Thank You for the answer.
Tom
Sorry but that doesn't work. I am using LC 9.5.1 on a Windows 10 Computer. I haven't tried on my Mac but I am suspicious that the Computer is the culprit. I rarely go to the MS product for these things.
I'll try on the Mac!
Thank You for the answer.
Tom
-
- VIP Livecode Opensource Backer
- Posts: 4003
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Changing fields properties with script
Hi Tom,
the point I wanted to make is that you put the name of the field into a variable which you build on the fly. That is all fine. The important point is how you address the field
The code I posted was tested with one field and one button. It worked. And this should not depend on the operating system LC is running on.
Kind regards
Bernd
the point I wanted to make is that you put the name of the field into a variable which you build on the fly. That is all fine. The important point is how you address the field
note there is not quotes and no ampersand in the quotes. As soon as you put quotes around a variable it is no longer a variable but a literal.set the property of field dfld to someValue
The code I posted was tested with one field and one button. It worked. And this should not depend on the operating system LC is running on.
Kind regards
Bernd
Re: Changing fields properties with script
Hi Bernd,
Boy do I feel stupid!
The objects I have been trying to work with are NOT FIELDS they are GRAPHICS.
Everything works like clockwork now. (even on the WIn 10)
Thank You Bernd!
Boy do I feel stupid!
The objects I have been trying to work with are NOT FIELDS they are GRAPHICS.
Everything works like clockwork now. (even on the WIn 10)
Thank You Bernd!
-
- VIP Livecode Opensource Backer
- Posts: 9670
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Changing fields properties with script
Don't feel too bad. Many times I have gone down to the character level trying to figure out why my code does not work, only to find there was nothing wrong after all. I was addressing the wrong type of control.
Craig
Craig
Re: Changing fields properties with script
Thanks Craig. Glad to know I’m not alone.
Tom
Tom