Common name <> proper name [Solved]

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
atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Common name <> proper name [Solved]

Post by atout66 » Sat Jun 07, 2014 5:29 pm

Hi to all,

If I have a string with these 2 lines:

Code: Select all

put "Paris,proper name"&cr&"paris,conjugated verb" into myStg
How can I make the difference between the two with the function:

Code: Select all

get lineOffset("paris",myStg)
Try this in the commandWindow to see what I mean:

Code: Select all

put "Paris,proper name"&cr&"paris,conjugated verb" into myStg
    get lineOffset("paris",myStg)
put IT
IT returns 1 which is for the proper name. But I search for the conjugated verb.
Even if I write first "set the wholeMatches to true", IT returns 0
Thanks for your help, Jean-Paul.
Last edited by atout66 on Sat Jun 07, 2014 8:01 pm, edited 1 time in total.
Discovering LiveCode Community 6.5.2.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10335
Joined: Wed May 06, 2009 2:28 pm

Re: Common name <> proper name

Post by dunbarx » Sat Jun 07, 2014 6:51 pm

Hi.

Several ways to do this, and an array is the most compact, but if you always have the same format, that is, the conjugated verb is always the second line of each variable instance, then you do not have to be clever, just exploitative:

get lineOffset("paris",myStg) + 1.

You could write a function that either gets the first or second line, depending on which type you needed.

Now this seems almost like cheating, and it is. But there is nothing wrong with that, exceept that it is sort of a balancing act, and not terribly robust, never mind stable and easy to manage.

So my question to you is this. Does each pair of words reside in its own variable, or is there one variable containing a long return delimited list of pairs, noun1/verb1/noun2/verb2, etc.? Write back, and we can find more elegant ways to work this.

Craig Newman

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Common name <> proper name

Post by jacque » Sat Jun 07, 2014 7:28 pm

Check for case sensitivity:

Code: Select all

put "Paris,proper name"&cr&"paris,conjugated verb" into myStg
set the casesensitive to true
get lineOffset("paris",myStg)
put IT
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Common name <> proper name

Post by atout66 » Sat Jun 07, 2014 8:00 pm

The casesensitive ! That's exactly what I was looking for.
@ Craig, no I don't have always the same format but with caseSensitive everything is going much easier;-)
Thanks a lot to both of you.
Kind regards, Jean-Paul.
Discovering LiveCode Community 6.5.2.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10335
Joined: Wed May 06, 2009 2:28 pm

Re: Common name <> proper name [Solved]

Post by dunbarx » Sat Jun 07, 2014 10:04 pm

Ah. I did not pay attention to the first char of each word. Jacque did, though.

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Common name <> proper name [Solved]

Post by jacque » Sun Jun 08, 2014 6:12 am

@Craig: The problem with being as familiar with xtalk as you and I are is that we're spoiled about capitalization. If you add the fact that Macs don't much care about it either, we're doubly cursed. When I get on a Linux server or a mobile device I'm constantly tripped up by that. I think the number of times I've been bitten has terrorized me into compliance. ;)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply