Re: sort container parameters

2021-03-03 Thread Curry Kenworthy via use-livecode



Inline sort param variables:

If anyone files this bug report/feature request, let me know!
I will sign on

Best wishes,

Curry Kenworthy

Custom Software Development
"Better Methods, Better Results"
LiveCode Training and Consulting
http://livecodeconsulting.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: sort container parameters

2021-03-03 Thread Bob Sneidar via use-livecode
We used to call that, “polishing poop” which, according to Mythbusters is a 
thing. No, really.

Bob S


On Mar 3, 2021, at 2:02 PM, Paul Dupuis via use-livecode 
mailto:use-livecode@lists.runrev.com>> wrote:

Perhaps it is a compliment to Livecode/LCS that I EXPECTED it to work and was 
SURPRISED when it did not :-)

___
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: sort container parameters

2021-03-03 Thread Ken Ray via use-livecode
Craig,

It's because when you try to sort something, it's got to be a variable that's 
being sorted. So all of the examples you used put "toSort" into the statement 
to be "done" coming out compiled as:

sort items of "A,C,T,B" ascending

... which won't work. You need to execute:

do "sort items of toSort" && sortDir

which compiles to:

sort items of toSort ascending

... and that works.

:)


Ken Ray
Sons of Thunder Software, Inc.
Email: k...@sonsothunder.com
Website: https://www.sonsothunder.com


> On Mar 3, 2021, at 12:23 PM, Craig Newman via use-livecode 
>  wrote:
> 
> I thought I was pretty clever at using “do”, often going down several levels, 
>  evaluating the whole way before trying to execute a single  “do” statement.
> 
> Neither of the last lines seem to work:
> 
> on mouseup
> 
> put "A,C,T,B" into toSort
> 
> put "ascending" into sortDir
> 
> get "sort items of" && quote & toSort & quote && sortDir
> 
> breakpoint
> 
> --do it
> 
> --do "sort" && toSort && sortDir
> 
> do "sort" && quote & toSort & quote && sortDir
> 
> end mouseup
> 
> 
> I feel there must be a way…
> 
> Craig
> 
> 
>> On Mar 2, 2021, at 7:36 PM, Alex Tweedly via use-livecode 
>>  wrote:
>> 
>> The number of lines being sorted makes o difference.
>> 
>> The number of distinct sorts will - but at a single 'do' for each of 
>> "several hundreds", you'll not even notice except (maybe) if you are 
>> benchmarking it (around 5ms per 1000 'do's on an elderly MacBook Pro).
>> 
>> Alex.
>> 
>> On 02/03/2021 22:52, Paul Dupuis via use-livecode wrote:
>>> Okay. Thank you Ralph.
>>> 
>>> I was reluctant to use "do" for performance reasons. The sort could be 
>>> sorting a large number of lines - as many as several hundred sorts of a 
>>> thousand to ten thousand lines.
>>> 
>>> I could of course do timing trials, but does anyone from the mothership (or 
>>> anyone period) know if using "do" with a container sort causes any 
>>> appreciable performance hit? All the data is in a variable (vs fields).
>>> 
>>> 
>>> On 3/2/2021 5:19 PM, Ralph DiMola via use-livecode wrote:
 I found that you must us a "Do"(thank heaven for "Do"s) if you want to 
 make variable any LC token that colorizes like "stack", "the", "field", 
 "button", "put" or "ascending".
 
 I don't think "Do" is a kludge is this case.
 
 Ralph DiMola
 IT Director
 Evergreen Information Services
 rdim...@evergreeninfo.net
 
 -Original Message-
 From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On 
 Behalf Of Paul Dupuis via use-livecode
 Sent: Tuesday, March 02, 2021 4:56 PM
 To: use-livecode@lists.runrev.com
 Cc: Paul Dupuis
 Subject: sort container parameters
 
 I just discovered much to my dismay that you can not execute the following:
 
 put "ascending" into tDirection
 soft lines of tContainer tDirection international
 
 apparently neither the sort direction (ascending|descending) nor the sort 
 type (international|text|datetime|numeric|binary) can be variable!
 
 That means if you want to parameterize a sort direction, you have to do 
 something like:
 
 if tDirection is "ascending" then
sort lines of tContainer ascending international else
sort lines of tCOntainer descending international end if
 
 I see this a a bug or perhaps a failure to fully robust impliment the sort 
 container command? Does any one else see this as a bug?
 
 I suppose I could work around it with a "do" but that seems like a cludge
 
 do ("sort line of tContainer" && tDirection && tSortType)
 
 Thoughts? Comments? Opinions? Am I expecting too much of LiveCode to have 
 sort direction and type actual parameters?
 
 
 ___
 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
