Page 1 of 1

Changing fields properties with script

Posted: Sat Feb 01, 2020 1:39 am
by trags3
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

Re: Changing fields properties with script

Posted: Sat Feb 01, 2020 2:24 am
by bn
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

Re: Changing fields properties with script

Posted: Sat Feb 01, 2020 2:51 am
by trags3
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

Re: Changing fields properties with script

Posted: Sat Feb 01, 2020 3:01 am
by bn
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

Re: Changing fields properties with script

Posted: Sat Feb 01, 2020 3:02 am
by trags3
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:

Re: Changing fields properties with script

Posted: Sat Feb 01, 2020 3:20 am
by dunbarx
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

Re: Changing fields properties with script

Posted: Sat Feb 01, 2020 4:34 am
by trags3
Thanks Craig. Glad to know I’m not alone.
Tom