RE: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-28 Thread DAVID WADEMAN
I can see that there can be better sorting methods out there, and
possible faster. I see some places that uses c sort and locate methods
for uses 1+ records and using bubble method could be fatal to the
system. At most we used this subroutine couple times a year for certain
applications and if that for under 1000 records. At times, we just used
BY @ID or @I-TYPE for sorting. 





-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of MAJ Programming
Sent: Friday, July 25, 2008 10:04 AM
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] Basic SORT() Function not avail in UniVerse?

Given my age, I've used many manual sort methods (including bubble)
years
and years ago.

Ever since I could LOCATE with the optional sorting parameter, I've
never
put a bubble sort in MV programs. VB and QB yes. MV, No.

My 2 cents.
Mark Johnson
- Original Message -
From: DAVID WADEMAN [EMAIL PROTECTED]
To: u2-users@listserver.u2ug.org
Sent: Tuesday, July 22, 2008 12:59 PM
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?


 This is a UniData subroutine, but should work 

 SUBROUTINE B42.SORT.ARRAY(SORTED,ARRAY)
 * Bubble sort the elements of a dynamic array
 * Created by: David Wademan
 * Creation Date: 01/05/05
 SORTED=
 VALUES = DCOUNT(ARRAY,@VM)
 LOOP
CHANGES = 0
FOR X = 2 TO VALUES
   * For each adjacent pair
   ELEMENT1 = ARRAY1,X-1
   ELEMENT2 = ARRAY1,X

   IF ELEMENT2  ELEMENT1 THEN
  * Swap if pair out of sequence
  ARRAY1,X = ELEMENT1
  ARRAY1,X-1 = ELEMENT2
  CHANGES = 1
   END
NEXT X
 WHILE CHANGES DO REPEAT
 SORTED=ARRAY
 RETURN

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Baker Hughes
 Sent: Tuesday, July 22, 2008 10:51 AM
 To: 'u2-users@listserver.u2ug.org'
 Subject: [U2] Basic SORT() Function not avail in UniVerse?

 Hey,

 I'm needing to SORT a dynamic array and apparently UniVerse doesn't
have
 this
 Function.

 Other MV implementations have this, such as D3 - The sort() function
 sorts an
 attribute or value mark delimited str.exp in ascending order. [from
 ePick]

 There was also a user exit u1072 that did the same thing.

 Does anyone have a work around or fast path to same thing  maybe
I'm
 missing something but can't see this in UV docs.

 -Baker
 ---
 u2-users mailing list
 u2-users@listserver.u2ug.org
 To unsubscribe please visit http://listserver.u2ug.org/
 ---
 u2-users mailing list
 u2-users@listserver.u2ug.org
 To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-26 Thread Anthony W. Youngman
In message [EMAIL PROTECTED], MAJ 
Programming [EMAIL PROTECTED] writes

I don't think that the sort/extract function alone is justification for
choosing dim arrays over dynamic arrays in programs.

Sure, for large array concepts/projects, DIM will prevail. But IMHO, for
data READ/WRITE, dynamic appears just as fast as DIM.


Not knowing the internals, I can't be sure, but this is where I would 
expect dynamic to be faster. After all, a record is stored on disk as a 
dynamic array, isn't it, so the conversion to/from DIM will be an 
overhead...


Cheers,
Wol
--
Anthony W. Youngman [EMAIL PROTECTED]
'Yings, yow graley yin! Suz ae rikt dheu,' said the blue man, taking the
thimble. 'What *is* he?' said Magrat. 'They're gnomes,' said Nanny. The man
lowered the thimble. 'Pictsies!' Carpe Jugulum, Terry Pratchett 1998
Visit the MaVerick web-site - http://www.maverick-dbms.org Open Source Pick
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-25 Thread MAJ Programming
Given my age, I've used many manual sort methods (including bubble) years
and years ago.

Ever since I could LOCATE with the optional sorting parameter, I've never
put a bubble sort in MV programs. VB and QB yes. MV, No.

My 2 cents.
Mark Johnson
- Original Message -
From: DAVID WADEMAN [EMAIL PROTECTED]
To: u2-users@listserver.u2ug.org
Sent: Tuesday, July 22, 2008 12:59 PM
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?


 This is a UniData subroutine, but should work 

 SUBROUTINE B42.SORT.ARRAY(SORTED,ARRAY)
 * Bubble sort the elements of a dynamic array
 * Created by: David Wademan
 * Creation Date: 01/05/05
 SORTED=
 VALUES = DCOUNT(ARRAY,@VM)
 LOOP
CHANGES = 0
FOR X = 2 TO VALUES
   * For each adjacent pair
   ELEMENT1 = ARRAY1,X-1
   ELEMENT2 = ARRAY1,X

   IF ELEMENT2  ELEMENT1 THEN
  * Swap if pair out of sequence
  ARRAY1,X = ELEMENT1
  ARRAY1,X-1 = ELEMENT2
  CHANGES = 1
   END
NEXT X
 WHILE CHANGES DO REPEAT
 SORTED=ARRAY
 RETURN

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Baker Hughes
 Sent: Tuesday, July 22, 2008 10:51 AM
 To: 'u2-users@listserver.u2ug.org'
 Subject: [U2] Basic SORT() Function not avail in UniVerse?

 Hey,

 I'm needing to SORT a dynamic array and apparently UniVerse doesn't have
 this
 Function.

 Other MV implementations have this, such as D3 - The sort() function
 sorts an
 attribute or value mark delimited str.exp in ascending order. [from
 ePick]

 There was also a user exit u1072 that did the same thing.

 Does anyone have a work around or fast path to same thing  maybe I'm
 missing something but can't see this in UV docs.

 -Baker
 ---
 u2-users mailing list
 u2-users@listserver.u2ug.org
 To unsubscribe please visit http://listserver.u2ug.org/
 ---
 u2-users mailing list
 u2-users@listserver.u2ug.org
 To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-25 Thread MAJ Programming
Sidebar:
If we're concerned for speed, then don't have the DCOUNT in the end value of
a FOR...NEXT loop. Set the variable once before the loop.

example:

LAST=DCOUNT(ITAB,@AM)
FOR X=1 TO LAST

Mark Johnson
- Original Message -
From: Dave Laansma [EMAIL PROTECTED]
To: u2-users@listserver.u2ug.org
Sent: Wednesday, July 23, 2008 10:35 AM
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?


 I'd suggest this subroutine.  Brief and to the point:

   SUBROUTINE HUB.SORT.B (ITAB)

   OTAB = 

   FOR X = 1 TO DCOUNT(ITAB,@AM)
 ELEM = ITABX
 LOCATE ELEM IN OTAB BY AL SETTING PLACE ELSE NULL
 OTAB = INSERT(OTAB,PLACE;ELEM)
   NEXT X

   ITAB = OTAB

 

   RETURN

   END

 David Laansma
 IT Manager
 Hubbard Supply Co.
 Direct: 810-342-7143
 Office:810-234-8681
 Fax: 810-234-6142
 www.hubbardsupply.com
 Delivering Products, Services, and Innovative Solutions

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Jeff Marcos
 Sent: Tuesday, July 22, 2008 7:35 PM
 To: u2-users@listserver.u2ug.org
 Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

 We had the same issue back in the 90's. So a clever guy (Ed) that worked
 with us wrote a small C program (on Unix) to do the sort. This also
 included controlling/dependants fields. Any universe program could call
 it, passing in the variables and returned the items sorted.

 Speed is incredible. To this day it's still used and blitzes any
 universe program methods in sorting large arrays.

 Regards,
 Jeff Marcos

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Allen E. Elwood
 Sent: Wednesday, 23 July 2008 6:59 AM
 To: u2-users@listserver.u2ug.org
 Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

 Hey, and don't forget to do a speed test.  You know, because LOCATE is
 coded
 as part of the OS it just *might* be faster than bubble or speed sort
 options.

 In fact, this was a topic on this list about 3 or 4 years ago and
 someone
 doing the speed test concluded LOCATE was in fact faster.

 And no I don't remember who it was, or have a link to the thread (sorry)

 :-)

 Allen

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Behalf Of Israel, John R.
 Sent: Tuesday, July 22, 2008 10:26
 To: 'u2-users@listserver.u2ug.org'
 Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?


 Note that if the array is big, you would get much better performance by
 loading it into a DIM array, so the sort of sort below, then put the
 results
 back into a dynamic array.

 Dynamic arrays are much easier to use, but when used wisely, dimensioned
 arrays can be MUCH faster.  This is true for any application, esp.
 looping
 through multi-values.

 John Israel


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of DAVID WADEMAN
 Sent: Tuesday, July 22, 2008 1:00 PM
 To: u2-users@listserver.u2ug.org
 Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

 This is a UniData subroutine, but should work 

 SUBROUTINE B42.SORT.ARRAY(SORTED,ARRAY)
 * Bubble sort the elements of a dynamic array
 * Created by: David Wademan
 * Creation Date: 01/05/05
 SORTED=
 VALUES = DCOUNT(ARRAY,@VM)
 LOOP
CHANGES = 0
FOR X = 2 TO VALUES
   * For each adjacent pair
   ELEMENT1 = ARRAY1,X-1
   ELEMENT2 = ARRAY1,X

   IF ELEMENT2  ELEMENT1 THEN
  * Swap if pair out of sequence
  ARRAY1,X = ELEMENT1
  ARRAY1,X-1 = ELEMENT2
  CHANGES = 1
   END
