ZMacros
?section GO  macro
== ****************************************************************************
== * GO program|macro|routine                                                 *
== * GO FUP INFO *.*                                                          *
== *--------------------------------------------------------------------------*
== * Runs a program, showing its command line                                 *
== ****************************************************************************
#output %*%
%*%


?section VAR macro
== ****************************************************************************
== * VAR variable [value]                                                     *
== * VAR MyVar    This is a test                                              *
== *--------------------------------------------------------------------------*
== * Pushes a variable if it doesn't already exist.                           *
== * If [value] is supplied, set it, otherwise, preserve the old value.       *
== ****************************************************************************
[#if [#variableinfo/existence/ %1%] |else| #push %1%]
[#if [#empty %2%] |then| |else| #set %1% %2 to 99%]


?section CompAll    macro
== ****************************************************************************
== * COMPALL [file mask] [;list] [$S]                                         *
== *--------------------------------------------------------------------------*
== * Gets a list of file names using the file mask                            *
== * Volumes to where the file is                                             *
== * Compiles the program based on its contents                               *
== * Volumes back to where you started                                        *
== ****************************************************************************
var   Param1 %1%
#push Param2 Param3
var   Param2 %2%
var   Param3 %3%
var   NoList ;nolist
#set  NoList
var   tst_lst
#set  tst_lst
[#case [#chargetv Param1 1 1] |;| #set NoList  [Param1] |otherwise|]
[#case [#chargetv Param2 1 1] |;| #set NoList  [Param2] |otherwise|]
[#case [#chargetv Param1 1 1] |$| #set tst_lst [Param1] |otherwise|]
[#case [#chargetv Param2 1 1] |$| #set tst_lst [Param2] |otherwise|]

#push MyFile FileList
fup /outv FileList/info %1%
#extractv FileList MyFile
#extractv FileList MyFile
#extractv FileList MyFile
var CompVol [#FILEINFO/VOLUME/x].[#FILEINFO/SUBVOL/x]]
[#loop |do|
   [#case [#chargetv MyFile 1 1]
   |$| VOLUME [MyFile]
   |otherwise|
      #set MyFile [#chargetv MyFile MyFile 1 8]
      COMPILE [MyFile]
   ]
   #extractv FileList MyFile
|until| [#emptyv FileList]
]
VOLUME [CompVol]
#pop MyFile FileList


?section COMP macro
var  tst_lst
#set tst_lst
var nolist ;nolist
var tst_src %1%
[#if [#fileinfo/existence/[tst_src]] |then|
   COMPILE %*%
|else|
   #output *** ERROR: %1% Does not exists
]


?section COMPF macro
var tst_src %1%
var tst_lst ,OUT LISTING.[tst_src]
var nolist
#set nolist ;nolist
[#if [#fileinfo/existence/[tst_src]] |then|
   COMPILE %*%
|else|
   #output *** ERROR: %1% Does not exists
]


?section COMPP macro
var tst_src %1%
var tst_lst ,OUT $P.#COMP.[tst_src]
var nolist
#set nolist ;NOLIST
[#if [#fileinfo/existence/[tst_src]] |then|
   COMPILE %*%
|else|
   #output *** ERROR: %1% Does not exists
]


?section COMPILE macro
var tst_lst
var nolist
var #INLINEPREFIX --
var tst_src %1%
var Src_Root [#charget tst_src 1 for [#compute [#charcount tst_src] - 1]]
var ThisVol [#FILEINFO/VOLUME/[tst_src]].[#FILEINFO/SUBVOL/[tst_src]]

var tst_lib $TECH1D.COPYSRC

var tst_all [ThisVol].[tst_src]
var tst_cat  $DEV3.MISCCATL
var tst_pobj $DEV2.TURBOBJ.xxx1
[#case [#charget [#shiftstring tst_src] 1 for 3]
   |EBC|  var tst_OBJ  $DEV2.TECHOB.[src_root]
   |EXP|  var tst_OBJ  $DEV2.EXPOBJ.[src_root]o
          var tst_pobj $DEV2.EXPOBJ.EXP1
          var ComptPobj EXP1
   |EMS|  var tst_OBJ  $DEV2.EMS.[src_root]n
   |ERR|  var tst_OBJ  $DEV2.SUBOBJ.[src_root]o
   |SUB|  var tst_OBJ  $DEV2.SUBOBJ.[src_root]o
   |BAT|  var tst_OBJ  $DEV2.TURBOBJ.[src_root]o
   |ENF|  var tst_OBJ  $DEV2.TURBOBJ.[src_root]o
   |DJL|  var tst_OBJ  $DEV2.TURBOBJ.[src_root]o
   |xxx|  var tst_OBJ  $DEV2.TURBOBJ.[src_root]o
          var ComptPobj xxx1
   |FLX|  var tst_OBJ  $DEV2.TURBOBJ.[src_root]o
   |FSR|  var tst_OBJ  $DEV2.TURBOBJ.[src_root]o
   |GBP|  var tst_OBJ  $DEV2.TURBOBJ.[src_root]o
   |PRG|  var tst_OBJ  $DEV2.TURBOBJ.[src_root]o
   |TAL|  var tst_OBJ  $DEV2.TECHOB.[src_root]o
   |TMP|  var tst_OBJ  $DEV2.TURBOBJ.[src_root]o
   |UTL|  var tst_OBJ  $DEV2.TURBOBJ.[src_root]o
   |STR|  var tst_OBJ  $DEV2.STOREOBJ.[src_root]o
   |INT|  var tst_OBJ  $DEV2.WEBOBJ.[src_root]o
   |REP|  var tst_OBJ  $DEV2.WEBOBJ.[src_root]o
   |WEB|  var tst_OBJ  $DEV2.WEBOBJ.[src_root]o
   |OTHERWISE|
          var tst_OBJ  $DEV2.xxxROBJ.[src_root]o
          var ComptPobj xxx1
]
var tmp [tst_src]
#push Found srcLanguage
#set Found
#set srcLanguage
[#if [#emptyv SrcLanguage] |then|
   edit /OUTV Found/[tmp] R;LB/ SCREEN / RB/ SECTION/RN/*/;E
   [#if [#linecount Found] > 2 |then| #set SrcLanguage SCOBOL ]
]
[#if [#emptyv SrcLanguage] |then|
   edit /OUTV Found/[tmp] R;LB/ TERMINAL / RB/ CONVERSATIONAL/RN/*/;E
   [#if [#linecount Found] > 2 |then| #set SrcLanguage SCOBOL ]
]
[#if [#emptyv SrcLanguage] |then|
   edit /OUTV Found/[tmp] R;LB/ TERMINAL / RB/ IBM-3270/RN/*/;E
   [#if [#linecount Found] > 2 |then| #set SrcLanguage SCOBOL ]
]
[#if [#emptyv SrcLanguage] |then|
   edit /OUTV Found/[tmp] R;LB/PROCEDURE / RB/DIVISION/RN/*/;E
   [#if [#linecount Found] > 2 |then| #set SrcLanguage COBOL]
]
[#if [#emptyv SrcLanguage] |then|
   edit /OUTV Found/[tmp] R;LB/ $SYSTEM.SYSTEM.EXTDECS/;E
   [#if [#linecount Found] > 2 |then| #set SrcLanguage Tal]
]
[#if [#emptyv SrcLanguage] |then|
   edit /OUTV Found/[tmp] R;LB/#include/;E
   [#if [#linecount Found] > 2 |then| #set SrcLanguage C]
]
[#if [#emptyv SrcLanguage] |then|
   edit /OUTV Found/[tmp] R;LB/?DICTIONARY /;E
   [#if [#linecount Found] > 2 |then| #set SrcLanguage Enform]
]
[#if [#emptyv SrcLanguage] |then|
   edit /OUTV Found/[tmp] R;LB/?DICT /;E
   [#if [#linecount Found] > 2 |then| #set SrcLanguage DDL]
]
[#if [#emptyv SrcLanguage] |then|
   edit /OUTV Found/[tmp] R;LB/CATALOG / r/=/;E
   [#if [#linecount Found] > 2 |then| #set SrcLanguage SQL]
]
[#if [#emptyv tst_lst] |then|
|else|
   [#if [#fileinfo/volume/[tst_lst]] |then|
      [#if [#fileinfo/existence/listing.[tst_src]] |then|
         PURGE listing.[tst_src]]
         fup CREATE listing.[tst_src], type u, ext(50,50)
      |else|
         fup purgedata listing.[tst_src]
      ]
      #set tst_lst ,out listing.[tst_src]
   |else|
      #set tst_lst ,out [tst_lst].#[SrcLanguage].[tst_src]
   ]
]

comment GO EDIT/INLINE/[tst_all]
comment GO -- CBA/$TECH1D.COPYSRC./COPYSRC./A
comment GO -- CBA/$TECH1.COPYSRC./COPYSRC./A
comment GO -- CBA/$TECH2D.//A
comment GO -- CBA/$TECH2.//A
comment GO -- CBA/?SOURCE ./?SOURCE /A
comment GO -- CBA/ COPYSRC./ / /COPY /
comment GO -- CF/*/  /TIMEFILE-MOD-TIME/ RN/*/
comment GO -- CBA/BLKTJRC/BLKTJRN/A
comment GO -- CA/search "$tech1D./search "/A
comment GO -- EXIT


param    SYMBOL-BLOCKS 8
VOLUME   [tst_lib]
[#case   [SrcLanguage]
|COBOL|  GO COBOL85/IN [tst_all][tst_lst]/[tst_obj][nolist],ENV COMMON
         var ComptNbr 1
|SCOBOL| GO SCOBOLX/IN [tst_all][tst_lst]/[TST_POBJ][nolist]
         var ComptNbr 2 [ComptPobj]
|Enform| GO enform /inline[tst_lst]/
         GO -- ?compile [tst_all] TO [tst_obj]
         GO -- exit;
         var ComptNbr 3
|TAL|    GO TAL    /IN [tst_all][tst_lst]/[tst_obj][nolist]
         var ComptNbr 4
|SQL|    GO SQLCI  /IN [tst_all][tst_lst]/
|C|      GO C      /IN [tst_all][tst_lst]/[tst_obj][nolist], &
         SSV0 "$system.system",SSV1 "$system.ztcpip",SSV2 "$tech1.nos"
==       SSV3 "$tech1d"
         var ComptNbr 5
|DDL|    GO DDL    /IN [tst_all][tst_lst]/
|otherwise| #output Skipping [tst_ALL]
         var ComptNbr 99
]
volume [ThisVol]

[#IF (_COMPLETION:COMPLETIONCODE > 1) |then|
     #output **** ERROR ****
|else|
     SqlCheck [tst_obj]
]
[#if [#fileinfo/existence/[tst_obj]] |then|
     RUN $DEV2.CUTLAR.ZFUP SECURE [tst_obj],"nnnn"
     RUN $DEV2.CUTLAR.ZFUP GIVE   [tst_obj],SYSTEM.AOES
]

#pop Found
[#if [#empty %2%] |then| |else| COMPILE %2 TO 99%]


========================
?section SqlCheck macro
========================
[#if [#fileinfo/existence/%1%] |then|
   var lstSql
   #set lstSql
   SQLCOMP/IN %1%,outv lstSql/CATALOG [tst_cat]
   [#IF ([#LINEFIND lstSql 1 No SQL source ]>0) |then|
       #output Sql Compiling is not needed for %1%
       #set _COMPLETION
       SaveCompT R [tst_src] [ComptNbr]
   |else|
        #push #out
        #set  #out [tst_lst]
        outvar lstSql
        #pop  #out
        #set _COMPLETION
       [#IF (_COMPLETION:COMPLETIONCODE > 1) |then|
          #output ********** SQL ERROR **********************
       |else|
          [#case [ComptNbr]
           |1| SaveCompT R [tst_src] 6
           |otherwise|
               SaveCompT R [tst_src] [ComptNbr]
          ]
       ]
   ]
|else|
   SaveCompT R [tst_src] [ComptNbr]
]


?section SaveCompT macro
== This is for, in my opinion, a rather interesting compile macro that compiles turnovers.
#push #out
#set  #out zcompfil
#output %*%
#pop #out
COMMENT  rename [tst_src],TURNOVER.[tst_src]

?section SetPw   macro
var Param1 Param2
#set Param1 %1%
#set Param2 %2%
[#case [#chargetv Param1 1 1] |$| var PcName [Param1] |otherwise| var PcServer [Param2]]
[#case [#chargetv Param2 1 1] |$| var PcName [Param2] |otherwise| var PcServer [Param1]]
[#if [#emptyv PcName] |then|  
   var PcName [#input Enter the Pathway System: ($MNTF):]
]
[#if [#emptyv PcServer] |then|
   var PcServer [#input Enter the Pathway Server (TESTPOST-SERVER):]
]


?section DebugOn macro
== * DebugOn [$PW] [server-name]
SetPw %*%
freeze     [PcName] [PcServer]
go pathcom [PcName];alter [PCServer],hometerm [#myterm],debug on
thaw       [PcName] [PcServer]


?section Freeze macro
SetPw %*%
go pathcom [PcName];freeze [PCServer]
go pathcom [PcName];stop   [PCServer], delay 10 secs


?section Thaw   macro
SetPw %*%
go pathcom [PcName];thaw [PCServer]


?section DebugOff macro
== * DebugOff [$PW] [server-name]
SetPw %*%
freeze     [PcName] [PcServer]
go pathcom [PcName];alter [PCServer],hometerm $VHS, debug off
thaw       [PcName] [PcServer]


?section set_SysIni macro
var CdVol          $DEV2.TEST
var LstVol         $DEV2.TESTLST
var SrcVol         $DEV2.TESTSRC
var TST_EXE        $DEV2.TESTOBJ.[SrcFile]O
var ObjVol         $DEV2.TESTOBJ
var TST_REN        $DEV2.TESTOBJ.[SrcFile]X
var TST_OBJ        $DEV2.TESTOBJ
var TST_POBJ       $DEV2.TESTOBJ.xxx1
var ObeyFile_VOL   $DEV2.TESTOBEY


?section LIB macro
GO VOLUME [TST_LIB]
?section LST macro
GO volume $DEV2.LISTING

?section SRC macro
[#if [#empty %1%] |then|
  GO volume $DEV2.SOURCE
|else|
  var  SrcFile %1%
]


?section OK macro
 [#case [#input RUN %*% (y)?] |y Y| GO %*% |otherwise|]
 #output ---------------------------------------------


?section PCLS macro
 SPOOLCOM $SPLS;JOB (OWNER),DELETE !
 SPOOLCOM $PPLS;JOB (OWNER),DELETE !


?section SV macro
 FUP SUBVOLS %*%


?section Type macro
 fup copy %1%


?section p macro
[#if [#empty %1%] |then| peruse $PPLS |else| peruse $SPLS]


?section InfoDefine macro
#frame
#push    X1 X2 X3 X4
#setMANY X1 X2 X3 X4,[#defineinfo %1%]
#output/HOLD/ADD DEFINE %1%
#output/HOLD,COLUMN 25/,CLASS [X2]
#output/COLUMN 40/,[X3] [X4]
#unframe
[#if [#empty %2%] |then| |else| INFODEFINE %2 to 99%]


?section CreateDefines macro
PURGE XD
INFO/OUT XD/DEFINE =*
EDIT XD;DQN/=/;CQ/ Define Name / INFODEFINE /A;E
PURGE DEFINES
#push #OUT
#set #OUT DEFINES
O XD
#pop #OUT
EDIT DEFINES;DQ/INFODEFINE/;E
EDIT DEFINES
[#if [#empty %2%] |then| |else| INFODEFINE %2 to 99%]


?section ST macro
[#IF [#EMPTY %1%]
|then| STATUS *,TERM
|else| STATUS %*%
]


?section DelY    macro
[#IF [#FILEINFO/EXISTENCE/%1%] |then|
   FILEINFO %1%
   [#CASE [#INPUT Do you wish to delete this (y)?]
      |y Y| purge %1%
      |otherwise|
   ]
]


?section COMPARE macro
$DEV2.testobj.COMPARE %*%


?section PC macro
[#if [#empty %1%]
|then| GO pathcom [PcName]
|else| #set PcName %*%
       GO pathcom %*%]


?section OBJ macro
Go VOLUME $DEV2.TESTOBJ


?section TL macro
Go LOAD/KEEP 1/$DEV2.COMPILES.ZMACROS


?section GT macro
edit $DEV2.COMPILES.ZMACROS;set tabs 10 20 30 40 50 60 70;%1 TO 9%


?section CD macro
var CdVol %1%
volume [CdVol]


?section G macro
var GSrc %*%
EDIT;SET TABS 10 20 30 40 50 60 70;SET JOIN 80;G [GSrc]


?section O macro
var ObeyFile %1%
[#if [#emptyv ObeyFile] |then|
     #output ([ObeyFile]) doesn't exist.
|else|
   [#if [#fileinfo/existence/[ObeyFile]] |then|
      #push Found
      edit /OUTV Found/[ObeyFile] R;LB/?section/RB/ ROUTINE/;E
      [#if [#linecount Found] > 2 |then|
         GO T [ObeyFile]
      |else|
         GO OBEY [ObeyFile]
      ]
      #pop  Found
   |else|
      #output The default Obey File hasn't been set yet. Try: O obeyfile
   ]
]
[#if [#empty %2%] |then| |else| O %2 to 99%]


?section BYE       macro
CSAVE
LOGOFF


?section CLOAD     macro
#push MyVol
#set  MyVol [#DEFAULTS]
VOLUME
OBEY DEFAULTS
VOLUME [MyVol]
#pop MyVol


?section CSAVE     macro
#push WS_VOLUME
#set  WS_VOLUME [#DEFAULTS]
VOLUME
#frame
#push #INLINEPREFIX
#set  #INLINEPREFIX --
edit/INLINE/DEFAULTS !
-- DQ ! F/L
-- 101 /#set PCName      [PCName]/
-- 102 /#set PCServer    [PCServer]/
-- 103 /#set SrcFile     [SrcFile]/
-- 104 /#set ObeyFile    [ObeyFile]/
-- 105 /#set CdVol       [CdVol]/
-- 106 /#set SrcFile     [SrcFile]/
-- 107 /#set COut        [COut]/
-- 108 /#set GSrc [GSrc]/
-- 109 /#set CdVol       [CdVol]/
-- E
VOLUME [WS_VOLUME]
#unframe


?section FILESPEC macro
[#if [#fileinfo /existence/ %1%] |then|
    #output /hold/ [#fileinfo/fullname/ %1%]
    #output /column 35,hold/
    [#case [#fileinfo /filestructure/ %1%]
         |0| #output /hold/ U:
         |1| #output /hold/ R:
         |2| #output /hold/ E:
         |3| #output /hold/ K:
         |otherwise| ]
    #output /column 37,hold/ [#fileinfo/eof/ %1%]
    #output /column 44,hold/&
        [_CONTIME_TO_TEXT [#CONTIME [#fileinfo/modification/%1%]]]
    #output /column 72,hold/ [#fileinfo/owner/ %1%]
|else|
    #output /hold/ File %1% does not exist ]
#output


?section SCUPINFO macro
#frame
#push OUTLIST
SCUP /OUTV OUTLIST/INFO %*%
#output [#LINEGET OUTLIST 1 FOR 1]
#output [#LINEGET OUTLIST 5 FOR 1]
#unframe


?section PRINT macro
FUP COPY %1%,$P
[#if [#empty %2%] |then| |else| PRINT %2 to 99%]


?section SQCOST macro
SQLCOMP/IN $DEV2.TESTOBJ.%1%,OUT $P.#SQCOST/ &
STOREDDEFINES EXPLAIN PLAN NORECOMPILE


?section LOG macro
[#if [#empty %1%] |then|
  EDIT $DEV2.TEST.LOG2009;XVS L-20;E
|else|
  #frame
  #push #out
  #set  #width 230
  #push  wYY wMM wDD wHH wMI
  #setmany  wYY wMM wDD wHH wMI, [#contime [#timestamp]]
  [#IF [wYY]< 10 |then| #set wYY 0[wYY]]
  [#IF [wMM]< 10 |then| #set wMM 0[wMM]]
  [#IF [wDD]< 10 |then| #set wDD 0[wDD]]
  [#IF [wHH]< 10 |then| #set wHH 0[wHH]]
  [#IF [wMI]< 10 |then| #set wMI 0[wMI]]
  #set  #out $DEV2.TEST.LOG[wYY]
  #output [wMM]/[wDD]/[wYY] [wHH]:[wMI]-> %*%
  #set  #width 80
  #pop  #out
  #unframe
]

?section sv macro
fup subvols %1%


?section CLS macro
#frame
 [#DEF ascii STRUCT
  BEGIN
  BYTE byt5(0:1)
   value 27 73;
  CHAR clr(0:1)
   redefines byt5;
  END;
 ]
#output [ascii:clr(0:1)]
#unframe


?section IMP     macro
var tst_src %1%
[#if [#fileinfo/existence/[tst_src]] |then|
    GO fup dup [tst_src], $tech1d.turnover.[tst_src],purge
]
[#if [#empty %2%] |then| |else| IMP %2 TO 99%]


?section GL      macro
var tst_src %1%
purge x
edit listing.[tst_src] p x


?section GS macro
var tst_src %1%
EDIT;SET TABS 10 20 30 40 50 60 70;SET JOIN 80;G [tst_src]
?section FS ALIAS
FINDDATA

?section CALC ALIAS
COMPUTE


?section dir ALIAS
fileinfo

?section fs alias
 finddata

?section grep alias
 finddata

Sunday, August 9, 2009 6:33:18 PM, From: jim, To: Stories