Page 1 of 1
Common name <> proper name [Solved]
Posted: Sat Jun 07, 2014 5:29 pm
by atout66
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:
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.
Re: Common name <> proper name
Posted: Sat Jun 07, 2014 6:51 pm
by dunbarx
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
Re: Common name <> proper name
Posted: Sat Jun 07, 2014 7:28 pm
by jacque
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
Re: Common name <> proper name
Posted: Sat Jun 07, 2014 8:00 pm
by atout66
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.
Re: Common name <> proper name [Solved]
Posted: Sat Jun 07, 2014 10:04 pm
by dunbarx
Ah. I did not pay attention to the first char of each word. Jacque did, though.
Craig
Re: Common name <> proper name [Solved]
Posted: Sun Jun 08, 2014 6:12 am
by jacque
@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.