NEXT X
 WHILE CHANGES DO REPEAT
 SORTED=ARRAY
 RETURN

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Baker Hughes
 Sent: Tuesday, July 22, 2008 10:51 AM
 To: 'u2-users@listserver.u2ug.org'
 Subject: [U2] Basic SORT() Function not avail in UniVerse?

 Hey,

 I'm needing to SORT a dynamic array and apparently UniVerse doesn't have
 this
 Function.

 Other MV implementations have this, such as D3 - The sort() function
 sorts an
 attribute or value mark delimited str.exp in ascending order. [from
 ePick]

 There was also a user exit u1072 that did the same thing.

 Does anyone have a work around or fast path to same thing  maybe I'm
 missing something but can't see this in UV docs.

 -Baker
 ---
 u2-users mailing list
 u2-users@listserver.u2ug.org
 To unsubscribe please visit http://listserver.u2ug.org/
 ---
 u2-users mailing list
 u2-users@listserver.u2ug.org
 To unsubscribe please visit http://listserver.u2ug.org/
 ---
 u2-users mailing list
 u2-users@listserver.u2ug.org
 To unsubscribe please visit http://listserver.u2ug.org/
 ---
 u2-users mailing list
 u2-users@listserver.u2ug.org
 To unsubscribe please visit http://listserver.u2ug.org/

 The information contained in this email and any attached files are
 strictly
 private and confidential. This email should be read by the intended
 addressee
 only

Re: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-25 Thread MAJ Programming
This is a little catch-22. Years ago, there was a limit on the number of
'variables' a program had. This, since each element in a DIM array is a
variable, you could not DIM REC(10). Thus legacy code may have been
forced to use dynamic arrays on large items.

Nowadays, we may not be held to any limits (or they are very large). Us
programmers tend to stretch the limits of what's available at the time.

Thus, knowing all of the programming options (array types, REMOVE, LOCATE,
concatenation, work files etc), we can apply the best fit for the issue at
hand.

Mark Johnson
- Original Message -
From: Baakkonen, Rodney A (Rod) 46K [EMAIL PROTECTED]
To: u2-users@listserver.u2ug.org
Sent: Wednesday, July 23, 2008 3:48 PM
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?


 I guess my point was a little off topic, as I was really calling
 attention to performance issues with dynamic arrays in general and not
 about sorting keys. When dynamic arrays can out perform work files, we
 will use them.

  We have seen processes that used dynamic arrays run for a week. Even
 with doing REMOVE and using concatenation to build the array. Changing
 the logic to use a work file resulted in the same process finishing in
 hours.

 The other aspect is that a lot dynamic arrays in programs do more that
 just hold keys. Doing a locate on one array may result in multiple data
 elements being inserted into corresponding arrays. With this type of
 intermediate data, writing and sorting a work file will run circles
 around internal arrays.

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Rex Gozar
 Sent: Wednesday, July 23, 2008 1:50 PM
 To: u2-users@listserver.u2ug.org
 Subject: Re: [U2] Basic SORT() Function not avail in UniVerse?

 I've done research on sorting in the past, working with 100,000 to
 1,000,000 element lists.

 Allen: LOCATE's are faster, but only when you're dealing with less than
 100 elements.  Because LOCATE's must start at the beginning of a string
 and traverse the entire length, they get slower and slower.  Bubble
 sorts are also useless when dealing with a large number of elements.

 Jeff: Yes, a C program is the fastest (at least it was at my last job
 where we used GCI to integrate it with the universe shell.)

 As for writing out ids to work files just to sort them, it adds
 unnecessary overhead to the whole process.

 I wish universe had an intrinsic sort() function.  Since they don't I
 wrote my own and posted it on PickWiki.  You could also use the
 QuickSort sample posted in this thread.  Once you standardize on a
 particular sorting program, you'll be amazed at the number of times it
 comes in handy.

 http://www.pickwiki.com/cgi-bin/wiki.pl?Sorting
 http://www.pickwiki.com/cgi-bin/wiki.pl?ShellSort
 http://www.pickwiki.com/cgi-bin/wiki.pl?QuickSort

 Another handy function is to be able to flip fields to values and vice
 versa.  See http://www.pickwiki.com/cgi-bin/wiki.pl?Row2Col and again
 it's optimized for a large number of elements.

 rex
 ---
 u2-users mailing list
 u2-users@listserver.u2ug.org
 To unsubscribe please visit http://listserver.u2ug.org/
 ---
 u2-users mailing list
 u2-users@listserver.u2ug.org
 To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-25 Thread MAJ Programming
I don't think that the sort/extract function alone is justification for
choosing dim arrays over dynamic arrays in programs.

Sure, for large array concepts/projects, DIM will prevail. But IMHO, for
data READ/WRITE, dynamic appears just as fast as DIM.

Maybe this doesn't apply to large systems with 100's of users. But I recall
when the  replaced the EXTRACT family of commands that typingly incouraged
programmers to use MATREAD instead of READ.

I've also run into problems with legacy systems where the data in a file
exceeds a nominal maximum number of fields and I've spent (wasted) clients
time/money changing DIM REC(100) to DIM REC(200). Who knows, in 20 years
I'll be the errant programmer when 200 needs to go to 300.

If there is a file defining INCLUDE that has the DIM, then it's an easy
repair to move forward. If they're DIM'd separately in each program (with
differing names), then it's a nightmare and bound to omit one.

My 2 cents
Mark Johnson
- Original Message -
From: Baakkonen, Rodney A (Rod) 46K [EMAIL PROTECTED]
To: u2-users@listserver.u2ug.org
Sent: Wednesday, July 23, 2008 1:24 PM
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?


 That is why we discourage developers from using dynamic arrays in
 programs. Once they get to a certain size, performance goes out the
 window. We have them store all intermediate program data in work files
 that sort quickly when well sized.

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Dave Laansma
 Sent: Wednesday, July 23, 2008 10:42 AM
 To: u2-users@listserver.u2ug.org
 Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

 I've been experimenting and discovered something.  Instead of waiting
 until you have all (say) 100,000 elements to sort at once, why not sort
 them in blocks of (say) 5,000.  So I wrote this little subroutine that
 takes two parameters, a relatively small un-sorted table and the larger
 sorted table and sorts the un-sorted into the sorted table.

 The calling program accumulates the unsorted ITAB and when it reaches a
 certain watermark, say 5,000 elements, this subroutine is called and
 those 5,000 get inserted into the master sorted OTAB, which initially is
 null.

 My experimentation discovered this method to run extremely quickly
 compared to waiting for the entire 100,000 element table to be built
 before starting the sort.  Try it out!

   SUBROUTINE HUB.SORT.B (ITAB,OTAB)

   X2= DCOUNT(ITAB,@AM)

   FOR X = 1 TO X2
 ELEM = ITABX
 LOCATE ELEM IN OTAB BY AL SETTING PLACE ELSE NULL
 OTAB = INSERT(OTAB,PLACE;ELEM)
   NEXT X

 

   RETURN

   END

 David Laansma
 IT Manager
 Hubbard Supply Co.
 Direct: 810-342-7143
 Office:810-234-8681
 Fax: 810-234-6142
 www.hubbardsupply.com
 Delivering Products, Services, and Innovative Solutions


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Jeff Marcos
 Sent: Tuesday, July 22, 2008 7:35 PM
 To: u2-users@listserver.u2ug.org
 Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

 We had the same issue back in the 90's. So a clever guy (Ed) that worked
 with us wrote a small C program (on Unix) to do the sort. This also
 included controlling/dependants fields. Any universe program could call
 it, passing in the variables and returned the items sorted.

 Speed is incredible. To this day it's still used and blitzes any
 universe program methods in sorting large arrays.

 Regards,
 Jeff Marcos

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Allen E. Elwood
 Sent: Wednesday, 23 July 2008 6:59 AM
 To: u2-users@listserver.u2ug.org
 Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

 Hey, and don't forget to do a speed test.  You know, because LOCATE is
 coded
 as part of the OS it just *might* be faster than bubble or speed sort
 options.

 In fact, this was a topic on this list about 3 or 4 years ago and
 someone
 doing the speed test concluded LOCATE was in fact faster.

 And no I don't remember who it was, or have a link to the thread (sorry)

 :-)

 Allen

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Behalf Of Israel, John R.
 Sent: Tuesday, July 22, 2008 10:26
 To: 'u2-users@listserver.u2ug.org'
 Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?


 Note that if the array is big, you would get much better performance by
 loading it into a DIM array, so the sort of sort below, then put the
 results
 back into a dynamic array.

 Dynamic arrays are much easier to use, but when used wisely, dimensioned
 arrays can be MUCH faster.  This is true for any application, esp.
 looping
 through multi-values.

 John Israel


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of DAVID WADEMAN
 Sent: Tuesday, July 22, 2008 1:00 PM
 To: u2-users@listserver.u2ug.org
 Subject: RE: [U2] Basic SORT() Function not avail

Re: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-25 Thread MAJ Programming
For those managing D3 as well, you can write the array to ANY file-item and
use

SORT-LIST FILENAME ITEMNAME

instead of the Pointer-File.
Mark Johnson
- Original Message -
From: Dave Laansma [EMAIL PROTECTED]
To: u2-users@listserver.u2ug.org
Sent: Thursday, July 24, 2008 10:49 AM
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?


 I think I like this one better than the Unix sort.  It is really quick
 too.  However I'd suggest using the SORT.LIST instead of the
 GET.LIST/MERGE.LIST:

SUBROUTINE HUB.SORT.C (ITAB)

SORT.KEY= tmpsortfile
SORT.KEY2 = @UID
SORT.KEY3 = @USERNO
SORT.KEY4 = TIME()
SWAP @AM WITH _ IN SORT.KEY

WRITELIST ITAB ON SORT.KEY

CMD = SORT.LIST :SORT.KEY
EXECUTE CMD CAPTURING MSG RETURNING ERR

READLIST ITAB FROM SORT.KEY ELSE ITAB = 

  

RETURN

END

 David Laansma
 IT Manager
 Hubbard Supply Co.
 Direct: 810-342-7143
 Office:810-234-8681
 Fax: 810-234-6142
 www.hubbardsupply.com
 Delivering Products, Services, and Innovative Solutions


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Rex Gozar
 Sent: Thursday, July 24, 2008 8:15 AM
 To: u2-users@listserver.u2ug.org
 Subject: Re: [U2] Basic SORT() Function not avail in UniVerse?

 And since no one has mentioned it yet, MERGE.LIST takes advantage of
 Universe's built-in (a.k.a C) sorting ability.

 SUBROUTINE SORT.ITEM(ITEM)
 WRITELIST ITEM ON MYLIST
 STMT = 
 STMT-1 = GET.LIST MYLIST
 STMT-1 = MERGE.LIST 0 UNION 0
 STMT-1 = SAVE.LIST MYLIST
 READLIST ITEM FROM MYLIST ELSE ABORTM IMPOSSIBLE!
 DELETELIST MYLIST
 RETURN
 END

 Of course, this still adds the i/o overhead of reading and writing, but
 is still faster than LOCATE's on 1000+ element items.

 [Another] aspect is that a lot dynamic arrays in programs do more than
 just hold keys...  which is why I wrote ROW2COL and QUICKSORT as
 complimentary subroutines (both on PickWiki).  ROW2COL will flip
 associated multivalues sideways so QUICKSORT can sort and subsort on
 values in the corresponding rows; then I use ROW2COL to flip them
 back.  Ideally, Universe should provide similar built-in functionality.

 rex
 ---
 u2-users mailing list
 u2-users@listserver.u2ug.org
 To unsubscribe please visit http://listserver.u2ug.org/
 ---
 u2-users mailing list
 u2-users@listserver.u2ug.org
 To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-24 Thread Rex Gozar
And since no one has mentioned it yet, MERGE.LIST takes advantage of 
Universe's built-in (a.k.a C) sorting ability.


   SUBROUTINE SORT.ITEM(ITEM)
   WRITELIST ITEM ON MYLIST
   STMT = 
   STMT-1 = GET.LIST MYLIST
   STMT-1 = MERGE.LIST 0 UNION 0
   STMT-1 = SAVE.LIST MYLIST
   READLIST ITEM FROM MYLIST ELSE ABORTM IMPOSSIBLE!
   DELETELIST MYLIST
   RETURN
END

Of course, this still adds the i/o overhead of reading and writing, but 
is still faster than LOCATE's on 1000+ element items.


[Another] aspect is that a lot dynamic arrays in programs do more than
just hold keys...  which is why I wrote ROW2COL and QUICKSORT as 
complimentary subroutines (both on PickWiki).  ROW2COL will flip 
associated multivalues sideways so QUICKSORT can sort and subsort on 
values in the corresponding rows; then I use ROW2COL to flip them 
back.  Ideally, Universe should provide similar built-in functionality.


rex
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-24 Thread Louie Bergsagel
That is a nifty idea if your values are all the same type.  It doesn't work
for 1-10:

EDIT.LIST MYLIST
New record.

: I
0001= 2
0002= 1
0003= 3
0004= 5
0005= 10
0006= 7
0007= 6
0008= 4
0009= 9
0010= 8
0011=
Bottom at line 10.
: FILE
MYLIST filed in file SAVEDLISTS.
GET.LIST MYLIST

10 record(s) selected to SELECT list #0.
MERGE.LIST 0 UNION 0

10 record(s) selected to SELECT list #0.
SAVE.LIST MYLIST

10 record(s) SAVEd to SELECT list MYLIST.
EDIT.LIST MYLIST
10 lines long.

: P
0001: 1
0002: 10
0003: 2
0004: 3
0005: 4
0006: 5
0007: 6
0008: 7
0009: 8
0010: 9
Bottom at line 10.
: Q
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-24 Thread Dianne Ackerman

I don't seem to have SORT.LIST on UV 10.1.14.  Is it on a later version?
-Dianne

Dave Laansma wrote:


I think I like this one better than the Unix sort.  It is really quick
too.  However I'd suggest using the SORT.LIST instead of the
GET.LIST/MERGE.LIST:

  SUBROUTINE HUB.SORT.C (ITAB)

  SORT.KEY= tmpsortfile
  SORT.KEY2 = @UID
  SORT.KEY3 = @USERNO
  SORT.KEY4 = TIME()
  SWAP @AM WITH _ IN SORT.KEY

  WRITELIST ITAB ON SORT.KEY

  CMD = SORT.LIST :SORT.KEY
  EXECUTE CMD CAPTURING MSG RETURNING ERR

  READLIST ITAB FROM SORT.KEY ELSE ITAB = 



  RETURN

  END

David Laansma
IT Manager
Hubbard Supply Co. 
Direct: 810-342-7143

Office:810-234-8681
Fax: 810-234-6142
www.hubbardsupply.com
Delivering Products, Services, and Innovative Solutions

---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-24 Thread Dave Laansma
My apologies.  I am on Unidata.

David Laansma
IT Manager
Hubbard Supply Co. 
Direct: 810-342-7143
Office:810-234-8681
Fax: 810-234-6142
www.hubbardsupply.com
Delivering Products, Services, and Innovative Solutions


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dianne Ackerman
Sent: Thursday, July 24, 2008 11:39 AM
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] Basic SORT() Function not avail in UniVerse?

I don't seem to have SORT.LIST on UV 10.1.14.  Is it on a later version?
-Dianne

Dave Laansma wrote:

I think I like this one better than the Unix sort.  It is really quick
too.  However I'd suggest using the SORT.LIST instead of the
GET.LIST/MERGE.LIST:

   SUBROUTINE HUB.SORT.C (ITAB)

   SORT.KEY= tmpsortfile
   SORT.KEY2 = @UID
   SORT.KEY3 = @USERNO
   SORT.KEY4 = TIME()
   SWAP @AM WITH _ IN SORT.KEY

   WRITELIST ITAB ON SORT.KEY

   CMD = SORT.LIST :SORT.KEY
   EXECUTE CMD CAPTURING MSG RETURNING ERR

   READLIST ITAB FROM SORT.KEY ELSE ITAB = 

 

   RETURN

   END

David Laansma
IT Manager
Hubbard Supply Co. 
Direct: 810-342-7143
Office:810-234-8681
Fax: 810-234-6142
www.hubbardsupply.com
Delivering Products, Services, and Innovative Solutions
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-23 Thread Dave Laansma
I'd suggest this subroutine.  Brief and to the point:

  SUBROUTINE HUB.SORT.B (ITAB)

  OTAB = 

  FOR X = 1 TO DCOUNT(ITAB,@AM)
ELEM = ITABX
LOCATE ELEM IN OTAB BY AL SETTING PLACE ELSE NULL
OTAB = INSERT(OTAB,PLACE;ELEM)
  NEXT X

  ITAB = OTAB



  RETURN

  END

David Laansma
IT Manager
Hubbard Supply Co. 
Direct: 810-342-7143
Office:810-234-8681
Fax: 810-234-6142
www.hubbardsupply.com
Delivering Products, Services, and Innovative Solutions

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jeff Marcos
Sent: Tuesday, July 22, 2008 7:35 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

We had the same issue back in the 90's. So a clever guy (Ed) that worked
with us wrote a small C program (on Unix) to do the sort. This also
included controlling/dependants fields. Any universe program could call
it, passing in the variables and returned the items sorted.

Speed is incredible. To this day it's still used and blitzes any
universe program methods in sorting large arrays. 

Regards,
Jeff Marcos

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Allen E. Elwood
Sent: Wednesday, 23 July 2008 6:59 AM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

Hey, and don't forget to do a speed test.  You know, because LOCATE is
coded
as part of the OS it just *might* be faster than bubble or speed sort
options.

In fact, this was a topic on this list about 3 or 4 years ago and
someone
doing the speed test concluded LOCATE was in fact faster.

And no I don't remember who it was, or have a link to the thread (sorry)

:-)

Allen

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Israel, John R.
Sent: Tuesday, July 22, 2008 10:26
To: 'u2-users@listserver.u2ug.org'
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?


Note that if the array is big, you would get much better performance by
loading it into a DIM array, so the sort of sort below, then put the
results
back into a dynamic array.

Dynamic arrays are much easier to use, but when used wisely, dimensioned
arrays can be MUCH faster.  This is true for any application, esp.
looping
through multi-values.

John Israel


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of DAVID WADEMAN
Sent: Tuesday, July 22, 2008 1:00 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

This is a UniData subroutine, but should work 

SUBROUTINE B42.SORT.ARRAY(SORTED,ARRAY)
* Bubble sort the elements of a dynamic array
* Created by: David Wademan
* Creation Date: 01/05/05
SORTED=
VALUES = DCOUNT(ARRAY,@VM)
LOOP
   CHANGES = 0
   FOR X = 2 TO VALUES
  * For each adjacent pair
  ELEMENT1 = ARRAY1,X-1
  ELEMENT2 = ARRAY1,X

  IF ELEMENT2  ELEMENT1 THEN
 * Swap if pair out of sequence
 ARRAY1,X = ELEMENT1
 ARRAY1,X-1 = ELEMENT2
 CHANGES = 1
  END
   NEXT X
