Re: lineOffset wildcard

2021-04-19 Thread Mark Wieder via use-livecode



I'll try benchmarking this against Jacque's suggestion of matchChunk. 
Filter is normally pretty fast, but I'll have to use the regex version, 
and I'm not sure what the speed implications will be.


Benchmark result averages over 10 runs on a 2700-line script:

filter lines of script 2612.6ms
filter script  2572.1ms
matchChunk 2424.3ms

the code:

put "^local.*"&".*" into tRegexString

put matchChunk(tScript, tRegexString, tStartPos, tEndPos) into tFound?
if tFound? then
   put the number of lines in char 1 to tStartPos of tScript into tLine
end if

filter tScript with regex tRegexString into tFoundScript
# alternate: no appreciable difference in timing
# filter tScript with "local*"&"*" into tFoundScript
if tFoundScript is not empty then
   put lineoffset(tFoundScript, tScript) into tLine
end if

So matchChunk plus "the number of lines" is faster by ~150 milliseconds 
over 2700 lines of text than filter plus lineOffset.


--
 Mark Wieder
 ahsoftw...@gmail.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: lineOffset wildcard

2021-04-19 Thread Mark Wieder via use-livecode

On 4/19/21 1:02 PM, Ken Ray wrote:
On Apr 19, 2021, at 1:47 PM, Mark Wieder via use-livecode 
mailto:use-livecode@lists.runrev.com>> 
wrote:


On 4/19/21 11:04 AM, J. Landman Gay via use-livecode wrote:

I don't think lineoffset supports wildcards, but you could do it with 
matchChunk.


Ah! matchChunk and the the number of lines of... etc...
That should do it.


Another way to do it is to use 'filter' to get the text of the line that 
matches your wildcard, and then 'lineOffset' to find that line:


put tScript into tTemp
filter tTemp with ("local*" & tFunctionName & "*")
put lineOffset((cr & tTemp & cr),(cr & tScript & cr)) into tPos

Not sure if 'filter' is faster than 'matchChunk' when dealing with large 
scripts, but I have a feeling it might be...


Thanks, Ken.
I'll try benchmarking this against Jacque's suggestion of matchChunk. 
Filter is normally pretty fast, but I'll have to use the regex version, 
and I'm not sure what the speed implications will be.



--
 Mark Wieder
 ahsoftw...@gmail.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: lineOffset wildcard

2021-04-19 Thread Mark Wieder via use-livecode

On 4/19/21 3:02 PM, Bob Sneidar via use-livecode wrote:

IOC I guess I did misunderstand after all.


Nah... I should have worded it differently to start with.


--
 Mark Wieder
 ahsoftw...@gmail.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: lineOffset wildcard

2021-04-19 Thread Bob Sneidar via use-livecode
IOC I guess I did misunderstand after all.

Bob S


On Apr 19, 2021, at 12:32 PM, Mark Wieder via use-livecode 
mailto:use-livecode@lists.runrev.com>> wrote:

On 4/19/21 12:11 PM, Bob Sneidar via use-livecode wrote:
Someone needs to update the dictionary then.
wholeMatches
Syntax
set the wholeMatches to {true | false}
Summary
Specifies whether the lineOffset, wordOffset, and itemOffset functions search 
only for entire lines, words, or items.

Here's what I meant:

setting the wholeMatches to true will match the input string verbatim, without 
regard to wildcards. So

lineOffset("local tFunction", ttext) will only match
local tFunction
and
lineOffset("local*tFunction", tText) will only match
local*tFunction
not
local tFunction
and not
local someThing, tFunction, somethingElse

--
Mark Wieder
ahsoftw...@gmail.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: lineOffset wildcard

2021-04-19 Thread Ken Ray via use-livecode
> On Apr 19, 2021, at 1:47 PM, Mark Wieder via use-livecode 
>  wrote:
> 
> On 4/19/21 11:04 AM, J. Landman Gay via use-livecode wrote:
> 
>> I don't think lineoffset supports wildcards, but you could do it with 
>> matchChunk.
> 
> Ah! matchChunk and the the number of lines of... etc...
> That should do it.

Another way to do it is to use 'filter' to get the text of the line that 
matches your wildcard, and then 'lineOffset' to find that line:

put tScript into tTemp
filter tTemp with ("local*" & tFunctionName & "*")
put lineOffset((cr & tTemp & cr),(cr & tScript & cr)) into tPos

Not sure if 'filter' is faster than 'matchChunk' when dealing with large 
scripts, but I have a feeling it might be...


Ken Ray
Sons of Thunder Software, Inc.
Email: k...@sonsothunder.com
Website: https://www.sonsothunder.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: lineOffset wildcard

2021-04-19 Thread Mark Wieder via use-livecode

On 4/19/21 12:11 PM, Bob Sneidar via use-livecode wrote:

Someone needs to update the dictionary then.

wholeMatches

Syntax
set the wholeMatches to {true | false}

Summary
Specifies whether the lineOffset, wordOffset, and itemOffset functions search 
only for entire lines, words, or items.


Here's what I meant:

setting the wholeMatches to true will match the input string verbatim, 
without regard to wildcards. So


lineOffset("local tFunction", ttext) will only match
local tFunction
and
lineOffset("local*tFunction", tText) will only match
local*tFunction
not
local tFunction
and not
local someThing, tFunction, somethingElse

--
 Mark Wieder
 ahsoftw...@gmail.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: lineOffset wildcard

2021-04-19 Thread Bob Sneidar via use-livecode
Someone needs to update the dictionary then. 

