Can you sort a Row Variable
Doug Easterbrook
doug at artsman.com
Mon Jun 8 10:28:54 EDT 2020
hi Michael.
I’m not sure sorting the columns alphabetically in a row (or a list) has much purpose internally.
so I’m guessing you are trying to display the contents of a row in some form to the user.
in a list, you can display as a headed list and then change the VIEW order of the columns using $displayorder on the headed list control
so if the columns are FieldZ, FieldA. you set the headed list’s $displayorder to 2,1 to see the fields in a different order than the list definition.
the key is that the internal list definition never changes — only the external display of it.
Row variables are super handy. We think of them as name-value pairs and pass them around methods as parameters. Far better than a long list of parameters where if you get one thing out of order, you have broken code.
in TMOBJS, there is a function called $makeparamrow that lets you add or replace values in the row, as well as combine two rows.
this is super handy for adding a new variable to the row that you pass to the next method.
so thats all about the contents of a row — and the need to use them
how do you display that the easiest way.
Me, I’d loop the row and load it into a list for display purposes since a single row is proably easiuer to view vertically than horizontally. and then you could sort the list columns.
eg
do list.$define(’Name’,’Value’)
for loop = 1 to row.$colcount
do List.$add(row.[loop].$name,row.[loop].$value)
end for
so list.$sort(’Name’,0)
now the list is sorted by name of field.
if you use TMOBJS, you could put that back into a row sorted by column if you want
newrow=null
for list.$line=1,list.$linecount
do TMOBJS.$makeparamrow(newrow,list.Name,list.value)
end for
and now the field names in newrow should be sorted alphabetically.
but then, as I mention, tailoring the internal representation of a row for external viewing - doesn’t make quite sense to me as I try to think of why I’d do it.
rows are just fantastic places to store name value pairs.
Doug Easterbrook
Arts Management Systems Ltd.
mailto:doug at artsman.com
http://www.artsman.com
Phone (403) 650-1978
> On June 8, 2020, at 5:24 AM, Michael Mantkowski <michaelj at clientrax.com> wrote:
>
> I have not used Row Variables that much. I am trying to sort a row of field
> names alphabetically to help someone find the field they want. I have tried
> several variations on the below and can't seem to get any of them to do
> anything. The docs seem to say the $sort is part of the notation for row
> variables but there are no examples. Lists are strait forward since you
> have column names, but I am not getting anywhere with the Row.
>
> Any help?
>
> Do iDataRow.$sort($ref.$cols.1,kFalse)
> Do $cinst.$redraw()
>
> *********************************************************************
> Michael Mantkowski
> ClienTrax Software
> 1-614-875-2245
> *********************************************************************
>
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
More information about the omnisdev-en
mailing list