WHILE CHANGES DO REPEAT
SORTED=ARRAY
RETURN

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Baker Hughes
Sent: Tuesday, July 22, 2008 10:51 AM
To: 'u2-users@listserver.u2ug.org'
Subject: [U2] Basic SORT() Function not avail in UniVerse?

Hey,

I'm needing to SORT a dynamic array and apparently UniVerse doesn't have
this
Function.

Other MV implementations have this, such as D3 - The sort() function
sorts an
attribute or value mark delimited str.exp in ascending order. [from
ePick]

There was also a user exit u1072 that did the same thing.

Does anyone have a work around or fast path to same thing  maybe I'm
missing something but can't see this in UV docs.

-Baker
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

The information contained in this email and any attached files are
strictly
private and confidential. This email should be read by the intended
addressee
only.  If the recipient of this message is not the intended addressee,
please
call Corporate Express Australia Limited on +61 2 9335 0555 or Corporate
Express
New Zealand Limited on +64 9 279 2555 and promptly delete this email and
any
attachments.  The intended recipient of this email may only use,
reproduce,
disclose or distribute the information contained in this email and any
attached
files with Corporate Express' permission. If you are not the intended
addressee,
you are strictly prohibited from using, reproducing, disclosing or
distributing

RE: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-23 Thread Dave Laansma
I've been experimenting and discovered something.  Instead of waiting
until you have all (say) 100,000 elements to sort at once, why not sort
them in blocks of (say) 5,000.  So I wrote this little subroutine that
takes two parameters, a relatively small un-sorted table and the larger
sorted table and sorts the un-sorted into the sorted table.

The calling program accumulates the unsorted ITAB and when it reaches a
certain watermark, say 5,000 elements, this subroutine is called and
those 5,000 get inserted into the master sorted OTAB, which initially is
null.

My experimentation discovered this method to run extremely quickly
compared to waiting for the entire 100,000 element table to be built
before starting the sort.  Try it out!

  SUBROUTINE HUB.SORT.B (ITAB,OTAB)

  X2= DCOUNT(ITAB,@AM)

  FOR X = 1 TO X2
ELEM = ITABX
LOCATE ELEM IN OTAB BY AL SETTING PLACE ELSE NULL
OTAB = INSERT(OTAB,PLACE;ELEM)
  NEXT X



  RETURN

  END

David Laansma
IT Manager
Hubbard Supply Co. 
Direct: 810-342-7143
Office:810-234-8681
Fax: 810-234-6142
www.hubbardsupply.com
Delivering Products, Services, and Innovative Solutions


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jeff Marcos
Sent: Tuesday, July 22, 2008 7:35 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

We had the same issue back in the 90's. So a clever guy (Ed) that worked
with us wrote a small C program (on Unix) to do the sort. This also
included controlling/dependants fields. Any universe program could call
it, passing in the variables and returned the items sorted.

Speed is incredible. To this day it's still used and blitzes any
universe program methods in sorting large arrays. 

Regards,
Jeff Marcos

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Allen E. Elwood
Sent: Wednesday, 23 July 2008 6:59 AM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

Hey, and don't forget to do a speed test.  You know, because LOCATE is
coded
as part of the OS it just *might* be faster than bubble or speed sort
options.

In fact, this was a topic on this list about 3 or 4 years ago and
someone
doing the speed test concluded LOCATE was in fact faster.

And no I don't remember who it was, or have a link to the thread (sorry)

:-)

Allen

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Israel, John R.
Sent: Tuesday, July 22, 2008 10:26
To: 'u2-users@listserver.u2ug.org'
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?


Note that if the array is big, you would get much better performance by
loading it into a DIM array, so the sort of sort below, then put the
results
back into a dynamic array.

Dynamic arrays are much easier to use, but when used wisely, dimensioned
arrays can be MUCH faster.  This is true for any application, esp.
looping
through multi-values.

John Israel


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of DAVID WADEMAN
Sent: Tuesday, July 22, 2008 1:00 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

This is a UniData subroutine, but should work 

SUBROUTINE B42.SORT.ARRAY(SORTED,ARRAY)
* Bubble sort the elements of a dynamic array
* Created by: David Wademan
* Creation Date: 01/05/05
SORTED=
VALUES = DCOUNT(ARRAY,@VM)
LOOP
   CHANGES = 0
   FOR X = 2 TO VALUES
  * For each adjacent pair
  ELEMENT1 = ARRAY1,X-1
  ELEMENT2 = ARRAY1,X

  IF ELEMENT2  ELEMENT1 THEN
 * Swap if pair out of sequence
 ARRAY1,X = ELEMENT1
 ARRAY1,X-1 = ELEMENT2
 CHANGES = 1
  END
   NEXT X
WHILE CHANGES DO REPEAT
SORTED=ARRAY
RETURN

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Baker Hughes
Sent: Tuesday, July 22, 2008 10:51 AM
To: 'u2-users@listserver.u2ug.org'
Subject: [U2] Basic SORT() Function not avail in UniVerse?

Hey,

I'm needing to SORT a dynamic array and apparently UniVerse doesn't have
this
Function.

Other MV implementations have this, such as D3 - The sort() function
sorts an
attribute or value mark delimited str.exp in ascending order. [from
ePick]

There was also a user exit u1072 that did the same thing.

Does anyone have a work around or fast path to same thing  maybe I'm
missing something but can't see this in UV docs.

-Baker
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

The information contained

RE: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-23 Thread Baakkonen, Rodney A (Rod) 46K
 That is why we discourage developers from using dynamic arrays in
programs. Once they get to a certain size, performance goes out the
window. We have them store all intermediate program data in work files
that sort quickly when well sized. 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dave Laansma
Sent: Wednesday, July 23, 2008 10:42 AM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

I've been experimenting and discovered something.  Instead of waiting
until you have all (say) 100,000 elements to sort at once, why not sort
them in blocks of (say) 5,000.  So I wrote this little subroutine that
takes two parameters, a relatively small un-sorted table and the larger
sorted table and sorts the un-sorted into the sorted table.

The calling program accumulates the unsorted ITAB and when it reaches a
certain watermark, say 5,000 elements, this subroutine is called and
those 5,000 get inserted into the master sorted OTAB, which initially is
null.

My experimentation discovered this method to run extremely quickly
compared to waiting for the entire 100,000 element table to be built
before starting the sort.  Try it out!

  SUBROUTINE HUB.SORT.B (ITAB,OTAB)

  X2= DCOUNT(ITAB,@AM)

  FOR X = 1 TO X2
ELEM = ITABX
LOCATE ELEM IN OTAB BY AL SETTING PLACE ELSE NULL
OTAB = INSERT(OTAB,PLACE;ELEM)
  NEXT X



  RETURN

  END

David Laansma
IT Manager
Hubbard Supply Co. 
Direct: 810-342-7143
Office:810-234-8681
Fax: 810-234-6142
www.hubbardsupply.com
Delivering Products, Services, and Innovative Solutions


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jeff Marcos
Sent: Tuesday, July 22, 2008 7:35 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

We had the same issue back in the 90's. So a clever guy (Ed) that worked
with us wrote a small C program (on Unix) to do the sort. This also
included controlling/dependants fields. Any universe program could call
it, passing in the variables and returned the items sorted.

Speed is incredible. To this day it's still used and blitzes any
universe program methods in sorting large arrays. 

Regards,
Jeff Marcos

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Allen E. Elwood
Sent: Wednesday, 23 July 2008 6:59 AM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

Hey, and don't forget to do a speed test.  You know, because LOCATE is
coded
as part of the OS it just *might* be faster than bubble or speed sort
options.

In fact, this was a topic on this list about 3 or 4 years ago and
someone
doing the speed test concluded LOCATE was in fact faster.

And no I don't remember who it was, or have a link to the thread (sorry)

:-)

Allen

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Israel, John R.
Sent: Tuesday, July 22, 2008 10:26
To: 'u2-users@listserver.u2ug.org'
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?


Note that if the array is big, you would get much better performance by
loading it into a DIM array, so the sort of sort below, then put the
results
back into a dynamic array.

Dynamic arrays are much easier to use, but when used wisely, dimensioned
arrays can be MUCH faster.  This is true for any application, esp.
looping
through multi-values.

John Israel


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of DAVID WADEMAN
Sent: Tuesday, July 22, 2008 1:00 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

This is a UniData subroutine, but should work 

SUBROUTINE B42.SORT.ARRAY(SORTED,ARRAY)
* Bubble sort the elements of a dynamic array
* Created by: David Wademan
* Creation Date: 01/05/05
SORTED=
VALUES = DCOUNT(ARRAY,@VM)
LOOP
   CHANGES = 0
   FOR X = 2 TO VALUES
  * For each adjacent pair
  ELEMENT1 = ARRAY1,X-1
  ELEMENT2 = ARRAY1,X

  IF ELEMENT2  ELEMENT1 THEN
 * Swap if pair out of sequence
 ARRAY1,X = ELEMENT1
 ARRAY1,X-1 = ELEMENT2
 CHANGES = 1
  END
   NEXT X
WHILE CHANGES DO REPEAT
SORTED=ARRAY
RETURN

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Baker Hughes
Sent: Tuesday, July 22, 2008 10:51 AM
To: 'u2-users@listserver.u2ug.org'
Subject: [U2] Basic SORT() Function not avail in UniVerse?

Hey,

I'm needing to SORT a dynamic array and apparently UniVerse doesn't have
this
Function.

Other MV implementations have this, such as D3 - The sort() function
sorts an
attribute or value mark delimited str.exp in ascending order. [from
ePick]