wholeMatches

Syntax
set the wholeMatches to {true | false}

Summary
Specifies whether the lineOffset, wordOffset, and itemOffset functions search 
only for entire lines, words, or items.

Bob S

> On Apr 19, 2021, at 11:49 , Mark Wieder via use-livecode 
>  wrote:
> 
> On 4/19/21 11:13 AM, Bob Sneidar via use-livecode wrote:
>> Why even embed the function?
>> put "local" & tString & functionName() into tSearchString
>> set wholeMatches to true
>> put lineOffset(tSearchString) into tLine
>> Or am I misunderstanding the problem (again)? :-)
> 
> Been there.
> the wholematches doesn't affect the offset functions.
> 
> -- 
> Mark Wieder
> ahsoftw...@gmail.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: lineOffset wildcard

2021-04-19 Thread Mark Wieder via use-livecode

On 4/19/21 11:13 AM, Bob Sneidar via use-livecode wrote:

Why even embed the function?

put "local" & tString & functionName() into tSearchString
set wholeMatches to true
put lineOffset(tSearchString) into tLine

Or am I misunderstanding the problem (again)? :-)


Been there.
the wholematches doesn't affect the offset functions.

--
 Mark Wieder
 ahsoftw...@gmail.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: lineOffset wildcard

2021-04-19 Thread Mark Wieder via use-livecode

On 4/19/21 11:04 AM, J. Landman Gay via use-livecode wrote:

I don't think lineoffset supports wildcards, but you could do it with 
matchChunk.




Ah! matchChunk and the the number of lines of... etc...
That should do it.

--
 Mark Wieder
 ahsoftw...@gmail.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: lineOffset wildcard

2021-04-19 Thread Bob Sneidar via use-livecode
Why even embed the function? 

put "local" & tString & functionName() into tSearchString
set wholeMatches to true
put lineOffset(tSearchString) into tLine

Or am I misunderstanding the problem (again)? :-)

Bob S


> On Apr 19, 2021, at 11:04 , J. Landman Gay via use-livecode 
>  wrote:
> 
> On 4/19/21 11:29 AM, Mark Wieder via use-livecode wrote:
>> I'm sure I'm missing something simple here but...
>> I need to use a wildcard in the lineOffset function but I can't seem to find 
>> the correct invocation.
>> put lineoffset("local*", tScript) into tPos
>> always returns zero
>> put lineoffset(tFunctionName, tScript) into tPos
>> of course returns a line number, but possibly not the right one
>> put lineoffset("local"&, tScript) into tPos
>> gives me the correct line in some cases but fails for
>> local tSomeFunction,tOtherFunction
>> Can anyone give me the correct syntax for using a wildcard string as an 
>> argument to lineOffset? Thanks in advance - I've spent enough time on my own 
>> trying to figger this out.
> 
> I don't think lineoffset supports wildcards, but you could do it with 
> matchChunk.
> 
> -- 
> 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: lineOffset wildcard

2021-04-19 Thread J. Landman Gay via use-livecode

On 4/19/21 11:29 AM, Mark Wieder via use-livecode wrote:

I'm sure I'm missing something simple here but...

I need to use a wildcard in the lineOffset function but I can't seem to find the correct 
invocation.


put lineoffset("local*", tScript) into tPos
always returns zero

put lineoffset(tFunctionName, tScript) into tPos
of course returns a line number, but possibly not the right one

put lineoffset("local"&, tScript) into tPos
gives me the correct line in some cases but fails for
local tSomeFunction,tOtherFunction

Can anyone give me the correct syntax for using a wildcard string as an argument to lineOffset? 
Thanks in advance - I've spent enough time on my own trying to figger this out.




I don't think lineoffset supports wildcards, but you could do it with 
matchChunk.

--
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: lineOffset wildcard

2021-04-19 Thread Bob Sneidar via use-livecode
I think either matchText, or else wholematches used with some form of xOffset 
is what you want. 

Bob S


> On Apr 19, 2021, at 09:29 , Mark Wieder via use-livecode 
>  wrote:
> 
> I'm sure I'm missing something simple here but...
> 
> I need to use a wildcard in the lineOffset function but I can't seem to find 
> the correct invocation.
> 
> put lineoffset("local*", tScript) into tPos
> always returns zero
> 
> put lineoffset(tFunctionName, tScript) into tPos
> of course returns a line number, but possibly not the right one
> 
> put lineoffset("local"&, tScript) into tPos
> gives me the correct line in some cases but fails for
> local tSomeFunction,tOtherFunction
> 
> Can anyone give me the correct syntax for using a wildcard string as an 
> argument to lineOffset? Thanks in advance - I've spent enough time on my own 
> trying to figger this out.
> 
> -- 
> Mark Wieder
> ahsoftw...@gmail.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


___
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


lineOffset wildcard

2021-04-19 Thread Mark Wieder via use-livecode

I'm sure I'm missing something simple here but...

I need to use a wildcard in the lineOffset function but I can't seem to 
find the correct invocation.


put lineoffset("local*", tScript) into tPos
always returns zero

put lineoffset(tFunctionName, tScript) into tPos
of course returns a line number, but possibly not the right one

put lineoffset("local"&, tScript) into tPos
gives me the correct line in some cases but fails for
local tSomeFunction,tOtherFunction

Can anyone give me the correct syntax for using a wildcard string as an 
argument to lineOffset? Thanks in advance - I've spent enough time on my 
own trying to figger this out.


--
 Mark Wieder
 ahsoftw...@gmail.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