How to loop through stacks with same name?
J. Landman Gay
jacque at hyperactivesw.com
Thu Apr 6 13:13:11 EDT 2023
You're right, though I assumed the stack names would be sufficiently
unique. But your way is safer.
Regardless of the method, I have no idea why it isn't working for Håkan. It
should. Håkan, did you check your LC preferences in Files and Memory? Try
the various options.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
On April 6, 2023 7:00:29 AM Alex Tweedly via use-livecode
<use-livecode at lists.runrev.com> wrote:
> Jacque,
>
> those two code snippets do slightly different things - and I don't think
> either of them is doing exactly what's intended; I think the intent is
> to delete stack(s) called (exactly) "test".
>
> The first one will (wrongly) catch a stack called "testabc" or "abctest"
> - and then will fail on deleting 'test'.
>
> The second one also catches "testabc" - but in this case deletes it
> unintentionally.
>
> Alternatively, we could go straight to the point
>>
>> put the milliseconds into tStart
>> repeat forever
>> try
>> delete stack "test"
>> catch tmp
>> exit repeat
>> end
>> end repeat
>> answer the milliseconds - tStart
> again, the timings are overlapping - the variation between different
> runs far outweighs the difference between the methods. I think that
> could be different if there many other mainstacks in play, but I don't
> see that it would be significant in any realistic case.
>
> So pick the one that seems most easily read and understood :-)
>
> Alex.
>
> On 05/04/2023 20:27, J. Landman Gay via use-livecode wrote:
>> I just created four same-named stacks and ran my suggested handler
>> wrapped with timer commands. All four were deleted in 67 milliseconds.
>> LC 10.0.0 DP 4.
>>
>> put the milliseconds into tStart
>> repeat while "test" is in the mainstacks
>> delete stack "test"
>> end repeat
>> answer the milliseconds - tStart
>>
>> Ralph's idea to use filter is good too but slightly slower, at (a
>> fairly insignificant) 79 milliseconds:
>>
>> put the milliseconds into tStart
>> filter the mainstacks with "test*" into tStacks
>> repeat for each line l in tStacks
>> delete stack l
>> end repeat
>> answer the milliseconds - tStart
>>
>> On 4/5/23 10:15 AM, Bob Sneidar via use-livecode wrote:
>>> Whoa! No I'm not! There's over 300 mainstacks just from Livecode!
>>>
>>> Bob S
>>>
>>>
>>> On Apr 5, 2023, at 08:07, Bob Sneidar via use-livecode
>>> <use-livecode at lists.runrev.com> wrote:
>>>
>>> Oooh Pro Tip #276 from Jacque. I'm gonna use that one.
>>>
>>> Bob S
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at 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 at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list