There was also a user exit u1072 that did the same thing.

Does anyone have a work around or fast path to same thing  maybe I'm
missing something but can't see this in UV docs.

-Baker
---
u2

Re: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-23 Thread Rex Gozar
I've done research on sorting in the past, working with 100,000 to 
1,000,000 element lists.


Allen: LOCATE's are faster, but only when you're dealing with less than 
100 elements.  Because LOCATE's must start at the beginning of a string 
and traverse the entire length, they get slower and slower.  Bubble 
sorts are also useless when dealing with a large number of elements.


Jeff: Yes, a C program is the fastest (at least it was at my last job 
where we used GCI to integrate it with the universe shell.)


As for writing out ids to work files just to sort them, it adds 
unnecessary overhead to the whole process.


I wish universe had an intrinsic sort() function.  Since they don't I 
wrote my own and posted it on PickWiki.  You could also use the 
QuickSort sample posted in this thread.  Once you standardize on a 
particular sorting program, you'll be amazed at the number of times it 
comes in handy.


http://www.pickwiki.com/cgi-bin/wiki.pl?Sorting
http://www.pickwiki.com/cgi-bin/wiki.pl?ShellSort
http://www.pickwiki.com/cgi-bin/wiki.pl?QuickSort

Another handy function is to be able to flip fields to values and vice 
versa.  See http://www.pickwiki.com/cgi-bin/wiki.pl?Row2Col and again 
it's optimized for a large number of elements.


rex
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-23 Thread David A. Green
Jeff,

Can you compare the speed of your C sorting program with this one?  It's
untested code...

FUNCTION SortArray(InArray, AllowDups, SortBy)
*
OutArray   = Remove(InArray, MoreItems)
ArrayDelim = @RM:@AM:@VM:@SM:@TM[MoreItems, 1]
If SortBy =  then SortBy = AL
*
While MoreItems Do
  Item = Remove(InArray, MoreItems)
  Locate Item in OutArray1 by SortBy setting Pos then
 If AllowDups then Ins Item before OutArrayPos
  End else
 Ins Item before OutArrayPos
  End
Repeat
*
Swap @AM with ArrayDelim in OutArray
Return OutArray

Can you share your 'C' program?  Maybe IBM can add it to U2 products as
SORT() Function.

Thanks,
David A. Green
www.dagconsulting.com
(480) 813-1725


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jeff Marcos
Sent: Tuesday, July 22, 2008 4:35 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

We had the same issue back in the 90's. So a clever guy (Ed) that worked
with us wrote a small C program (on Unix) to do the sort. This also
included controlling/dependants fields. Any universe program could call
it, passing in the variables and returned the items sorted.

Speed is incredible. To this day it's still used and blitzes any
universe program methods in sorting large arrays. 

Regards,
Jeff Marcos

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Allen E. Elwood
Sent: Wednesday, 23 July 2008 6:59 AM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

Hey, and don't forget to do a speed test.  You know, because LOCATE is
coded
as part of the OS it just *might* be faster than bubble or speed sort
options.

In fact, this was a topic on this list about 3 or 4 years ago and
someone
doing the speed test concluded LOCATE was in fact faster.

And no I don't remember who it was, or have a link to the thread (sorry)

:-)

Allen

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Israel, John R.
Sent: Tuesday, July 22, 2008 10:26
To: 'u2-users@listserver.u2ug.org'
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?


Note that if the array is big, you would get much better performance by
loading it into a DIM array, so the sort of sort below, then put the
results
back into a dynamic array.

Dynamic arrays are much easier to use, but when used wisely, dimensioned
arrays can be MUCH faster.  This is true for any application, esp.
looping
through multi-values.

John Israel


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of DAVID WADEMAN
Sent: Tuesday, July 22, 2008 1:00 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

This is a UniData subroutine, but should work 

SUBROUTINE B42.SORT.ARRAY(SORTED,ARRAY)
* Bubble sort the elements of a dynamic array
* Created by: David Wademan
* Creation Date: 01/05/05
SORTED=
VALUES = DCOUNT(ARRAY,@VM)
LOOP
   CHANGES = 0
   FOR X = 2 TO VALUES
  * For each adjacent pair
  ELEMENT1 = ARRAY1,X-1
  ELEMENT2 = ARRAY1,X

  IF ELEMENT2  ELEMENT1 THEN
 * Swap if pair out of sequence
 ARRAY1,X = ELEMENT1
 ARRAY1,X-1 = ELEMENT2
 CHANGES = 1
  END
   NEXT X
WHILE CHANGES DO REPEAT
SORTED=ARRAY
RETURN

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Baker Hughes
Sent: Tuesday, July 22, 2008 10:51 AM
To: 'u2-users@listserver.u2ug.org'
Subject: [U2] Basic SORT() Function not avail in UniVerse?

Hey,

I'm needing to SORT a dynamic array and apparently UniVerse doesn't have
this
Function.

Other MV implementations have this, such as D3 - The sort() function
sorts an
attribute or value mark delimited str.exp in ascending order. [from
ePick]

There was also a user exit u1072 that did the same thing.

Does anyone have a work around or fast path to same thing  maybe I'm
missing something but can't see this in UV docs.

-Baker
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

The information contained in this email and any attached files are strictly
private and confidential. This email should be read by the intended
addressee
only.  If the recipient of this message is not the intended addressee,
please
call Corporate Express Australia Limited on +61 2 9335 0555 or Corporate
Express
New Zealand Limited on +64 9 279 2555 and promptly delete this email and any
attachments.  The intended recipient of this email may only use, reproduce,
disclose or distribute

RE: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-23 Thread Nick Gettino
For very large files we use alternate indexes on Unidata.
So we have one for date or some virtual of data that is used most of the
time.  Then we use a generic subroutine to read the index using either a
SETINDEX to go exactly where you want (or where the next record should
be) or SELECTINDEX it is extremely fast as we use it for our 911
dispatching application where every millisecond counts.


Nick Gettino
Director of Development
EnRoute Emergency Systems
401 E Jackson St
Suite 1500
Tampa FL 33602

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Rex Gozar
Sent: Wednesday, July 23, 2008 2:50 PM
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] Basic SORT() Function not avail in UniVerse?

I've done research on sorting in the past, working with 100,000 to 
1,000,000 element lists.

Allen: LOCATE's are faster, but only when you're dealing with less than 
100 elements.  Because LOCATE's must start at the beginning of a string 
and traverse the entire length, they get slower and slower.  Bubble 
sorts are also useless when dealing with a large number of elements.

Jeff: Yes, a C program is the fastest (at least it was at my last job 
where we used GCI to integrate it with the universe shell.)

As for writing out ids to work files just to sort them, it adds 
unnecessary overhead to the whole process.

I wish universe had an intrinsic sort() function.  Since they don't I 
wrote my own and posted it on PickWiki.  You could also use the 
QuickSort sample posted in this thread.  Once you standardize on a 
particular sorting program, you'll be amazed at the number of times it 
comes in handy.

http://www.pickwiki.com/cgi-bin/wiki.pl?Sorting
http://www.pickwiki.com/cgi-bin/wiki.pl?ShellSort
http://www.pickwiki.com/cgi-bin/wiki.pl?QuickSort

Another handy function is to be able to flip fields to values and vice 
versa.  See http://www.pickwiki.com/cgi-bin/wiki.pl?Row2Col and again 
it's optimized for a large number of elements.

rex
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-23 Thread Baakkonen, Rodney A (Rod) 46K
 I guess my point was a little off topic, as I was really calling
attention to performance issues with dynamic arrays in general and not
about sorting keys. When dynamic arrays can out perform work files, we
will use them.

 We have seen processes that used dynamic arrays run for a week. Even
with doing REMOVE and using concatenation to build the array. Changing
the logic to use a work file resulted in the same process finishing in
hours.

The other aspect is that a lot dynamic arrays in programs do more that
just hold keys. Doing a locate on one array may result in multiple data
elements being inserted into corresponding arrays. With this type of
intermediate data, writing and sorting a work file will run circles
around internal arrays.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Rex Gozar
Sent: Wednesday, July 23, 2008 1:50 PM
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] Basic SORT() Function not avail in UniVerse?

I've done research on sorting in the past, working with 100,000 to 
1,000,000 element lists.

Allen: LOCATE's are faster, but only when you're dealing with less than 
100 elements.  Because LOCATE's must start at the beginning of a string 
and traverse the entire length, they get slower and slower.  Bubble 
sorts are also useless when dealing with a large number of elements.

Jeff: Yes, a C program is the fastest (at least it was at my last job 
where we used GCI to integrate it with the universe shell.)

As for writing out ids to work files just to sort them, it adds 
unnecessary overhead to the whole process.

I wish universe had an intrinsic sort() function.  Since they don't I 
wrote my own and posted it on PickWiki.  You could also use the 
QuickSort sample posted in this thread.  Once you standardize on a 
particular sorting program, you'll be amazed at the number of times it 
comes in handy.

http://www.pickwiki.com/cgi-bin/wiki.pl?Sorting
http://www.pickwiki.com/cgi-bin/wiki.pl?ShellSort
http://www.pickwiki.com/cgi-bin/wiki.pl?QuickSort

Another handy function is to be able to flip fields to values and vice 
versa.  See http://www.pickwiki.com/cgi-bin/wiki.pl?Row2Col and again 
it's optimized for a large number of elements.

rex
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-23 Thread Symeon Breen
I too would be interested in your c function


Thanks
Symeon.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of David A. Green
Sent: 23 July 2008 19:58
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

Jeff,