>>> 
>>> 
>>> ___
>>> 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: sort container parameters

2021-03-03 Thread Paul Dupuis via use-livecode
I love xTalk. While I have written code in many dozens of languages over 
my career, I personally will likely never code in anything other than 
xTalk for as long as I continue to write code.


That said, one of the "problems" of a programming language that is so 
intuitive is that I sometime write code that I expect to work ... and it 
doesn't. The container sort with params was one such instance.


Perhaps it is a compliment to Livecode/LCS that I EXPECTED it to work 
and was SURPRISED when it did not :-)



On 3/3/2021 1:00 PM, Richard Gaskin via use-livecode wrote:

Paul Dupuis wrote:

> I just discovered much to my dismay that you can not execute the
> following:
>
> put "ascending" into tDirection
> soft lines of tContainer tDirection international
>
> apparently neither the sort direction (ascending|descending) nor the
> sort type (international|text|datetime|numeric|binary) can be
> variable!
...
> I see this a a bug or perhaps a failure to fully robust impliment the
> sort container command? Does any one else see this as a bug?

Bug or feature?  The ambiguities introduced by the HyperTalk team have 
made that an evergreen question. ;)


Some tokens can be parameterized, others not.

MC/LC goes much further than HC in allowing object references to be a 
mix of literal and variable expressions, e.g.:


   -- Works in LC, not in HC:
   put the long id of this cd into tCdObj
   get the name of btn 1 of tCdObj

...but other expressions and keywords are not so clear.

Let's see what happens if we parameterize everything in your statement:

  put "ascending" into tDirection
  put "numeric" into tSortType
  put "items" into tChunkType
  put "1,2,3,4,5,6,7,8,9" into tData
  sort tChunkType of tData tSortType tDirection

In that last line, which variables should we expect to be allowed, and 
which ones not?


I'm certain there's a rule defining this.

I'm equally certain I've never met any xTalker who was able to intuit 
that rule with complete confidence.





___
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: sort container parameters

2021-03-03 Thread Craig Newman via use-livecode
I thought I was pretty clever at using “do”, often going down several levels,  
evaluating the whole way before trying to execute a single  “do” statement.

Neither of the last lines seem to work:

on mouseup

put "A,C,T,B" into toSort

put "ascending" into sortDir

get "sort items of" && quote & toSort & quote && sortDir

breakpoint

--do it

--do "sort" && toSort && sortDir

do "sort" && quote & toSort & quote && sortDir

end mouseup


I feel there must be a way…

Craig


> On Mar 2, 2021, at 7:36 PM, Alex Tweedly via use-livecode 
>  wrote:
> 
> The number of lines being sorted makes o difference.
> 
> The number of distinct sorts will - but at a single 'do' for each of "several 
> hundreds", you'll not even notice except (maybe) if you are benchmarking it 
> (around 5ms per 1000 'do's on an elderly MacBook Pro).
> 
> Alex.
> 
> On 02/03/2021 22:52, Paul Dupuis via use-livecode wrote:
>> Okay. Thank you Ralph.
>> 
>> I was reluctant to use "do" for performance reasons. The sort could be 
>> sorting a large number of lines - as many as several hundred sorts of a 
>> thousand to ten thousand lines.
>> 
>> I could of course do timing trials, but does anyone from the mothership (or 
>> anyone period) know if using "do" with a container sort causes any 
>> appreciable performance hit? All the data is in a variable (vs fields).
>> 
>> 
>> On 3/2/2021 5:19 PM, Ralph DiMola via use-livecode wrote:
>>> I found that you must us a "Do"(thank heaven for "Do"s) if you want to make 
>>> variable any LC token that colorizes like "stack", "the", "field", 
>>> "button", "put" or "ascending".
>>> 
>>> I don't think "Do" is a kludge is this case.
>>> 
>>> Ralph DiMola
>>> IT Director
>>> Evergreen Information Services
>>> rdim...@evergreeninfo.net
>>> 
>>> -Original Message-
>>> From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf 
>>> Of Paul Dupuis via use-livecode
>>> Sent: Tuesday, March 02, 2021 4:56 PM
>>> To: use-livecode@lists.runrev.com
>>> Cc: Paul Dupuis
>>> Subject: sort container parameters
>>> 
>>> I just discovered much to my dismay that you can not execute the following:
>>> 
>>> put "ascending" into tDirection
>>> soft lines of tContainer tDirection international
>>> 
>>> apparently neither the sort direction (ascending|descending) nor the sort 
>>> type (international|text|datetime|numeric|binary) can be variable!
>>> 
>>> That means if you want to parameterize a sort direction, you have to do 
>>> something like:
>>> 
>>> if tDirection is "ascending" then
>>> sort lines of tContainer ascending international else
>>> sort lines of tCOntainer descending international end if
>>> 
>>> I see this a a bug or perhaps a failure to fully robust impliment the sort 
>>> container command? Does any one else see this as a bug?
>>> 
>>> I suppose I could work around it with a "do" but that seems like a cludge
>>> 
>>> do ("sort line of tContainer" && tDirection && tSortType)
>>> 
>>> Thoughts? Comments? Opinions? Am I expecting too much of LiveCode to have 
>>> sort direction and type actual parameters?
>>> 
>>> 
>>> ___
>>> 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
>> 
>> 
>> ___
>> 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

___
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: sort container parameters

2021-03-03 Thread Richard Gaskin via use-livecode

Paul Dupuis wrote:

> I just discovered much to my dismay that you can not execute the
> following:
>
> put "ascending" into tDirection
> soft lines of tContainer tDirection international
>
> apparently neither the sort direction (ascending|descending) nor the
> sort type (international|text|datetime|numeric|binary) can be
> variable!
...
> I see this a a bug or perhaps a failure to fully robust impliment the
> sort container command? Does any one else see this as a bug?

Bug or feature?  The ambiguities introduced by the HyperTalk team have 
made that an evergreen question. ;)


Some tokens can be parameterized, others not.

MC/LC goes much further than HC in allowing object references to be a 
mix of literal and variable expressions, e.g.:


   -- Works in LC, not in HC:
   put the long id of this cd into tCdObj
   get the name of btn 1 of tCdObj

...but other expressions and keywords are not so clear.

Let's see what happens if we parameterize everything in your statement:

  put "ascending" into tDirection
  put "numeric" into tSortType
  put "items" into tChunkType
  put "1,2,3,4,5,6,7,8,9" into tData
  sort tChunkType of tData tSortType tDirection

In that last line, which variables should we expect to be allowed, and 
which ones not?


I'm certain there's a rule defining this.

I'm equally certain I've never met any xTalker who was able to intuit 
that rule with complete confidence.


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.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: sort container parameters

2021-03-02 Thread Curry Kenworthy via use-livecode



Paul:

> apparently neither the sort direction (ascending|descending)
> nor the sort type (international|text|datetime|numeric|binary)
> can be variable!

> I see this a a bug or perhaps a failure to fully
> robust impliment the sort container command?
> Does any one else see this as a bug?

Absolutely a bug or extremely annoying limitation!
I've been hating this for a long time.

> I suppose I could work around it with a "do"
> but that seems like a cludge

There has been no performance hit for "do" as a one-off.
So I don't mind using "do" once. I try to avoid it in loops.
Test, and you'll see that in your results.

Meanwhile "do" is arguably cleaner and smaller code than if/else.
But still a clumsy abomination compared to using an inline variable.

Any bug report on this issue gets my vote! Yes, it's a bad thing.

Best wishes,

Curry Kenworthy

Custom Software Development
"Better Methods, Better Results"
LiveCode Training and Consulting
http://livecodeconsulting.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: sort container parameters

2021-03-02 Thread Alex Tweedly via use-livecode

The number of lines being sorted makes o difference.

The number of distinct sorts will - but at a single 'do' for each of 
"several hundreds", you'll not even notice except (maybe) if you are 
benchmarking it (around 5ms per 1000 'do's on an elderly MacBook Pro).


Alex.

On 02/03/2021 22:52, Paul Dupuis via use-livecode wrote:

Okay. Thank you Ralph.

I was reluctant to use "do" for performance reasons. The sort could be 
sorting a large number of lines - as many as several hundred sorts of 
a thousand to ten thousand lines.


I could of course do timing trials, but does anyone from the 
mothership (or anyone period) know if using "do" with a container sort 
causes any appreciable performance hit? All the data is in a variable 
(vs fields).



On 3/2/2021 5:19 PM, Ralph DiMola via use-livecode wrote:
I found that you must us a "Do"(thank heaven for "Do"s) if you want 
to make variable any LC token that colorizes like "stack", "the", 
"field", "button", "put" or "ascending".


I don't think "Do" is a kludge is this case.

Ralph DiMola
IT Director
Evergreen Information Services
rdim...@evergreeninfo.net

-Original Message-
From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On 
Behalf Of Paul Dupuis via use-livecode

Sent: Tuesday, March 02, 2021 4:56 PM
To: use-livecode@lists.runrev.com
Cc: Paul Dupuis
Subject: sort container parameters

I just discovered much to my dismay that you can not execute the 
following:


put "ascending" into tDirection
soft lines of tContainer tDirection international

