Is there an easy way to distinguish type of object

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
planix
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 47
Joined: Tue Mar 10, 2009 12:47 pm

Is there an easy way to distinguish type of object

Post by planix » Wed Mar 25, 2009 12:11 pm

Hi,

Simple question... I hope.

I have a piece of code that iterates through the fields on a card and clears the contents.

Problem: When I ran this it cleared the text entry field contents and deleted all the contents of the label fields as well :-(

Is there are simple way to distinguish a label field from a text entry field? I was hoping that there was a standard "type" property but I can't find it. Otherwise, I am guessing I will need to set up a custom property for each label field to make it non-deleteable.

Cheers
****************************************
PLANIX
"Knowing anything is better than knowing nothing. But knowing that nothing ain't anything, why that's just plain nirvana."

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Wed Mar 25, 2009 1:32 pm

Hi Planix,

well, a field is a field be it "Label" or Text entry" :-)

But both have different properties that you could check:
Here the two main differences in the DEFAULT properties, which can of course be changed/modified!
(L = Label, TE = Text entry)

"showborder"
L = false
TE = true

"locktext"
L = true
TE = false

Maybe this is the prop for you to check!
...
if the locktext of fld XYZ <> true then
## probably NOT a "Label" field!
put empty into fld XYZ
end if
...

You get the picture :-)


Best from germany

Klaus

planix
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 47
Joined: Tue Mar 10, 2009 12:47 pm

Post by planix » Thu Mar 26, 2009 1:58 am

Thanks Klaus,

In the end I got around it because I don't name label fields. So they all have the default name "Label Field". So, I just checked each field in the repeat loop as to whether it contained the word "label"

Code: Select all

if the name of this field contains "Label" then
   next repeat
end if
Simple enough but I think it would be better if labels were a separate object from fields or there was a type property somewhere.

Cheers
****************************************
PLANIX
"Knowing anything is better than knowing nothing. But knowing that nothing ain't anything, why that's just plain nirvana."

Post Reply