Can you compare the speed of your C sorting program with this one?  It's
untested code...

FUNCTION SortArray(InArray, AllowDups, SortBy)
*
OutArray   = Remove(InArray, MoreItems)
ArrayDelim = @RM:@AM:@VM:@SM:@TM[MoreItems, 1]
If SortBy =  then SortBy = AL
*
While MoreItems Do
  Item = Remove(InArray, MoreItems)
  Locate Item in OutArray1 by SortBy setting Pos then
 If AllowDups then Ins Item before OutArrayPos
  End else
 Ins Item before OutArrayPos
  End
Repeat
*
Swap @AM with ArrayDelim in OutArray
Return OutArray

Can you share your 'C' program?  Maybe IBM can add it to U2 products as
SORT() Function.

Thanks,
David A. Green
www.dagconsulting.com
(480) 813-1725


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jeff Marcos
Sent: Tuesday, July 22, 2008 4:35 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

We had the same issue back in the 90's. So a clever guy (Ed) that worked
with us wrote a small C program (on Unix) to do the sort. This also
included controlling/dependants fields. Any universe program could call
it, passing in the variables and returned the items sorted.

Speed is incredible. To this day it's still used and blitzes any
universe program methods in sorting large arrays. 

Regards,
Jeff Marcos

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Allen E. Elwood
Sent: Wednesday, 23 July 2008 6:59 AM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

Hey, and don't forget to do a speed test.  You know, because LOCATE is
coded
as part of the OS it just *might* be faster than bubble or speed sort
options.

In fact, this was a topic on this list about 3 or 4 years ago and
someone
doing the speed test concluded LOCATE was in fact faster.

And no I don't remember who it was, or have a link to the thread (sorry)

:-)

Allen

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Israel, John R.
Sent: Tuesday, July 22, 2008 10:26
To: 'u2-users@listserver.u2ug.org'
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?


Note that if the array is big, you would get much better performance by
loading it into a DIM array, so the sort of sort below, then put the
results
back into a dynamic array.

Dynamic arrays are much easier to use, but when used wisely, dimensioned
arrays can be MUCH faster.  This is true for any application, esp.
looping
through multi-values.

John Israel


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of DAVID WADEMAN
Sent: Tuesday, July 22, 2008 1:00 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

This is a UniData subroutine, but should work 

SUBROUTINE B42.SORT.ARRAY(SORTED,ARRAY)
* Bubble sort the elements of a dynamic array
* Created by: David Wademan
* Creation Date: 01/05/05
SORTED=
VALUES = DCOUNT(ARRAY,@VM)
LOOP
   CHANGES = 0
   FOR X = 2 TO VALUES
  * For each adjacent pair
  ELEMENT1 = ARRAY1,X-1
  ELEMENT2 = ARRAY1,X

  IF ELEMENT2  ELEMENT1 THEN
 * Swap if pair out of sequence
 ARRAY1,X = ELEMENT1
 ARRAY1,X-1 = ELEMENT2
 CHANGES = 1
  END
   NEXT X
WHILE CHANGES DO REPEAT
SORTED=ARRAY
RETURN

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Baker Hughes
Sent: Tuesday, July 22, 2008 10:51 AM
To: 'u2-users@listserver.u2ug.org'
Subject: [U2] Basic SORT() Function not avail in UniVerse?

Hey,

I'm needing to SORT a dynamic array and apparently UniVerse doesn't have
this
Function.

Other MV implementations have this, such as D3 - The sort() function
sorts an
attribute or value mark delimited str.exp in ascending order. [from
ePick]

There was also a user exit u1072 that did the same thing.

Does anyone have a work around or fast path to same thing  maybe I'm
missing something but can't see this in UV docs.

-Baker
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

The information contained in this email and any attached files are strictly
private and confidential. This email should be read by the intended
addressee
only.  If the recipient of this message

RE: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-23 Thread Israel, John R.
Same here

John Israel
Sr. Programmer/Analyst
Dayton Superior Corporation
721 Richard St.
Dayton, OH  45342
937-866-0711 x44380

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Symeon Breen
Sent: Wednesday, July 23, 2008 4:09 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

I too would be interested in your c function


Thanks
Symeon.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of David A. Green
Sent: 23 July 2008 19:58
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

Jeff,

Can you compare the speed of your C sorting program with this one?  It's
untested code...

FUNCTION SortArray(InArray, AllowDups, SortBy)
*
OutArray   = Remove(InArray, MoreItems)
ArrayDelim = @RM:@AM:@VM:@SM:@TM[MoreItems, 1]
If SortBy =  then SortBy = AL
*
While MoreItems Do
  Item = Remove(InArray, MoreItems)
  Locate Item in OutArray1 by SortBy setting Pos then
 If AllowDups then Ins Item before OutArrayPos
  End else
 Ins Item before OutArrayPos
  End
Repeat
*
Swap @AM with ArrayDelim in OutArray
Return OutArray

Can you share your 'C' program?  Maybe IBM can add it to U2 products as
SORT() Function.

Thanks,
David A. Green
www.dagconsulting.com
(480) 813-1725


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jeff Marcos
Sent: Tuesday, July 22, 2008 4:35 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

We had the same issue back in the 90's. So a clever guy (Ed) that worked
with us wrote a small C program (on Unix) to do the sort. This also
included controlling/dependants fields. Any universe program could call
it, passing in the variables and returned the items sorted.

Speed is incredible. To this day it's still used and blitzes any
universe program methods in sorting large arrays.

Regards,
Jeff Marcos

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Allen E. Elwood
Sent: Wednesday, 23 July 2008 6:59 AM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

Hey, and don't forget to do a speed test.  You know, because LOCATE is
coded
as part of the OS it just *might* be faster than bubble or speed sort
options.

In fact, this was a topic on this list about 3 or 4 years ago and
someone
doing the speed test concluded LOCATE was in fact faster.

And no I don't remember who it was, or have a link to the thread (sorry)

:-)

Allen

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Israel, John R.
Sent: Tuesday, July 22, 2008 10:26
To: 'u2-users@listserver.u2ug.org'
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?


Note that if the array is big, you would get much better performance by
loading it into a DIM array, so the sort of sort below, then put the
results
back into a dynamic array.

Dynamic arrays are much easier to use, but when used wisely, dimensioned
arrays can be MUCH faster.  This is true for any application, esp.
looping
through multi-values.

John Israel


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of DAVID WADEMAN
Sent: Tuesday, July 22, 2008 1:00 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

This is a UniData subroutine, but should work 

SUBROUTINE B42.SORT.ARRAY(SORTED,ARRAY)
* Bubble sort the elements of a dynamic array
* Created by: David Wademan
* Creation Date: 01/05/05
SORTED=
VALUES = DCOUNT(ARRAY,@VM)
LOOP
   CHANGES = 0
   FOR X = 2 TO VALUES
  * For each adjacent pair
  ELEMENT1 = ARRAY1,X-1
  ELEMENT2 = ARRAY1,X

  IF ELEMENT2  ELEMENT1 THEN
 * Swap if pair out of sequence
 ARRAY1,X = ELEMENT1
 ARRAY1,X-1 = ELEMENT2
 CHANGES = 1
  END
   NEXT X
WHILE CHANGES DO REPEAT
SORTED=ARRAY
RETURN

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Baker Hughes
Sent: Tuesday, July 22, 2008 10:51 AM
To: 'u2-users@listserver.u2ug.org'
Subject: [U2] Basic SORT() Function not avail in UniVerse?

Hey,

I'm needing to SORT a dynamic array and apparently UniVerse doesn't have
this
Function.

Other MV implementations have this, such as D3 - The sort() function
sorts an
attribute or value mark delimited str.exp in ascending order. [from
ePick]

There was also a user exit u1072 that did the same thing.

Does anyone have a work around or fast path to same thing  maybe I'm
missing something but can't see this in UV docs.

-Baker
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org

Re: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-23 Thread Charlie Rubeor
Before we had the SORT function, I wrote out the variable to a directory and
used the *nix sort command.  I don't have the original program, but I
re-created it here as best I could.  I remember the program as being a lot
more complicated then this, but here it is anyway.

SUBROUTINE SORT.STUFF(BIG.ARRAY,SORTED.ARRAY)
*
* Must have a temporary dir-type file
*
OPEN 'TEMPDIR' TO F.TEMPDIR ELSE STOP 201,'TEMPDIR'
TEMP.KEY = @USERNO:'*':@LEVEL
TEMP.PATH = FILEINFO(F.TEMPDIR,2):'/':TEMP.KEY
*
WRITE BIG.ARRAY ON F.TEMPDIR,TEMP.KEY
*
CMD = '!sort -o ':TEMP.PATH:' ':TEMP.PATH
EXECUTE CMD CAPTURING OUTPUT RETURNING ERROR.MESSAGE
*
READ SORTED.ARRAY FROM F.TEMPDIR,TEMP.KEY THEN
   DELETE F.TEMPDIR,TEMP.KEY
END ELSE
   PRINT;PRINT Didn't work!
END
RETURN

I only tested this once, it sorted a 1,000,000 line array in a couple of
seconds.

hth

- Original Message -
From: Baker Hughes [EMAIL PROTECTED]
To: u2-users@listserver.u2ug.org
Sent: Tuesday, July 22, 2008 10:50 AM
Subject: [U2] Basic SORT() Function not avail in UniVerse?


 Hey,

 I'm needing to SORT a dynamic array and apparently UniVerse doesn't have
 this
 Function.

 Other MV implementations have this, such as D3 - The sort() function
 sorts an
 attribute or value mark delimited str.exp in ascending order. [from
 ePick]

 There was also a user exit u1072 that did the same thing.

 Does anyone have a work around or fast path to same thing  maybe I'm
 missing something but can't see this in UV docs.

 -Baker
 ---
 u2-users mailing list
 u2-users@listserver.u2ug.org
 To unsubscribe please visit http://listserver.u2ug.org/

