RE: [U2] Sort help needed
This solved my problem. Thanks for all the suggestions. Al -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bob Woodward Sent: Monday, November 07, 2005 6:23 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] Sort help needed The problem is your "ELSE POS=0" statement. You need something like this: LOCATE PART.NBR IN RECORD<14> BY "AL" SETTING POS ELSE INSERT... END In a "THEN" condition, the value is already in RECORD<14>. You only need to do an INSERT when it's not found. When it's not found, POS will contain the position that the new value should be in so just use it. Don't override the value by setting it to zero. BobW > -Original Message- > From: [EMAIL PROTECTED] [mailto:owner-u2- > [EMAIL PROTECTED] On Behalf Of Al DeWitt > Sent: Monday, November 07, 2005 3:27 PM > To: u2-users@listserver.u2ug.org > Subject: [U2] Sort help needed > > Environment: UniData - Pick Flavor > > > > I'm trying to build a multi-value field in part number order. > > > > I begin with LOCATE PART.NBR IN RECORD<14> BY "AL" SETTING POS ELSE POS > = 0 > > > > The first time through RECORD<14> is empty. The second time RECORD<14> > has one value. If PART.NBR is of greater value than what is now in > RECORD<14> then I want PART.NBR to be the second value, if it is of > lesser value than I want PART.NBR to be inserted before the value in > RECORD<14>. > > > > I will then do a second LOCATE to see where PART.NBR is stored > (RECORD<14,x>) and use that position to insert data into associated > attributes. > > > > My problem is that I haven't done this in a while and when I did it was > in Universe. So not only am I suffering a senior moment I'm dealing > with a language barrier. > > > > Any help would be greatly appreciated. > > > > Thanks. > > > > Al DeWitt > > Stylmark, Inc. > --- > 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] Sort help needed
I always use: NFND=0 ; LOCATE WWW IN XXX BY YYY SETTING ZZZ ELSE NFND=1 [IF NFND=1 THEN] INS WWW BEFORE XXX [END] George This way I avoid the NULL, and you can choose at a later time whether you want to INS or not. > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of Keith > W. Roberts > Sent: Tuesday, November 08, 2005 12:45 PM > To: u2-users@listserver.u2ug.org > Subject: RE: [U2] Sort help needed > > > Yep, I did make that [possibly invalid] assumption. > > -Keith > > Original Message > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Womack, Adrian > Sent: Tuesday, November 08, 2005 8:07 AM > To: u2-users@listserver.u2ug.org > Subject: RE: [U2] Sort help needed > > > The original question didn't specify that "PART.NBR" had to > > be unique. Maybe > > it's a list of orders and possibly contains two different > > orders for the same part number. --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] Sort help needed
Yep, I did make that [possibly invalid] assumption. -Keith Original Message From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Womack, Adrian Sent: Tuesday, November 08, 2005 8:07 AM To: u2-users@listserver.u2ug.org Subject: RE: [U2] Sort help needed > The original question didn't specify that "PART.NBR" had to > be unique. Maybe > it's a list of orders and possibly contains two different > orders for the same part number. > > > > From: [EMAIL PROTECTED] on behalf of Keith W. > Roberts Sent: Tue 8/11/2005 11:24 PM To: u2-users@listserver.u2ug.org > Subject: RE: [U2] Sort help needed > > > > Your logic is wrong here; you are inserting whether PART.NBR > is found or > not. The INS should be inside the ELSE clause. > > -Keith > > Original Message > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Womack, Adrian > Sent: Monday, November 07, 2005 4:49 PM > To: u2-users@listserver.u2ug.org > Subject: RE: [U2] Sort help needed > >> LOCATE PART.NBR IN RECORD<14,1> BY "AL" SETTING POSELSE NULL >> >> INS PART.NBR BEFORE RECORD<14,POS> >> INS related.data BEFORE related.field<14,POS> >> >> No need to do the second locate. >> >> Note: I've used the PI/Open syntax for the LOCATE statement (that's >> the only one I relate to), you may have to alter the syntax > slightly. --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] Sort help needed
The original question didn't specify that "PART.NBR" had to be unique. Maybe it's a list of orders and possibly contains two different orders for the same part number. From: [EMAIL PROTECTED] on behalf of Keith W. Roberts Sent: Tue 8/11/2005 11:24 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] Sort help needed Your logic is wrong here; you are inserting whether PART.NBR is found or not. The INS should be inside the ELSE clause. -Keith Original Message From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Womack, Adrian Sent: Monday, November 07, 2005 4:49 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] Sort help needed > LOCATE PART.NBR IN RECORD<14,1> BY "AL" SETTING POSELSE NULL > > INS PART.NBR BEFORE RECORD<14,POS> > INS related.data BEFORE related.field<14,POS> > > No need to do the second locate. > > Note: I've used the PI/Open syntax for the LOCATE statement (that's > the only one I relate to), you may have to alter the syntax slightly. --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ DISCLAIMER: Disclaimer. This e-mail is private and confidential. If you are not the intended recipient, please advise us by return e-mail immediately, and delete the e-mail and any attachments without using or disclosing the contents in any way. The views expressed in this e-mail are those of the author, and do not represent those of this company unless this is clearly indicated. You should scan this e-mail and any attachments for viruses. This company accepts no liability for any direct or indirect damage or loss resulting from the use of any attachments to this e-mail. [demime 1.01d removed an attachment of type application/ms-tnef which had a name of winmail.dat] --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] Sort help needed
Your logic is wrong here; you are inserting whether PART.NBR is found or not. The INS should be inside the ELSE clause. -Keith Original Message From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Womack, Adrian Sent: Monday, November 07, 2005 4:49 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] Sort help needed > LOCATE PART.NBR IN RECORD<14,1> BY "AL" SETTING POSELSE NULL > > INS PART.NBR BEFORE RECORD<14,POS> > INS related.data BEFORE related.field<14,POS> > > No need to do the second locate. > > Note: I've used the PI/Open syntax for the LOCATE statement (that's > the only one I relate to), you may have to alter the syntax slightly. --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
Re: [U2] Sort help needed
Sidebar: Did (does) any system require the null expression for DICT in an OPEN statement. Haven't used them since 1978 when I accidentally forgot it and never looked back. Just curious. Mark Johnson - Original Message - From: "Allen E. Elwood" <[EMAIL PROTECTED]> To: Sent: Monday, November 07, 2005 7:24 PM Subject: RE: [U2] Sort help needed > Here's a generic sort routine to use as an example. It is capable of > sorting any number of attributes in a file. Basically, after using LOCATE > you have to use INSERT. > > *TEST.SORT Sort unlimited associated fields off of one field > OPEN "", "ORDER.BACK" TO ORDER.BACK ELSE PRINT "GAA";STOP > ORD = "" > ORD<11> = CHANGE('789,456,123',",",@VM) > ORD<12> = CHANGE('1,2,3',",",@VM) > ORD<13> = CHANGE('4,5,6',",",@VM) > ORD<14> = CHANGE('SOMETHING, THAT, SHOULDNOTCHANGE',",",@VM) > ORD<31> = CHANGE('7,8,9',",",@VM) > ORD<32> = CHANGE('10,11,12',",",@VM) > > * Setup Parameters > SORT.REC = ORD > ATTR.LIST = "12,13,31,32" > ATTR.LIST = CHANGE(ATTR.LIST, ",", @AM) > ATTR.COUNT = DCOUNT(ATTR.LIST,@AM) > DATA.BASE = "" > SORT.ATTR = 11 > SORT.BASE = "" > SORT.COUNT = DCOUNT(SORT.REC,@VM) > * Sort the data based off of the sort attribute in the sort record > FOR SORT.I = 1 TO SORT.COUNT > SORT.VALUE = SORT.REC > LOCATE SORT.VALUE IN SORT.BASE<1>,1 BY 'AR' SETTING SORT.INDEX ELSE NULL > SORT.BASE = INSERT(SORT.BASE, 1, SORT.INDEX, 0, SORT.VALUE) > FOR ATTR.I = 1 TO ATTR.COUNT > ATTR = ATTR.LIST > ATTR.VALUE = SORT.REC > DATA.BASE = INSERT(DATA.BASE, 1, SORT.INDEX, 0, > ATTR.VALUE) > NEXT ATTR.I > NEXT SORT.I > * Replace the sort record with the sorted values > SORT.REC = SORT.BASE > FOR ATTR.I = 1 TO ATTR.COUNT > ATTR = ATTR.LIST > SORT.REC = DATA.BASE > NEXT ATTR.I > ORD = SORT.REC > WRITE ORD ON ORDER.BACK, 'TEST.SORT' > STOP > > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of Al DeWitt > Sent: Monday, November 07, 2005 15:27 > To: u2-users@listserver.u2ug.org > Subject: [U2] Sort help needed > > > Environment: UniData - Pick Flavor > > > > I'm trying to build a multi-value field in part number order. > > > > I begin with LOCATE PART.NBR IN RECORD<14> BY "AL" SETTING POS ELSE POS > = 0 > > > > The first time through RECORD<14> is empty. The second time RECORD<14> > has one value. If PART.NBR is of greater value than what is now in > RECORD<14> then I want PART.NBR to be the second value, if it is of > lesser value than I want PART.NBR to be inserted before the value in > RECORD<14>. > > > > I will then do a second LOCATE to see where PART.NBR is stored > (RECORD<14,x>) and use that position to insert data into associated > attributes. > > > > My problem is that I haven't done this in a while and when I did it was > in Universe. So not only am I suffering a senior moment I'm dealing > with a language barrier. > > > > Any help would be greatly appreciated. > > > > Thanks. > > > > Al DeWitt > > Stylmark, Inc. > --- > 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] Sort help needed
LOCATE PART.NBR IN RECORD<14,1> BY "AL" SETTING POS ELSE NULL INS PART.NBR BEFORE RECORD<14,POS> INS related.data BEFORE related.field<14,POS> No need to do the second locate. Note: I've used the PI/Open syntax for the LOCATE statement (that's the only one I relate to), you may have to alter the syntax slightly. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Al DeWitt Sent: Tuesday, 8 November 2005 7:27 AM To: u2-users@listserver.u2ug.org Subject: [U2] Sort help needed Environment: UniData - Pick Flavor I'm trying to build a multi-value field in part number order. I begin with LOCATE PART.NBR IN RECORD<14> BY "AL" SETTING POS ELSE POS = 0 The first time through RECORD<14> is empty. The second time RECORD<14> has one value. If PART.NBR is of greater value than what is now in RECORD<14> then I want PART.NBR to be the second value, if it is of lesser value than I want PART.NBR to be inserted before the value in RECORD<14>. I will then do a second LOCATE to see where PART.NBR is stored (RECORD<14,x>) and use that position to insert data into associated attributes. My problem is that I haven't done this in a while and when I did it was in Universe. So not only am I suffering a senior moment I'm dealing with a language barrier. Any help would be greatly appreciated. Thanks. Al DeWitt Stylmark, Inc. --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ DISCLAIMER: Disclaimer. This e-mail is private and confidential. If you are not the intended recipient, please advise us by return e-mail immediately, and delete the e-mail and any attachments without using or disclosing the contents in any way. The views expressed in this e-mail are those of the author, and do not represent those of this company unless this is clearly indicated. You should scan this e-mail and any attachments for viruses. This company accepts no liability for any direct or indirect damage or loss resulting from the use of any attachments to this e-mail. --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
Re: [U2] Sort help needed
Hi Al, Is LOCATE different in UniData & UniVerse? I think your ELSE is the problem - it is taken if the item is not found. Try: LOCATE(PART.NBR,RECORD,14;'AL',POS) ELSE INS PART.NBR BEFORE RECORD<14,POS> END Good luck! Kate - Original Message - From: "Al DeWitt" <[EMAIL PROTECTED]> To: Sent: Tuesday, November 08, 2005 12:26 PM Subject: [U2] Sort help needed Environment: UniData - Pick Flavor I'm trying to build a multi-value field in part number order. I begin with LOCATE PART.NBR IN RECORD<14> BY "AL" SETTING POS ELSE POS = 0 The first time through RECORD<14> is empty. The second time RECORD<14> has one value. If PART.NBR is of greater value than what is now in RECORD<14> then I want PART.NBR to be the second value, if it is of lesser value than I want PART.NBR to be inserted before the value in RECORD<14>. I will then do a second LOCATE to see where PART.NBR is stored (RECORD<14,x>) and use that position to insert data into associated attributes. My problem is that I haven't done this in a while and when I did it was in Universe. So not only am I suffering a senior moment I'm dealing with a language barrier. Any help would be greatly appreciated. Thanks. Al DeWitt Stylmark, Inc. --- 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] Sort help needed
Here's a generic sort routine to use as an example. It is capable of sorting any number of attributes in a file. Basically, after using LOCATE you have to use INSERT. *TEST.SORT Sort unlimited associated fields off of one field OPEN "", "ORDER.BACK" TO ORDER.BACK ELSE PRINT "GAA";STOP ORD = "" ORD<11> = CHANGE('789,456,123',",",@VM) ORD<12> = CHANGE('1,2,3',",",@VM) ORD<13> = CHANGE('4,5,6',",",@VM) ORD<14> = CHANGE('SOMETHING, THAT, SHOULDNOTCHANGE',",",@VM) ORD<31> = CHANGE('7,8,9',",",@VM) ORD<32> = CHANGE('10,11,12',",",@VM) * Setup Parameters SORT.REC = ORD ATTR.LIST = "12,13,31,32" ATTR.LIST = CHANGE(ATTR.LIST, ",", @AM) ATTR.COUNT = DCOUNT(ATTR.LIST,@AM) DATA.BASE = "" SORT.ATTR = 11 SORT.BASE = "" SORT.COUNT = DCOUNT(SORT.REC,@VM) * Sort the data based off of the sort attribute in the sort record FOR SORT.I = 1 TO SORT.COUNT SORT.VALUE = SORT.REC LOCATE SORT.VALUE IN SORT.BASE<1>,1 BY 'AR' SETTING SORT.INDEX ELSE NULL SORT.BASE = INSERT(SORT.BASE, 1, SORT.INDEX, 0, SORT.VALUE) FOR ATTR.I = 1 TO ATTR.COUNT ATTR = ATTR.LIST ATTR.VALUE = SORT.REC DATA.BASE = INSERT(DATA.BASE, 1, SORT.INDEX, 0, ATTR.VALUE) NEXT ATTR.I NEXT SORT.I * Replace the sort record with the sorted values SORT.REC = SORT.BASE FOR ATTR.I = 1 TO ATTR.COUNT ATTR = ATTR.LIST SORT.REC = DATA.BASE NEXT ATTR.I ORD = SORT.REC WRITE ORD ON ORDER.BACK, 'TEST.SORT' STOP -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Al DeWitt Sent: Monday, November 07, 2005 15:27 To: u2-users@listserver.u2ug.org Subject: [U2] Sort help needed Environment: UniData - Pick Flavor I'm trying to build a multi-value field in part number order. I begin with LOCATE PART.NBR IN RECORD<14> BY "AL" SETTING POS ELSE POS = 0 The first time through RECORD<14> is empty. The second time RECORD<14> has one value. If PART.NBR is of greater value than what is now in RECORD<14> then I want PART.NBR to be the second value, if it is of lesser value than I want PART.NBR to be inserted before the value in RECORD<14>. I will then do a second LOCATE to see where PART.NBR is stored (RECORD<14,x>) and use that position to insert data into associated attributes. My problem is that I haven't done this in a while and when I did it was in Universe. So not only am I suffering a senior moment I'm dealing with a language barrier. Any help would be greatly appreciated. Thanks. Al DeWitt Stylmark, Inc. --- 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] Sort help needed
The problem is your "ELSE POS=0" statement. You need something like this: LOCATE PART.NBR IN RECORD<14> BY "AL" SETTING POS ELSE INSERT... END In a "THEN" condition, the value is already in RECORD<14>. You only need to do an INSERT when it's not found. When it's not found, POS will contain the position that the new value should be in so just use it. Don't override the value by setting it to zero. BobW > -Original Message- > From: [EMAIL PROTECTED] [mailto:owner-u2- > [EMAIL PROTECTED] On Behalf Of Al DeWitt > Sent: Monday, November 07, 2005 3:27 PM > To: u2-users@listserver.u2ug.org > Subject: [U2] Sort help needed > > Environment: UniData - Pick Flavor > > > > I'm trying to build a multi-value field in part number order. > > > > I begin with LOCATE PART.NBR IN RECORD<14> BY "AL" SETTING POS ELSE POS > = 0 > > > > The first time through RECORD<14> is empty. The second time RECORD<14> > has one value. If PART.NBR is of greater value than what is now in > RECORD<14> then I want PART.NBR to be the second value, if it is of > lesser value than I want PART.NBR to be inserted before the value in > RECORD<14>. > > > > I will then do a second LOCATE to see where PART.NBR is stored > (RECORD<14,x>) and use that position to insert data into associated > attributes. > > > > My problem is that I haven't done this in a while and when I did it was > in Universe. So not only am I suffering a senior moment I'm dealing > with a language barrier. > > > > Any help would be greatly appreciated. > > > > Thanks. > > > > Al DeWitt > > Stylmark, Inc. > --- > 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] Sort help needed
Environment: UniData - Pick Flavor I'm trying to build a multi-value field in part number order. I begin with LOCATE PART.NBR IN RECORD<14> BY "AL" SETTING POS ELSE POS = 0 The first time through RECORD<14> is empty. The second time RECORD<14> has one value. If PART.NBR is of greater value than what is now in RECORD<14> then I want PART.NBR to be the second value, if it is of lesser value than I want PART.NBR to be inserted before the value in RECORD<14>. I will then do a second LOCATE to see where PART.NBR is stored (RECORD<14,x>) and use that position to insert data into associated attributes. My problem is that I haven't done this in a while and when I did it was in Universe. So not only am I suffering a senior moment I'm dealing with a language barrier. Any help would be greatly appreciated. Thanks. Al DeWitt Stylmark, Inc. --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/