home *** CD-ROM | disk | FTP | other *** search
- /*
- * FindKey.tlog
- * AREXX report for TLog that prints misc. data for all entries with
- * SearchKey as a substring of the key field.
- */
-
-
- /* The key to search for is the 1st parameter */
- PARSE UPPER ARG SearchKey
-
-
-
- OPTIONS RESULTS
- OPTIONS FAILAT 10
- SIGNAL ON ERROR
-
- /* add the necessary libraries */
- IF(~EXISTS("libs:rexxsupport.library")|~EXISTS("libs:rexxarplib.library")|~EXISTS("libs:screenshare.library")) THEN
- DO
- SAY "Couldn't find needed library (rexxsupport, rexxarplib, screenshare, or rexxmathlib)."
- EXIT 20
- END
-
- IF ~SHOW('L','rexxsupport.library') THEN
- CALL ADDLIB('rexxsupport.library',0,-30)
- IF ~SHOW('L','rexxarplib.library') THEN
- CALL ADDLIB('rexxarplib.library',0,-30)
- IF ~SHOW('L','rexxmathlib.library') THEN
- CALL ADDLIB('rexxmathlib.library',0,-30)
-
-
- /* setup the port to tlog */
- ADDRESS 'TLOG'
-
-
- /* Open our window */
- CALL open out,"con:0/0/640/170/FindKey " || SearchKey
- IF ~RESULT THEN DO
- SAY "Open failure ... sorry"
- EXIT 10
- END
- CSI = '9B'x
-
-
-
- /* use TLog dateformat MMM DD YY and grab the 1st 3 chars as the month */
- GetDateFormat
- oldFormat = RESULT
- DateFormat 4
-
- /*
- * IF you have been making entries into the data base, it is best to
- * flush its buffers by doing a close first
- */
- CloseDB
-
-
- /* Open the data base and mark the end record */
- OpenDB
- LastRec
- lastDataRecord = RESULT
-
-
- CALL SCREENTOFRONT()
-
- CALL writech out, "TLog records containing subkey: "
- CALL writech out, CSI'0;33;40m'
- CALL writech out, SearchKey
- CALL writeln out, CSI'0;31;40m'
-
- /* get the first record and its data */
- FirstRec
-
- /* Now loop forever, or until nextrec yields the last record */
- DO FOREVER
- /* After the date, the fields in a record are delineated by spaces */
- PARSE VAR RESULT '"' dbdate '"' dbheart dbdist dbtime dbweight dbtemp dbkey
- PARSE UPPER VAR dbkey testkey '.'
- /* Is the SearchKey is a substring of the current key? */
- IF INDEX(testkey, SearchKey, 1) ~= 0 THEN DO
- /* here you can do what you want with the found record */
- CALL writeln out, "Date " dbdate " Distance " dbdist " Time " dbtime " Key " dbkey
- END
-
- IF RESULT = lastDataRecord THEN BREAK
- NextRec
- END
-
- /* restore the date format */
- DateFormat oldFormat
-
-
- CALL writeln out, " "
- /* put up prompt in color 2 */
- CALL writech out, CSI'0;32;40m'
- CALL writeln out, "Press <Return> to EXIT"
- CALL readln out
-
- CALL SCREENTOBACK()
-
- EXIT
-
-
- ERROR:
-
- CALL writeln out, " "
- /* put up prompt in color 2 */
- CALL writech out, CSI'0;32;40m'
- CALL writeln out, "Press <Return> to EXIT"
- CALL readln out
-
- CALL SCREENTOBACK()
-
- EXIT RC
-
-