[demime 1.01d removed an attachment of type application/pgp-signature which had 
a name of PGP.sig]
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Basic SORT() Function not avail in UniVerse? results

2008-07-23 Thread Jeff Marcos
David, thanks for the little challenge.



I took your code you suggested to try and created the below program:

Please feel free to comment or improve the code. Unfortunately I don't
have all day to refine (wish I could though).



Due to company policy, I can't at this point in time release any code
produced at this company other than the test code below.



You'll see in the results that

Recordsc-Sort   uv-Sort

1,0000:010:06

10,000  0:010:22

20,000  0:011:19

50,000  0:01  8:34

999,99920 (gave up after 25 minutes)



Plus you really start to see the speed improvement when you also have to
sort fields that have dependant attributes.



Ps. We run IBM P series with lots of memory and cpu



Final comment from Phil a colleague here:

What this points to is the need for IBM to develop an inbuilt high
speed multivalue sort function call that uses faster methods then
'LOCATE' and 'INSERT'. Can we put this on the wishlist 





~~

 PROGRAM TST.SORT

*

$INCLUDE SYINCLUDE COMMON

*

 PROMPT  

 scrPos = 3

 CRT @(-1):@(3,scrPos):*** START ***



 scrPos += 2

 CRT @(3,scrPos):Number of ids :

 INPUT NUM

 IF NOT(NUM) OR NUM  1 THEN

STOP

 END

*

 scrPos += 2

 CRT @(3,scrPos):Start Time for RND function : :TIMEDATE()

 EVALNUM = NUM * 100

 VARIDS = ''

 FOR X = 1 TO NUM

VARIDS := @VM:RND(EVALNUM)

 NEXT X

 VARIDS = DELETE(VARIDS,1,1,0) ;* first MV entry is null

*

 scrPos += 2

 CRT @(3,scrPos):Time taken so far after RND build :
:OCONV(((DATE()[EMAIL PROTECTED])*8400)+(TIME()[EMAIL PROTECTED]),MTS)

*

 GOSUB RESORT.C

*

 scrPos += 2

 CRT @(3,scrPos):Time taken so far after C version sort :
:OCONV(((DATE()[EMAIL PROTECTED])*8400)+(TIME()[EMAIL PROTECTED]),MTS)

*

 SortBy = 'DR'

 InArray = VARIDS

 AllowDups = @TRUE

 OutArray = ''

 GOSUB RESORT.U2:

*

 scrPos += 2

 CRT @(3,scrPos):Time taken so far after U2 version sort :
:OCONV(((DATE()[EMAIL PROTECTED])*8400)+(TIME()[EMAIL PROTECTED]),MTS)

 CRT

 CRT *** END ***

*

 RETURN

*

*

RESORT.C:

*

 RECORD = VARIDS

 scrPos += 2

 CRT @(3,scrPos):Start sort function (C) version -- # of VM's
:COUNT(RECORD1,@VM)

 PARAM = DR,1

 CALL REORDER

*

 RETURN

*

*

RESORT.U2:

*

 scrPos += 2

 CRT @(3,scrPos):Start sort U2 version -- # of VM's
:COUNT(InArray,@VM)

 If SortBy =  then SortBy = AL

*OutArray   = Remove(InArray, MoreItems)

*ArrayDelim = @RM:@AM:@VM:@SM:@TM[MoreItems, 1]

*

 LOOP

Item = Remove(InArray, MoreItems)

Locate Item in OutArray by SortBy setting Pos then

   If AllowDups then Ins Item before OutArrayPos

End else

   Ins Item before OutArrayPos

End

 While MoreItems Do

 Repeat

*

* SWAP @AM, ArrayDelim in OutArray

*

 RETURN

*



~

Test results:



1.

*** START ***

Number of ids  99

Start Time for RND function : 09:57:08 24 JUL 2008

Time taken so far after RND build : 00:00:10

Start sort function (C) version -- # of VM's 98

Time taken so far after C version sort : 00:00:30

Start sort U2 version -- # of VM's 98

Break: Option (A,C,L,Q,?) =A

DEV TIME

10:22:11 24 JUL 2008

DEV 





2.

*** START ***

Number of ids  1000

Start Time for RND function : 10:29:36 24 JUL 2008

Time taken so far after RND build : 00:00:05

Start sort function (C) version -- # of VM's 999

Time taken so far after C version sort : 00:00:05

Start sort U2 version -- # of VM's 999

Time taken so far after U2 version sort : 00:00:06

*** END ***



3.

*** START ***

Number of ids  1

Start Time for RND function : 10:30:07 24 JUL 2008

Time taken so far after RND build : 00:00:04

Start sort function (C) version -- # of VM's 

Time taken so far after C version sort : 00:00:04

Start sort U2 version -- # of VM's 

Time taken so far after U2 version sort : 00:00:22

*** END ***



4.

*** START ***

Number of ids  2

Start Time for RND function : 10:53:51 24 JUL 2008

Time taken so far after RND build : 00:00:07

Start sort function (C) version -- # of VM's 1

Time taken so far after C version sort : 00:00:07

Start sort U2 version -- # of VM's 1

Time taken so far after U2 version sort : 00:01:26

*** END ***



5.

*** START ***

Number of ids  5

Start Time for RND function : 10:56:26 24 JUL 2008

Time taken so far after RND build : 00:00:03

Start sort function (C) version -- # of VM's 4

Time taken so far after C version sort : 00:00:04

Start sort U2 version -- # of VM's 4

Time taken so far after U2 version sort : 00:08:38

*** END ***




The information contained in this email and any attached files are strictly
private and confidential. This email should 

RE: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-22 Thread Norman Morgan
Here's a Basic routine I use in UD:

SUBROUTINE QUICKSORT(ARRAY)
*** Quick Sort the elements of a dynamic array
 EQU AM TO CHAR(254)
 VALUES = DCOUNT(ARRAY,AM)
 IF VALUES = 1 THEN RETURN
 PIVOT = ARRAY1;** First element
 HIGHSTRING = ''; ** list of elements  pivot
 LOWSTRING = '';  ** list of elements  pivot
 FOR X = 2 TO VALUES
ELEMENT = ARRAYX
IF ELEMENT  PIVOT THEN
   HIGHSTRING-1 = ELEMENT
END ELSE
   LOWSTRING-1 = ELEMENT
END
 NEXT X
 CALL QUICKSORT(LOWSTRING)
 CALL QUICKSORT(HIGHSTRING)
 ARRAY = 
 IF LOWSTRING #  THEN ARRAY-1 = LOWSTRING
 IF PIVOT #  THEN ARRAY-1 = PIVOT
 IF HIGHSTRING #  THEN ARRAY-1 = HIGHSTRING
 RETURN

===
Norman Morgan  [EMAIL PROTECTED]  http://www.brake.com
===
You are in a maze of twisty subroutines, all alike!
===

 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Baker Hughes
 Sent: Tuesday, July 22, 2008 9:51 AM
 To: 'u2-users@listserver.u2ug.org'
 Subject: [U2] Basic SORT() Function not avail in UniVerse?
 
 Hey,
 
 I'm needing to SORT a dynamic array and apparently UniVerse 
 doesn't have this Function.
 
 Other MV implementations have this, such as D3 - The sort() 
 function sorts an attribute or value mark delimited str.exp 
 in ascending order. [from ePick]
 
 There was also a user exit u1072 that did the same thing.
 
 Does anyone have a work around or fast path to same thing 
  maybe I'm missing something but can't see this in UV docs.
 
 -Baker
 ---
 u2-users mailing list
 u2-users@listserver.u2ug.org
 To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-22 Thread Brian Leach
Baker

Off the top of my head:

FUNCTION SortArray(InArray, AllowDups)
Dc = DCount(InArray,@FM)
OutArray = ''
For I = 1 To Dc
  Locate InArrayI In OutArray By AL Setting Pos Then
   If AllowDups Then Ins InArrayI Before OutArrayPos
  End Else
   Ins InArrayI Before OutArrayPos
  End
Next
Return(OutArray)


Then add DEFFUN SortArray(InArray, AllowDups) to your calling routine.

Brian

Hey,

I'm needing to SORT a dynamic array and apparently UniVerse doesn't have this
Function.

Other MV implementations have this, such as D3 - The sort() function sorts an
attribute or value mark delimited str.exp in ascending order. [from ePick]

There was also a user exit u1072 that did the same thing.

Does anyone have a work around or fast path to same thing  maybe I'm
missing something but can't see this in UV docs.

-Baker
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-22 Thread Israel, John R.
Note that if the array is big, you would get much better performance by loading 
it into a DIM array, so the sort of sort below, then put the results back into 
a dynamic array.

Dynamic arrays are much easier to use, but when used wisely, dimensioned arrays 
can be MUCH faster.  This is true for any application, esp. looping through 
multi-values.

John Israel


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of DAVID WADEMAN
Sent: Tuesday, July 22, 2008 1:00 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

This is a UniData subroutine, but should work 

SUBROUTINE B42.SORT.ARRAY(SORTED,ARRAY)
* Bubble sort the elements of a dynamic array
* Created by: David Wademan
* Creation Date: 01/05/05
SORTED=
VALUES = DCOUNT(ARRAY,@VM)
LOOP
   CHANGES = 0
   FOR X = 2 TO VALUES
  * For each adjacent pair
  ELEMENT1 = ARRAY1,X-1
  ELEMENT2 = ARRAY1,X

  IF ELEMENT2  ELEMENT1 THEN
 * Swap if pair out of sequence
 ARRAY1,X = ELEMENT1
 ARRAY1,X-1 = ELEMENT2
 CHANGES = 1
  END
   NEXT X
WHILE CHANGES DO REPEAT
SORTED=ARRAY
RETURN

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Baker Hughes
Sent: Tuesday, July 22, 2008 10:51 AM
To: 'u2-users@listserver.u2ug.org'
Subject: [U2] Basic SORT() Function not avail in UniVerse?

Hey,

I'm needing to SORT a dynamic array and apparently UniVerse doesn't have
this
Function.

Other MV implementations have this, such as D3 - The sort() function
sorts an
attribute or value mark delimited str.exp in ascending order. [from
ePick]

There was also a user exit u1072 that did the same thing.

Does anyone have a work around or fast path to same thing  maybe I'm
missing something but can't see this in UV docs.

-Baker
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-22 Thread Baker Hughes
Thank you Bill, Brian  Norman,

If I'm allowed to deploy a separate Function or Sub you've virtually coded it 
for me.

-Baker
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-22 Thread Symeon Breen
One thing I would say on this is never presume - experiment - I have been
stung in the past when using remove on the dynamic array portion of a
dimensioned array - turned out to be faster to have the whole thing
dynamic..




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Israel, John R.
Sent: 22 July 2008 18:26
To: 'u2-users@listserver.u2ug.org'
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

Note that if the array is big, you would get much better performance by
loading it into a DIM array, so the sort of sort below, then put the results
back into a dynamic array.

Dynamic arrays are much easier to use, but when used wisely, dimensioned
arrays can be MUCH faster.  This is true for any application, esp. looping
through multi-values.

John Israel


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of DAVID WADEMAN
Sent: Tuesday, July 22, 2008 1:00 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

This is a UniData subroutine, but should work 

SUBROUTINE B42.SORT.ARRAY(SORTED,ARRAY)
* Bubble sort the elements of a dynamic array
* Created by: David Wademan
* Creation Date: 01/05/05
SORTED=
VALUES = DCOUNT(ARRAY,@VM)
LOOP
   CHANGES = 0
   FOR X = 2 TO VALUES
  * For each adjacent pair
  ELEMENT1 = ARRAY1,X-1
  ELEMENT2 = ARRAY1,X

  IF ELEMENT2  ELEMENT1 THEN
 * Swap if pair out of sequence
 ARRAY1,X = ELEMENT1
 ARRAY1,X-1 = ELEMENT2
 CHANGES = 1
  END
   NEXT X
WHILE CHANGES DO REPEAT
SORTED=ARRAY
RETURN

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Baker Hughes
Sent: Tuesday, July 22, 2008 10:51 AM
To: 'u2-users@listserver.u2ug.org'
Subject: [U2] Basic SORT() Function not avail in UniVerse?

Hey,

I'm needing to SORT a dynamic array and apparently UniVerse doesn't have
this
Function.

Other MV implementations have this, such as D3 - The sort() function
sorts an
attribute or value mark delimited str.exp in ascending order. [from
ePick]

There was also a user exit u1072 that did the same thing.

Does anyone have a work around or fast path to same thing  maybe I'm
missing something but can't see this in UV docs.

-Baker
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
No virus found in this incoming message.
Checked by AVG - http://www.avg.com 
Version: 8.0.138 / Virus Database: 270.5.3/1565 - Release Date: 7/21/2008
6:36 PM
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-22 Thread Allen E. Elwood
Hey, and don't forget to do a speed test.  You know, because LOCATE is coded
as part of the OS it just *might* be faster than bubble or speed sort
options.

In fact, this was a topic on this list about 3 or 4 years ago and someone
doing the speed test concluded LOCATE was in fact faster.

And no I don't remember who it was, or have a link to the thread (sorry)

:-)

Allen

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Israel, John R.
Sent: Tuesday, July 22, 2008 10:26
To: 'u2-users@listserver.u2ug.org'
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?


Note that if the array is big, you would get much better performance by
loading it into a DIM array, so the sort of sort below, then put the results
back into a dynamic array.

Dynamic arrays are much easier to use, but when used wisely, dimensioned
arrays can be MUCH faster.  This is true for any application, esp. looping
through multi-values.

John Israel


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of DAVID WADEMAN
Sent: Tuesday, July 22, 2008 1:00 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

This is a UniData subroutine, but should work 

SUBROUTINE B42.SORT.ARRAY(SORTED,ARRAY)
* Bubble sort the elements of a dynamic array
* Created by: David Wademan
* Creation Date: 01/05/05
SORTED=
VALUES = DCOUNT(ARRAY,@VM)
LOOP
   CHANGES = 0
   FOR X = 2 TO VALUES
  * For each adjacent pair
  ELEMENT1 = ARRAY1,X-1
  ELEMENT2 = ARRAY1,X

  IF ELEMENT2  ELEMENT1 THEN
 * Swap if pair out of sequence
 ARRAY1,X = ELEMENT1
 ARRAY1,X-1 = ELEMENT2
 CHANGES = 1
  END
   NEXT X
WHILE CHANGES DO REPEAT
SORTED=ARRAY
RETURN

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Baker Hughes
Sent: Tuesday, July 22, 2008 10:51 AM
To: 'u2-users@listserver.u2ug.org'
Subject: [U2] Basic SORT() Function not avail in UniVerse?

Hey,

I'm needing to SORT a dynamic array and apparently UniVerse doesn't have
this
Function.

Other MV implementations have this, such as D3 - The sort() function
sorts an
attribute or value mark delimited str.exp in ascending order. [from
ePick]

There was also a user exit u1072 that did the same thing.

Does anyone have a work around or fast path to same thing  maybe I'm
missing something but can't see this in UV docs.

-Baker
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Basic SORT() Function not avail in UniVerse?

2008-07-22 Thread Jeff Marcos
We had the same issue back in the 90's. So a clever guy (Ed) that worked
with us wrote a small C program (on Unix) to do the sort. This also
included controlling/dependants fields. Any universe program could call
it, passing in the variables and returned the items sorted.

Speed is incredible. To this day it's still used and blitzes any
universe program methods in sorting large arrays. 

Regards,
Jeff Marcos

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Allen E. Elwood
Sent: Wednesday, 23 July 2008 6:59 AM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

Hey, and don't forget to do a speed test.  You know, because LOCATE is
coded
as part of the OS it just *might* be faster than bubble or speed sort
options.

In fact, this was a topic on this list about 3 or 4 years ago and
someone
doing the speed test concluded LOCATE was in fact faster.

And no I don't remember who it was, or have a link to the thread (sorry)

:-)

Allen

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Israel, John R.
Sent: Tuesday, July 22, 2008 10:26
To: 'u2-users@listserver.u2ug.org'
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?


Note that if the array is big, you would get much better performance by
loading it into a DIM array, so the sort of sort below, then put the
results
back into a dynamic array.

Dynamic arrays are much easier to use, but when used wisely, dimensioned
arrays can be MUCH faster.  This is true for any application, esp.
looping
through multi-values.

John Israel


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of DAVID WADEMAN
Sent: Tuesday, July 22, 2008 1:00 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Basic SORT() Function not avail in UniVerse?

This is a UniData subroutine, but should work 

SUBROUTINE B42.SORT.ARRAY(SORTED,ARRAY)
* Bubble sort the elements of a dynamic array
* Created by: David Wademan
* Creation Date: 01/05/05
SORTED=
VALUES = DCOUNT(ARRAY,@VM)
LOOP
   CHANGES = 0
   FOR X = 2 TO VALUES
  * For each adjacent pair
  ELEMENT1 = ARRAY1,X-1
  ELEMENT2 = ARRAY1,X

  IF ELEMENT2  ELEMENT1 THEN
 * Swap if pair out of sequence
 ARRAY1,X = ELEMENT1
 ARRAY1,X-1 = ELEMENT2
 CHANGES = 1
  END
   NEXT X
WHILE CHANGES DO REPEAT
SORTED=ARRAY
RETURN

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Baker Hughes
Sent: Tuesday, July 22, 2008 10:51 AM
To: 'u2-users@listserver.u2ug.org'
Subject: [U2] Basic SORT() Function not avail in UniVerse?

Hey,

I'm needing to SORT a dynamic array and apparently UniVerse doesn't have
this
Function.

Other MV implementations have this, such as D3 - The sort() function
sorts an
attribute or value mark delimited str.exp in ascending order. [from
ePick]

There was also a user exit u1072 that did the same thing.

Does anyone have a work around or fast path to same thing  maybe I'm
missing something but can't see this in UV docs.

-Baker
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

The information contained in this email and any attached files are strictly
private and confidential. This email should be read by the intended addressee
only.  If the recipient of this message is not the intended addressee, please
call Corporate Express Australia Limited on +61 2 9335 0555 or Corporate Express
New Zealand Limited on +64 9 279 2555 and promptly delete this email and any
attachments.  The intended recipient of this email may only use, reproduce,
disclose or distribute the information contained in this email and any attached
files with Corporate Express' permission. If you are not the intended addressee,
you are strictly prohibited from using, reproducing, disclosing or distributing
the information contained in this email and any attached files.  Corporate
Express advises that this email and any attached files should be scanned to
detect viruses. Corporate Express accepts no liability for loss or damage
(whether caused by negligence or not) resulting from the use of any attached
files.
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/