Changing fields properties with script

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
trags3
Posts: 331
Joined: Wed Apr 09, 2014 1:58 am
Location: Las Vegas, NV

Changing fields properties with script

Post by trags3 » Sat Feb 01, 2020 1:39 am

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

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3361
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Changing fields properties with script

Post by bn » Sat Feb 01, 2020 2:24 am

Hi Tom,

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
Kind regards
Bernd

trags3
Posts: 331
Joined: Wed Apr 09, 2014 1:58 am
Location: Las Vegas, NV

Re: Changing fields properties with script

Post by trags3 » Sat Feb 01, 2020 2:51 am

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

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3361
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Changing fields properties with script

Post by bn » Sat Feb 01, 2020 3:01 am

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
set the property of field dfld to someValue
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.
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

trags3
Posts: 331
Joined: Wed Apr 09, 2014 1:58 am
Location: Las Vegas, NV

Re: Changing fields properties with script

Post by trags3 » Sat Feb 01, 2020 3:02 am

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!
:oops: :oops: :oops: :oops:

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

Re: Changing fields properties with script

Post by dunbarx » Sat Feb 01, 2020 3:20 am

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

trags3
Posts: 331
Joined: Wed Apr 09, 2014 1:58 am
Location: Las Vegas, NV

Re: Changing fields properties with script

Post by trags3 » Sat Feb 01, 2020 4:34 am

Thanks Craig. Glad to know I’m not alone.
Tom

Post Reply

Return to “Talking LiveCode”