WLISTU pulls up the list sorted by date and time, and allows you to resort it 
by PID.
It could be easily modified to allow sorting on any of the columns

FFT.BP 'WLISTU' BASIC 71 lines  Level: 3
0001 *
0002 * Writen Aug 2012 by Will Johnson
0003 * This routine sorts the LISTU table by date and then by time
0004 * Builds a multi-sub-valued table, so the times get sorted right
0005 * Then swaps the SVMs for VMs so it becomes a regular table
0006 * Then it also allows you to resort it by PID
0007 *
0008       EQUATE FALSE TO 0, TRUE TO 1
0009       TODAY = DATE() ; THIS.YEAR = OCONV(TODAY,'DY')
0010       SWITCH = "DATE" ; EXIT.PROGRAM = FALSE
0011       LOOP
0012          EXECUTE "LISTU", OUT > RESULTS
0013          SELECTV RESULTS TO L.RESULTS
0014          DONE = FALSE ; CNT = 0 ; HEADERS = '' ; TABLE = ''
0015          LOOP
0016             READNEXT LINE FROM L.RESULTS ELSE DONE = TRUE
0017          UNTIL DONE DO
0018             CNT += 1
0019             T.PID = LINE[16,5]
0020             T.TIMEDATE = LINE[62,13]
0021             T.DATE = OCONV(T.TIMEDATE,'G0 2'):' ':THIS.YEAR
0022             T.TIME = OCONV(T.TIMEDATE,'G2 1')
0023             IF SWITCH = "DATE" THEN GOSUB BY.DATE.AND.TIME
0024             IF SWITCH = "PID" THEN GOSUB BY.PID
0025          REPEAT
0026          TABLE<1> = HEADERS:@VM:TABLE<1>
0027          TABLE = CONVERT(@SVM,@VM,TABLE)
0028 *
0029          S.TABLE = DCOUNT(TABLE<1>,@VM)
0030          FOR I.TABLE = 1 TO S.TABLE
0031             IF TABLE<1,I.TABLE> # '' THEN
0032                PRINT I.TABLE'R%2':' ':TABLE<1,I.TABLE>
0033             END
0034          NEXT I.TABLE
0035          DISPLAY "SORT BY (D)ATE, (P)ID, OR (Q)UIT ": ; INPUT ANYTHING
0036          BEGIN CASE
0037             CASE ANYTHING = 'Q' ; EXIT.PROGRAM = TRUE
0038             CASE ANYTHING = 'P' ; SWITCH = 'PID'
0039             CASE ANYTHING = 'D' ; SWITCH = 'DATE'
0040          END CASE
0041       UNTIL EXIT.PROGRAM DO REPEAT
0042       STOP
0043 *
0044 BY.DATE.AND.TIME:
0045       I.DATE = ICONV(T.DATE,'D') ; I.TIME = ICONV(T.TIME,'MT')
0046       IF STATUS() THEN
0047          HEADERS<1,-1> = LINE
0048       END ELSE
0049          LOCATE I.DATE IN TABLE<2,1> BY 'AR' SETTING W.DATE ELSE
0050             TABLE = INSERT(TABLE,1,W.DATE;'')
0051             TABLE = INSERT(TABLE,2,W.DATE;I.DATE)
0052             TABLE = INSERT(TABLE,3,W.DATE;'')
0053          END
0054          LOCATE I.TIME IN TABLE<3,W.DATE,1> BY 'AR' SETTING W.TIME ELSE
0055             NULL
0056          END
0057          TABLE = INSERT(TABLE,1,W.DATE,W.TIME;LINE)
0058          TABLE = INSERT(TABLE,3,W.DATE,W.TIME;I.TIME)
0059       END
0060       RETURN
0061 *
0062 BY.PID:
0063       IF NUM(T.PID) THEN
0064          T.PID = TRIM(T.PID) + 0
0065          LOCATE T.PID IN TABLE<2,1> BY 'AR' SETTING W.PID ELSE NULL
0066          TABLE = INSERT(TABLE,1,W.PID;LINE)
0067          TABLE = INSERT(TABLE,2,W.PID;T.PID)
0068       END ELSE HEADERS<1,-1> = LINE
0069       RETURN
0070 *
0071    END 
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to