apparently neither the sort direction (ascending|descending) nor the 
sort type (international|text|datetime|numeric|binary) can be variable!


That means if you want to parameterize a sort direction, you have to 
do something like:


if tDirection is "ascending" then
    sort lines of tContainer ascending international else
    sort lines of tCOntainer descending international end if

I see this a a bug or perhaps a failure to fully robust impliment the 
sort container command? Does any one else see this as a bug?


I suppose I could work around it with a "do" but that seems like a 
cludge


do ("sort line of tContainer" && tDirection && tSortType)

Thoughts? Comments? Opinions? Am I expecting too much of LiveCode to 
have sort direction and type actual parameters?



___
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



___
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: sort container parameters

2021-03-02 Thread Bob Sneidar via use-livecode
If it is a lot to sort, I am wondering why not use a memory database with the 
indexes you need to sort by, or a file database if the data needs to be 
persistent?

Bob S


On Mar 2, 2021, at 2:52 PM, Paul Dupuis via use-livecode 
mailto:use-livecode@lists.runrev.com>> wrote:

Okay. Thank you Ralph.

I was reluctant to use "do" for performance reasons. The sort could be sorting 
a large number of lines - as many as several hundred sorts of a thousand to ten 
thousand lines.

I could of course do timing trials, but does anyone from the mothership (or 
anyone period) know if using "do" with a container sort causes any appreciable 
performance hit? All the data is in a variable (vs fields).

___
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: sort container parameters

2021-03-02 Thread Paul Dupuis via use-livecode

Okay. Thank you Ralph.

I was reluctant to use "do" for performance reasons. The sort could be 
sorting a large number of lines - as many as several hundred sorts of a 
thousand to ten thousand lines.


I could of course do timing trials, but does anyone from the mothership 
(or anyone period) know if using "do" with a container sort causes any 
appreciable performance hit? All the data is in a variable (vs fields).



On 3/2/2021 5:19 PM, Ralph DiMola via use-livecode wrote:

I found that you must us a "Do"(thank heaven for "Do"s) if you want to make variable any LC token that colorizes like "stack", 
"the", "field", "button", "put" or "ascending".

I don't think "Do" is a kludge is this case.

Ralph DiMola
IT Director
Evergreen Information Services
rdim...@evergreeninfo.net

-Original Message-
From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf Of 
Paul Dupuis via use-livecode
Sent: Tuesday, March 02, 2021 4:56 PM
To: use-livecode@lists.runrev.com
Cc: Paul Dupuis
Subject: sort container parameters

I just discovered much to my dismay that you can not execute the following:

put "ascending" into tDirection
soft lines of tContainer tDirection international

apparently neither the sort direction (ascending|descending) nor the sort type 
(international|text|datetime|numeric|binary) can be variable!

That means if you want to parameterize a sort direction, you have to do 
something like:

if tDirection is "ascending" then
sort lines of tContainer ascending international else
sort lines of tCOntainer descending international end if

I see this a a bug or perhaps a failure to fully robust impliment the sort 
container command? Does any one else see this as a bug?

I suppose I could work around it with a "do" but that seems like a cludge

do ("sort line of tContainer" && tDirection && tSortType)

Thoughts? Comments? Opinions? Am I expecting too much of LiveCode to have sort 
direction and type actual parameters?


___
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



___
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: sort container parameters

2021-03-02 Thread Ralph DiMola via use-livecode
I found that you must us a "Do"(thank heaven for "Do"s) if you want to make 
variable any LC token that colorizes like "stack", "the", "field", "button", 
"put" or "ascending".

I don't think "Do" is a kludge is this case. 

Ralph DiMola
IT Director
Evergreen Information Services
rdim...@evergreeninfo.net

-Original Message-
From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf Of 
Paul Dupuis via use-livecode
Sent: Tuesday, March 02, 2021 4:56 PM
To: use-livecode@lists.runrev.com
Cc: Paul Dupuis
Subject: sort container parameters

I just discovered much to my dismay that you can not execute the following:

put "ascending" into tDirection
soft lines of tContainer tDirection international

apparently neither the sort direction (ascending|descending) nor the sort type 
(international|text|datetime|numeric|binary) can be variable!

That means if you want to parameterize a sort direction, you have to do 
something like:

if tDirection is "ascending" then
   sort lines of tContainer ascending international else
   sort lines of tCOntainer descending international end if

I see this a a bug or perhaps a failure to fully robust impliment the sort 
container command? Does any one else see this as a bug?

I suppose I could work around it with a "do" but that seems like a cludge

do ("sort line of tContainer" && tDirection && tSortType)

Thoughts? Comments? Opinions? Am I expecting too much of LiveCode to have sort 
direction and type actual parameters?


___
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