get the name of a property given its synonym.

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
andresdt
Posts: 146
Joined: Fri Aug 16, 2019 7:51 pm

get the name of a property given its synonym.

Post by andresdt » Sun Jun 27, 2021 7:26 pm

Hello livecoders
I am wondering if there is any way to get the name of a property given one of its synonyms.
Example of "vis" get "visible".
Someone has a different idea than what I came up with.
Since what I came up with is to go to the dictionary and filter the properties and go one by one, see the ones that have a synonym and put all this in a function like the following

Code: Select all

function getSynonyms pName
         change pName
        
             case "rectangle"
                 return "rect"
                 break
            
             case "textdata"
                 return "text"
                 break
            
             case "vis"
                 return "visible"
                 break
            
             default
                 return pName
         end switch
end getSynonyms
a lot of work :oops: :oops:

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: get the name of a property given its synonym.

Post by bogs » Sun Jun 27, 2021 10:22 pm

Not sure I get what your trying to accomplish, or maybe I don't get why heh. Sorry, brain is feeling slow today. :oops:
Image

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

Re: get the name of a property given its synonym.

Post by dunbarx » Sun Jun 27, 2021 10:39 pm

Hi.

Your handler gets the synonyms, but only provided you already know them.

And you might want to say something like:

Code: Select all

case "rectangle"
case "rect"
                 return "rect,rectangle"
                 break
Are asking for a way to get them from the dictionary?

Craig

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: get the name of a property given its synonym.

Post by stam » Mon Jun 28, 2021 9:38 am

dunbarx wrote:
Sun Jun 27, 2021 10:39 pm
Hi.

Your handler gets the synonyms, but only provided you already know them.

And you might want to say something like:

Code: Select all

case "rectangle"
case "rect"
                 return "rect,rectangle"
                 break
Are asking for a way to get them from the dictionary?

Craig
That seems more robust as it can easily take plural forms where they apply...

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

Re: get the name of a property given its synonym.

Post by dunbarx » Mon Jun 28, 2021 1:08 pm

I did not even see the word "change", where a "switch" ought to be.

@andresdt. What was that, anyway?

And the point about plurals is well taken. You could add those to the case statements, I suppose.

But we are all wondering what your purpose is. Perhaps just an exercise in LC?

Craig

andresdt
Posts: 146
Joined: Fri Aug 16, 2019 7:51 pm

Re: get the name of a property given its synonym.

Post by andresdt » Tue Jun 29, 2021 12:57 am

Thanks to everyone for your replies
I'm going to try to explain myself better and put them in context a bit. First, my English is not the best, I just write LC jjj. The rest I entrust to the translator :oops: or @prometheus.

For about a year or two, @prometheus and I have been developing a library that allows us to use version controls in LC projects.

One of the many problems we had was.
Suppose we have an object with a constantly changing property, but we are not interested in saving those changes. Example a field where the username is placed. Well, we created a mechanism to tell our library to ignore the text property of that field. Or we can have an object that adjusts to the size of the stack when its dimensions change. In this case, we tell the library to ignore the rect of that object.

The problem here is that I can tell the library to ignore the "rect" of the object, but also tell it to ignore the "rectangle". In the end, the library has to be able to identify that it is the same property and choose a single name, rect in this case.

I don't know if I explain myself better now, in the end I created the function that solves the problem. The downside is that if in a version higher than 9.6.2 (which is the one I'm using), they incorporate another property with synonyms to the engine, this function will have to be refactored.

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

Re: get the name of a property given its synonym.

Post by dunbarx » Tue Jun 29, 2021 3:12 am

I think I see what you are getting at.

But you don't have to deal with that. The nice thing about synonyms is that they are interchangeable. You can mix and match synonyms at will, or, in fact, by accident, and nothing will happen.

I always use one form or the other, never changing. I do this because I just got used to one option. But if I ever accidentally substituted one for the other, I would never know it.

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”