itemoffset & wholematches

2022-11-14 Thread jbv via use-livecode

Hi list,

I have a variable with a content of 3 lines as follows :
1   sombre  brunprofond
2   flouincertain
3   inexploré   mystérieux  inconnu

The separator between words is tab.
I want to check if a certain word is among the items as a whole.

The following script returns "6" :
   set itemdel to tab
   set the wholematches to false
   put itemoffset("incertain",myVar)

The following script returns "0" :
   set itemdel to tab
   set the wholematches to true
   put itemoffset("incertain",myVar)

The following script returns "7" :
   set itemdel to tab
   set the wholematches to true
   replace return with tab in myVar
   put itemoffset("incertain",myVar)

Scripts 1 & 3 are logical, but any logical explanation
for the result of script 2 ? Does it mean that the return
char after the word is considered as part of the word ?

Thanks in advance.
jbv

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: itemoffset & wholematches

2022-11-14 Thread Mike Kerner via use-livecode
 you set the itemDelimiter to tab. the  is part of the item.
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: itemoffset & wholematches

2022-11-14 Thread Mike Kerner via use-livecode
the easy way to fix this problem:
replace cr with tab in myVar -- but if the line endings matter, this isn't
great

On Mon, Nov 14, 2022 at 9:00 AM Mike Kerner 
wrote:

>  you set the itemDelimiter to tab. the  is part of the item.
>


-- 
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: itemoffset & wholematches

2022-11-14 Thread Bob Sneidar via use-livecode
Why not just use is among the items? 

Bob S


> On Nov 14, 2022, at 04:51 , jbv via use-livecode 
>  wrote:
> 
> Hi list,
> 
> I have a variable with a content of 3 lines as follows :
> 1 sombre  brunprofond
> 2 flouincertain
> 3 inexploré   mystérieux  inconnu
> 
> The separator between words is tab.
> I want to check if a certain word is among the items as a whole.
> 
> The following script returns "6" :
>   set itemdel to tab
>   set the wholematches to false
>   put itemoffset("incertain",myVar)
> 
> The following script returns "0" :
>   set itemdel to tab
>   set the wholematches to true
>   put itemoffset("incertain",myVar)
> 
> The following script returns "7" :
>   set itemdel to tab
>   set the wholematches to true
>   replace return with tab in myVar
>   put itemoffset("incertain",myVar)
> 
> Scripts 1 & 3 are logical, but any logical explanation
> for the result of script 2 ? Does it mean that the return
> char after the word is considered as part of the word ?
> 
> Thanks in advance.
> jbv
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: itemoffset & wholematches

2022-11-14 Thread Mike Kerner via use-livecode
that still won't work if the text is the last item of a line.
in the example, below, i've taken his original, replaced the tabs with
commas, and for the purpose of being able to read what's going on,
substituted the cr for a backslash, and added a line to substitute it back
for the test.

*put*
"1,sombre,burn,profound\2,flou,incertain\3,inexploré,mystériux,inconnu" into
 myVar

*replace* "\" with cr in myVar

*put* "profound" is among the items of myVar

On Mon, Nov 14, 2022 at 12:01 PM Bob Sneidar via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Why not just use is among the items?
>
> Bob S
>
>
> > On Nov 14, 2022, at 04:51 , jbv via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >
> > Hi list,
> >
> > I have a variable with a content of 3 lines as follows :
> > 1 sombre  brunprofond
> > 2 flouincertain
> > 3 inexploré   mystérieux  inconnu
> >
> > The separator between words is tab.
> > I want to check if a certain word is among the items as a whole.
> >
> > The following script returns "6" :
> >   set itemdel to tab
> >   set the wholematches to false
> >   put itemoffset("incertain",myVar)
> >
> > The following script returns "0" :
> >   set itemdel to tab
> >   set the wholematches to true
> >   put itemoffset("incertain",myVar)
> >
> > The following script returns "7" :
> >   set itemdel to tab
> >   set the wholematches to true
> >   replace return with tab in myVar
> >   put itemoffset("incertain",myVar)
> >
> > Scripts 1 & 3 are logical, but any logical explanation
> > for the result of script 2 ? Does it mean that the return
> > char after the word is considered as part of the word ?
> >
> > Thanks in advance.
> > jbv
> >
> > ___
> > use-livecode mailing list
> > use-livecode@lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>


-- 
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: itemoffset & wholematches

2022-11-14 Thread Bob Sneidar via use-livecode
oic. Odd use case. I suppose a lineOffset function followed by is among the 
items could be used. If he needs the lines to remain intact he could also 
replace cr with tab & cr first.

Bob S


On Nov 14, 2022, at 10:15 , Mike Kerner via use-livecode 
mailto:use-livecode@lists.runrev.com>> wrote:

that still won't work if the text is the last item of a line.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: itemoffset & wholematches

2022-11-14 Thread Alex Tweedly via use-livecode

That would deal with the last item in a line - but not the first.

Should do

   replace CR with TAB & CR & TAB in ...

and reverse later if needed.

Alex.

On 14/11/2022 18:43, Bob Sneidar via use-livecode wrote:

oic. Odd use case. I suppose a lineOffset function followed by is among the items 
could be used. If he needs the lines to remain intact he could also replace cr with 
tab & cr first.

Bob S


On Nov 14, 2022, at 10:15 , Mike Kerner via use-livecode 
mailto:use-livecode@lists.runrev.com>> wrote:

that still won't work if the text is the last item of a line.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: itemoffset & wholematches

2022-11-14 Thread J. Landman Gay via use-livecode

How about a one-liner:

put wordOffset("incertain",myVar)

If the words ever have punctuation attached, use trueWordOffset.

On 11/14/22 6:51 AM, jbv via use-livecode wrote:

