In most cases the members are subroutine sources (:T) and executable (:O) pairs with the same family and base member name.
Many of these routines are used by the dialogs in the default main menu.
SUBROUTINE TOOLS.BUFDLG (buffer_name) RETURNING (rc)
PROGRAM INTEGER RC DELETE BUFFER "MESSAGE" CREATE BUFFER "MESSAGE" PUT LINE TO BUFFER "MESSAGE" NUMBERED 1 FROM " This is an example of using" PUT LINE TO BUFFER "MESSAGE" NUMBERED 2 FROM " SYSPROC.TOOLS.BUFDLG" EXECUTE SYSPROC.TOOLS.BUFDLG("MESSAGE") RETURNING (RC) END PROGRAM
SUBROUTINE TOOLS.BUFFCOPY (source, target)
PROGRAM INTEGER RC DELETE BUFFER "MESSAGE" CREATE BUFFER "MESSAGE" PUT LINE TO BUFFER "MESSAGE" NUMBERED 1 FROM "This is an example of using BUFFCOPY" EXECUTE SYSPROC.TOOLS.BUFFCOPY ("MESSAGE","NEW MESSAGE") END PROGRAM
SUBROUTINE TOOLS.BUFFEDIT (title, buffer_name, rows, cols)
PROGRAM INTEGER RC DELETE BUFFER "MESSAGE" CREATE BUFFER "MESSAGE" PUT LINE TO BUFFER "MESSAGE" NUMBERED 1 FROM "This is an example of using BUFFEDIT" EXECUTE SYSPROC.TOOLS.BUFFEDIT ("Edit This..." "MESSAGE",4,50) END PROGRAM
SUBROUTINE TOOLS.BUFFFIND (buffer_name, string) RETURNING (line)
PROGRAM INTEGER RC DELETE BUFFER "MESSAGE" CREATE BUFFER "MESSAGE" PUT LINE TO BUFFER "MESSAGE" NUMBERED 1 FROM "apples" PUT LINE TO BUFFER "MESSAGE" NUMBERED 2 FROM "bananas" PUT LINE TO BUFFER "MESSAGE" NUMBERED 3 FROM "needles" PUT LINE TO BUFFER "MESSAGE" NUMBERED 4 FROM "pawpaw" EXECUTE SYSPROC.TOOLS.BUFFFIND ("MESSAGE", "needles") RETURNING (RC) IFTHEN (RC GT 0) WRITE "Found at " RC ELSE WRITE "Not found" ENDIF END PROGRAM
SUBROUTINE TOOLS.BUFFMAKE (buffer_name) RETURNING (rc)
(If you want to create a buffer and want to clear it if it does exist then use
DELETE BUFFER name CREATE BUFFER nameAs CREATE BUFFER will give an error if the buffer exists but DELETE BUFFER will not give an error if the buffer does not exist.)
PROGRAM INTEGER RC EXECUTE SYSPROC.TOOLS.BUFFMAKE("MESSAGE") RETURNING (RC) END PROGRAM
SUBROUTINE TOOLS.BUFFSIZE (buffer_name) RETURNING (lines)
PROGRAM INTEGER LINES DELETE BUFFER "MESSAGE" CREATE BUFFER "MESSAGE" PUT LINE TO BUFFER "MESSAGE" NUMBERED 1 FROM "apples" PUT LINE TO BUFFER "MESSAGE" NUMBERED 2 FROM "bananas" PUT LINE TO BUFFER "MESSAGE" NUMBERED 3 FROM "needles" PUT LINE TO BUFFER "MESSAGE" NUMBERED 4 FROM "pawpaw" EXECUTE SYSPROC.TOOLS.BUFFSIZE("MESSAGE") RETURNING (LINES) WRITE "MESSAGE is " LINES " lines long" END PROGRAM
SUBROUTINE TOOLS.BUFFSORT (buffer_name, target, ord)
PROGRAM INTEGER LINES DELETE BUFFER "MESSAGE" CREATE BUFFER "MESSAGE" PUT LINE TO BUFFER "MESSAGE" NUMBERED 1 FROM "pawpaw" PUT LINE TO BUFFER "MESSAGE" NUMBERED 2 FROM "bananas" PUT LINE TO BUFFER "MESSAGE" NUMBERED 3 FROM "needles" PUT LINE TO BUFFER "MESSAGE" NUMBERED 4 FROM "apples" EXECUTE SYSPROC.TOOLS.BUFFSORT("MESSAGE","NEW MESSAGE","A") EXECUTE SYSPROC.TOOLS.BUFFEDIT("Sorted","NEW MESSAGE",6,30) END PROGRAM
SUBROUTINE TOOLS.BUFRDLG (buffer_name) RETURNING (rc)
PROGRAM INTEGER RC DELETE BUFFER "MESSAGE" CREATE BUFFER "MESSAGE" PUT LINE TO BUFFER "MESSAGE" NUMBERED 1 FROM "<center>An example of using<br>" PUT LINE TO BUFFER "MESSAGE" NUMBERED 2 FROM "<b>SYSPROC.TOOLS.BUFRDLG</b></center>" EXECUTE SYSPROC.TOOLS.BUFRDLG("MESSAGE") RETURNING (RC) END PROGRAM
SUBROUTINE TOOLS.CNTRLPOP (id, type, opt1) RETURNING (num)
SET PROCFILE SYSPROC SET FAMILY TOOLS PROGRAM INTEGER*2 M_ID, M_ARG1, M_ARG2 INTEGER NUM DIALOG "The TOOLS Family" LIST 1 , 0, 8, 0, 80, 0 INITIAL EXECUTE SYSPROC.TOOLS.CNTRLPOP (1,"MEMBER","TE") RETURNING (NUM) END INITIAL MESSAGE ALL M_ID, M_ARG1, M_ARG2 IF (M_ID EQ 0) EXIT MESSAGE END MESSAGE END DIALOG END PROGRAM
SUBROUTINE TOOLS.CNTRLSRT (id, order)
PROGRAM INTEGER*2 M_ID, M_ARG1, M_ARG2 INTEGER*1 ID_00001; PRESET ID_00001 (1 ) DIALOG "Sort A Control" POSTYPE 1 LIST ID_00001, 0, 86, 0, 80, 0 INITIAL APPEND ITEM ID_00001,"TESTING" APPEND ITEM ID_00001,"SORT" APPEND ITEM ID_00001,"CONTROL" APPEND ITEM ID_00001,"USING" APPEND ITEM ID_00001,"A" APPEND ITEM ID_00001,"TOOLS" APPEND ITEM ID_00001,"SUBROUTINE" EXECUTE SYSPROC.TOOLS.CNTRLSRT(ID_00001,1) END INITIAL MESSAGE ALL M_ID, M_ARG1, M_ARG2 IF (M_ID EQ 0) EXIT MESSAGE END MESSAGE END DIALOG END PROGRAM
SUBROUTINE TOOLS.COLRIMG (id, height, width, hexin)
PROGRAM INTEGER*2 M_ID, M_ARG1, M_ARG2 INTEGER*1 ID_00001; PRESET ID_00001 (1 ) DIALOG "Green" POSTYPE 1 IMAGE ID_00001 , 0, 21, 0, 80, 1 INITIAL EXECUTE SYSPROC.TOOLS.COLRIMG (ID_00001,40,120,"#008000") END INITIAL MESSAGE ALL M_ID, M_ARG1, M_ARG2 IF (M_ID EQ 0) EXIT MESSAGE END MESSAGE END DIALOG END PROGRAM
SUBROUTINE TOOLS.COLRPICK (hexin) RETURNING (hexout)
PROGRAM STRING COLOUR EXECUTE SYSPROC.TOOLS.COLRPICK("#FF0000") RETURNING (COLOUR) END PROGRAM
SUBROUTINE TOOLS.DATEPICK (title, default) RETURNING (selected, rc)
PROGRAM DATE SELECTED ("DD MMM YYYY") INTEGER RC EXECUTE SYEPROC.TOOLS.DATEPICK ("Pick A Date...",TODAY(0)) RETURNING (SELECTED,RC) END PROGRAM
SUBROUTINE TOOLS.FILENAME (filename) RETURNING (path, name, ext)
PROGRAM STRING*256 FILENAME PATH NAME STRING*8 EXT INTEGER RC DISPLAY OPENBOX 'Filename','All Files(*.*)|*.*|','',1 RESPONSE RC,FILENAME IFTHEN (RC GT 0) EXECUTE SYSPROC.TOOLS.FILENAME (FILENAME) RETURNING (PATH,NAME,EXT) WRITE PATH / NAME / EXT ENDIF END PROGRAM
SUBROUTINE TOOLS.LONGWRAP (long_string, width, buffer)
RETURNING (lines)
PROGRAM INTEGER RC STRING*4000 LONGSTR COMPUTE LONGSTR = "Call me Ishmael. Some years ago- never mind how long precisely- " + "having little or no money in my purse, and nothing particular " + "to interest me on shore, I thought I would sail about a little " + "and see the watery part of the world." EXECUTE SYSPROC.TOOLS.BUFFMAKE ("WRAPPED") RETURNING (RC) EXECUTE SYSPROC.TOOLS.LONGWRAP (LONGSTR,20,"WRAPPED") RETURNING (RC) EXECUTE SYSPROC.TOOLS.BUFDLG ("WRAPPED") RETURNING (RC) END PROGRAM
SUBROUTINE TOOLS.NAMEFILE (name, ext) RETURNING (filename)
PROGRAM INTEGER RC STRING*256 FILENAME EXECUTE SYSPROC.TOOLS.NAMEFILE ("COMPANY", "exp") RETURNING (FILENAME) WRITE FILENAME END PROGRAM
SUBROUTINE TOOLS.ODBCLIST RETURNING (database)
PROGRAM STRING*80 SOURCE EXECUTE SYSPROC.TOOLS.ODBCLIST RETURNING (SOURCE) WRITE SOURCE END PROGRAM
SUBROUTINE TOOLS.RECSTAT (recnum) RETURNING (status)
PROGRAM INTEGER RC EXECUTE SYSPROC.TOOLS.RECSTAT(2) RETURNING (RC) WRITE "Status = " RC END PROGRAM
SUBROUTINE TOOLS.SCRFILE (mask) RETURNING (filename,rc)
PROGRAM INTEGER RC STRING*80 SCR EXECUTE SYSPROC.TOOLS.SCRFILE ("TEST.tmp") RETURNING (SCR,RC) WRITE SCR END PROGRAM
SUBROUTINE TOOLS.SIRNAME (name, len) RETURNING (newname, rc)
In SIR/XS the naming rules are more liberal. Names can have any characters but need to be enclosed in curly brackets if they are non-standard names.
PROGRAM STRING NEWNAME EXECUTE SYSPROC.TOOLS.SIRNAME("!^235 Z",8) RETURNING (NEWNAME,RC) WRITE NEWNAME END PROGRAM
SUBROUTINE SYSPROC.TOOLS.SOUNDEX (longname) RETURNING (sound)
This is not the "SOUNDEX" algorithm.
This might be used with a secondary index on the SOUND of words or names. When a user enters a new name then a list of similar sounding words/names could be displayed.
PROGRAM STRING NAME SOUND COMPUTE NAME = "CHICKEN SOUP" EXECUTE SYSPROC.TOOLS.SOUNDEX(NAME) RETURNING (SOUND) WRITE SOUND COMPUTE NAME = "COKEN SOAP" EXECUTE SYSPROC.TOOLS.SOUNDEX(NAME) RETURNING (SOUND) WRITE SOUND END PROGRAM
SUBROUTINE TOOLS.VERIFY (patch) RETURNING (n,c,w)
This is a handy one to run at the start of a batch check and backup process.
PROGRAM INTEGER N C W EXECUTE SYSPROC.TOOLS.VERIFY (0) RETURNING (N,C,W) IFTHEN (N EQ 0 AND C GT 0) EXECUTE SYSPROC.TOOLS.VERIFY (1) RETURNING (N,C,W) ENDIF IFTHEN (SUM(N,C,W) EQ 0) WRITE "All OK..." ENDIF END PROGRAM
SUBROUTINE SYSPROC.MENU.EDITOR (pqlfile,type)
PROGRAM EXECUTE SYSPROC.MENU.EDITOR ("SYSPROC.MENU.EDITOR",2) END PROGRAMSo, as you see there are many potentially useful routines here. Please feel free to use them and any others not mentioned here. Copy the source code and modify it for your own needs if you wish. The PQL source code is included deliberately and is not subject to copyright.
Note: if you modify the procedures in the sysproc file then you may lose them when a revision is released - or the revised procfile may not overwrite your procfile (if yours is newer) so you will not receive the updated procfile.