Re: How to find the offset of the first character in a string that's not a tab?

2021-01-21 Thread Dick Kriesel via use-livecode


> On Jan 21, 2021, at 2:34 AM, Keith Clarke via use-livecode 
>  wrote:

> I was just keen to understand why offset wasn’t happy with the ‘not(tab)’ in 
> this instance.

expression "not(tab)" evaluates to true, which doesn’t serve your purpose

— Dick


___
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: How to find the offset of the first character in a string that's not a tab?

2021-01-21 Thread Dick Kriesel via use-livecode


> On Jan 21, 2021, at 2:25 AM, Dick Kriesel via use-livecode 
>  wrote:
> 
> Hi, Keith.  You could test each character until you find a tab:
> 
correction: until you find one that’s not a tab


___
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: How to find the offset of the first character in a string that's not a tab?

2021-01-21 Thread Dick Kriesel via use-livecode

> On Jan 21, 2021, at 1:30 AM, Keith Clarke via use-livecode 
> mailto:use-livecode@lists.runrev.com>> wrote:
> 
> Please can anyone advise on the correct syntax for trying to find the first 
> non-tab character offset in a string

Hi, Keith.  You could test each character until you find a tab:

function offsetOfNotTab pString
 local i
 repeat for each char tChar in pString
add 1 to i
if tChar <> tab then return i
 end repeat
end offsetOfNotTab

— Dick
___
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: directory tree -> array

2020-02-01 Thread Dick Kriesel via use-livecode

> On Jan 22, 2020, at 10:17 AM, Richard Gaskin via use-livecode 
>  wrote:
> 
> I stumbled across a code challenge for y'all, one that seems seductively 
> simple but I don't think it is:
> 
> What is the simplest way to build an array that reflects the files and 
> folders within a given folder?
> 
> There's a discussion about this here:
> 
> https://forums.livecode.com/viewtopic.php?f=7=33565
> 
> 
> On Jan 22, 2020, at 10:26 AM, Richard Gaskin via use-livecode 
>  wrote:

> 
> We have many handlers that deliver directory trees as lists, but arrays are a 
> different beast.  Because the depth is both unknowable and varied, I can't 
> think of a way to do this without resorting to "do".



Since that thread vanished last week, and hasn’t returned, I'm offering help 
here instead.

The list of full paths contains enough information to build an array 
representation of the directory tree.


/**

Summary: Given a list of full paths, and given the partial path they share, 
build an array representing the directory structure

pPaths: a return-delimited list of full paths

pPath: the path that was used to generate the list of full paths

Returns (array): A array with a branch node for each folder and a leaf node for 
each file

Description: Eliminate pPath from every line of pPaths. Then insert each line 
into an array.

email subject "directory tree -> array"

forum topic "f=7=33565"

*/


function arrayFromPaths pPaths, pPath -- a list of full paths, and the path 
that was used to generate the list

local tPaths, tFile, tArray

set the itemDelimiter to "/"


put char 2 to -1 of replaceText( cr & pPaths, cr & pPath & slash, cr ) into 
tPaths -- eliminate pPath from every full path

repeat for each line tPath in tPaths -- insert each file name into the array

put the last item of tPath into tFile

delete the last item of tPath

if tPath is empty then -- the file is in folder pPath

put "true" into tArray[ tFile ]

else -- the file is in a folder in folder pPath

split tPath by slash

put "true" into tArray[ tPath ][ tFile ]

end if

end repeat


return tArray

end arrayFromPaths


on mouseUp

local tPaths = "a/b/c,a/b/d/e,a/b/d/f" -- folder a/b contains file c and folder 
d, which contains files e and f

local tPath = "a/b" -- the shared partial path

replace comma with cr in tPaths


get arrayFromPaths( tPaths, tPath )


breakpoint

end mouseUp




If the topic reappears soon, I’ll repost there because reading code is easier 
there.

By, the way, thanks to RG for the bug report on my earlier posting in the 
now-vanished thread.

— Dick



___
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: valueDiff for arrays?

2018-08-07 Thread Dick Kriesel via use-livecode

> On Aug 7, 2018, at 9:29 PM, Jerry Jensen via use-livecode 
>  wrote:
> 
>> On Aug 7, 2018, at 8:35 PM, Mark Wieder via use-livecode 
>>  wrote:
>> 
>> On 08/07/2018 07:57 PM, Dick Kriesel via use-livecode wrote:
>>> On Aug 7, 2018, at 5:47 PM, Alex Tweedly via use-livecode 
>>>  wrote:
>>>> 
>>>> Is there an easy way to test whether an array is (currently) a sequence 
>>>> array ?
>>>> 
>>>> something easier than
>>>> put the extents of tArray into tmp
>>>> if item 1 of tmp = 1 AND item 2 of tmp = the number of elements in tArray 
>>>> then
>>> slightly easier, at least:
>>> function isSequence p
>>> return the extents of p is 1, number of elements in p
>>> end isSequence
>> 
>> If I'm understanding things right there's more to it:
>> The keys all have to be integers and (I think) only those integers from 1 to 
>> (the number of keys).
> 
> That was my understanding as well.
> .Jerry

"the extents" implements those rules, so "isSequence" doesn’t need to.

Or is there evidence "isSequence" fails?

— Dick
___
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: valueDiff for arrays?

2018-08-07 Thread Dick Kriesel via use-livecode
On Aug 7, 2018, at 5:47 PM, Alex Tweedly via use-livecode 
 wrote:
> 
> Is there an easy way to test whether an array is (currently) a sequence array 
> ?
> 
> something easier than
> put the extents of tArray into tmp
> if item 1 of tmp = 1 AND item 2 of tmp = the number of elements in tArray 
> then

slightly easier, at least:
function isSequence p

return the extents of p is 1, number of elements in p

end isSequence

— Dick
___
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: Sender of send in time

2018-07-14 Thread Dick Kriesel via use-livecode


> On Jul 13, 2018, at 1:26 AM, hh via use-livecode 
>  wrote:
> 
>> Bob S. wrote:
>> Something in my scripts is sending a selectionChanged message in
>> time to a specific datagrid when it shouldn't. How do I determine 
>> the sender of a send in time message?
> 
> Simply use a a parameter:
> 
> send "selectionChanged " to  in 
> 
> where  identifies the sender.
> 

Or, if you don’t want to create such parameters to identify your senders, you 
could use the executionContexts:

send "selectionChanged item 2 of line -1 of the executionContexts" to 
 in 

Or, if you want to reduce clutter in your many senders, you could just:

send "selectionChanged the executionContexts" to  in 

— Dick


___
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: Behaviors not honoring script local variables??

2018-06-27 Thread Dick Kriesel via use-livecode
> On Jun 26, 2018, at 1:13 PM, Bob Sneidar via use-livecode 
>  wrote:
> ...
> do "put " & quote &  aStackConstants [tConstant] & quote & " into " & 
> tConstant

Hi, Bob.  If you wanted simpler code, that could be just

 do "put aStackConstants[ tConstant ] into " & tConstant

— Dick
___
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: Q on Accessing multi-dimension arrays.

2018-04-26 Thread Dick Kriesel via use-livecode

> On Apr 26, 2018, at 12:14 PM, Brian Milby via use-livecode 
> > wrote:
> 
> tPath can also be thought of as a (proper) list which makes a little more
> sense. Mark W would need to answer the why.

The following excerpts provide a quote from Mark W:

> On Mar 12, 2012, at 10:19 AM, Pete wrote:
> 
>> I'm wondering how you found about about this key values array feature?  I
>> can't find any mention of it in the dictionary or the reference manual and
>> it sure seems like something that should be known!
> 


> On Mar 12, 2012, at 1:18 PM, Dick Kriesel  > wrote:
> 
> I found it while looking through bug reports for arrays, in 
>  > dated 2008-11-28.  So, 
> thanks be to Mark Waddingham and David Bovill for that.
> 
> For convenience, here's Mark's reply to David:
> 
> Thanks for the suggestion.
> 
> This is on the list to include for the next version. In that version with:
>  put tValue into tArray[tKey]
> (indeed anywhere you can currently do tArray[tKey])
> 
> The meaning of 'tKey' will be extended:
>  1) If it is a string then it is as it is now
>  2) If it is a numerically keyed array starting at 1, then it will mean:
>   put tValue into tArray[tKey[1]][tKey[2]]...[tKey[n]]
> where  is the number of elements in tKey
>  3) Otherwise it is an error.
> 
> This will allow you to construct an array containing the path to the key you
> want to modify/fetch/delete dynamically.
> 
> I agree, the feature's worth adding into the dictionary and manual.
> 
> -- Dick



___
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