Hi list,

I have a variable with a content of 3 lines as follows :
1    sombre    brun    profond
2    flou    incertain
3    inexploré    mystérieux    inconnu

The separator between words is tab.
I want to check if a certain word is among the items as a whole.

The following script returns "6" :
    set itemdel to tab
    set the wholematches to false
    put itemoffset("incertain",myVar)

The following script returns "0" :
    set itemdel to tab
    set the wholematches to true
    put itemoffset("incertain",myVar)

The following script returns "7" :
    set itemdel to tab
    set the wholematches to true
    replace return with tab in myVar
    put itemoffset("incertain",myVar)

Scripts 1 & 3 are logical, but any logical explanation
for the result of script 2 ? Does it mean that the return
char after the word is considered as part of the word ?


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: itemoffset & wholematches

2022-11-15 Thread jbv via use-livecode

Hi guys,
Thank you all for your answers.

Actually I thought that some "hierarchy"remained (items inside lines)
when using itemoffset, but obviously I was wrong.
I have about 6 variables to check, so I need my script to be as
fast as possible. I use "replace CR with TAB & CR & TAB in ...", but
as I need to get the exact itemoffset digit, I also need to count
how many items I have added and substract that number from the
result, which is quite cumbersome and slow...

To Jacqueline :
Thanks fro the suggestion, but I have to stick with items and
itemoffset, for some items can contain more that 1 word, like
"pied de biche"...

Le 2022-11-14 14:45, Alex Tweedly via use-livecode a écrit :

That would deal with the last item in a line - but not the first.

Should do

   replace CR with TAB & CR & TAB in ...

and reverse later if needed.

Alex.

On 14/11/2022 18:43, Bob Sneidar via use-livecode wrote:
oic. Odd use case. I suppose a lineOffset function followed by is 
among the items could be used. If he needs the lines to remain intact 
he could also replace cr with tab & cr first.





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: itemoffset & wholematches

2022-11-15 Thread Alex Tweedly via use-livecode

Hi,

I don't know if this will be faster, slower, or what !?! Something like 

  put myVar into tCopy
  replace CR with TAB in tCopy

  put itemoffset("incertain", tCopy) into tmp
  put the number of chars in item 1 to (tmp-1) of tCopy into tCharCount
  put the number of items in char 1 to tCharCount of myVar into 
theRealAnswer



Or, depending on what you do next, just go on using charOffset rather 
than itemOffset for the following code.



Alex.

On 15/11/2022 09:33, jbv via use-livecode wrote:

Hi guys,
Thank you all for your answers.

Actually I thought that some "hierarchy"remained (items inside lines)
when using itemoffset, but obviously I was wrong.
I have about 6 variables to check, so I need my script to be as
fast as possible. I use "replace CR with TAB & CR & TAB in ...", but
as I need to get the exact itemoffset digit, I also need to count
how many items I have added and substract that number from the
result, which is quite cumbersome and slow...

To Jacqueline :
Thanks fro the suggestion, but I have to stick with items and
itemoffset, for some items can contain more that 1 word, like
"pied de biche"...

Le 2022-11-14 14:45, Alex Tweedly via use-livecode a écrit :

That would deal with the last item in a line - but not the first.

Should do

   replace CR with TAB & CR & TAB in ...

and reverse later if needed.

Alex.

On 14/11/2022 18:43, Bob Sneidar via use-livecode wrote:
oic. Odd use case. I suppose a lineOffset function followed by is 
among the items could be used. If he needs the lines to remain 
intact he could also replace cr with tab & cr first.





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your 
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: itemoffset & wholematches

2022-11-15 Thread Bob Sneidar via use-livecode
If the data always contains the same number of items, I again highly recommend 
pushing everything to a memory based sqLite file then doing queries on it.

Bob S


On Nov 15, 2022, at 04:50 , Alex Tweedly via use-livecode 
mailto:use-livecode@lists.runrev.com>> wrote:

Hi,

I don't know if this will be faster, slower, or what !?! Something like 

  put myVar into tCopy
  replace CR with TAB in tCopy

  put itemoffset("incertain", tCopy) into tmp
  put the number of chars in item 1 to (tmp-1) of tCopy into tCharCount
  put the number of items in char 1 to tCharCount of myVar into theRealAnswer


Or, depending on what you do next, just go on using charOffset rather than 
itemOffset for the following code.


Alex.

On 15/11/2022 09:33, jbv via use-livecode wrote:
Hi guys,
Thank you all for your answers.

Actually I thought that some "hierarchy"remained (items inside lines)
when using itemoffset, but obviously I was wrong.
I have about 6 variables to check, so I need my script to be as
fast as possible. I use "replace CR with TAB & CR & TAB in ...", but
as I need to get the exact itemoffset digit, I also need to count
how many items I have added and substract that number from the
result, which is quite cumbersome and slow...

To Jacqueline :
Thanks fro the suggestion, but I have to stick with items and
itemoffset, for some items can contain more that 1 word, like
"pied de biche"...

Le 2022-11-14 14:45, Alex Tweedly via use-livecode a écrit :
That would deal with the last item in a line - but not the first.

Should do

   replace CR with TAB & CR & TAB in ...

and reverse later if needed.

Alex.

On 14/11/2022 18:43, Bob Sneidar via use-livecode wrote:
oic. Odd use case. I suppose a lineOffset function followed by is among the 
items could be used. If he needs the lines to remain intact he could also 
replace cr with tab & cr first.



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: itemoffset & wholematches

2022-11-15 Thread jbv via use-livecode

Again guys, thank you for your suggestions.

But finally I gave up using itemoffset and worked
with arrays instead, which is much much faster :
my script processes the 6 variables in less
than 15 secs.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode