Skip to content

Commit 2ca4af0

Browse files
committed
add calc.exec, small changes for start of VM Workshop
1 parent 48b29e6 commit 2ca4af0

File tree

9 files changed

+95
-54
lines changed

9 files changed

+95
-54
lines changed

execs/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,28 @@ $ git clone https://github.com/openmainframeproject/zvm-community-tools
7373
## REXX EXECs
7474
Following are descriptions of each REXX EXEC.
7575

76+
### CALC EXEC
77+
The ``CALC EXEC`` calculates a numerical expression.
78+
79+
- Here is the help:
80+
```
81+
calc -h
82+
Name: CALC - calculate a numerical expression
83+
Usage: CALC expression
84+
Exmpl: CALC 5 + 6
85+
```
86+
87+
- Here is an example of using it:
88+
```
89+
calc 21 * 5
90+
21 * 5 = 105
91+
```
92+
93+
- Here is an example of using it:
94+
95+
```
96+
calcdasd
97+
7698
### CALCDASD EXEC
7799
The ``CALCDASD EXEC`` calculates the size of all disk space.
78100

execs/calc.exec

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*-------------------------------------------------------------------*/
2+
/* CALC EXEC - calculate a numeric expression */
3+
/* Usage: CALC expr */
4+
/* Licensed under the Apache License, Version 2.0 */
5+
/* https://github.com/openmainframeproject/zvm-community-tools/execs */
6+
/*-------------------------------------------------------------------*/
7+
parse upper arg args
8+
if args = '' | args = "?" | args = "-H" then do
9+
say "Name: CALC - calculate a numerical expression"
10+
say "Usage: CALC expression"
11+
say "Exmpl: CALC 5 + 6"
12+
exit
13+
end
14+
interpret "result =" args
15+
say args "=" result
16+

execs/calcosa.exec

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ allOSA.0 = 0
1515
call mergeOSA /* merge free & used OSA by rdev */
1616
call prtOutput /* print results */
1717
exit /* CALCOSA EXEC */
18-
18+
1919
/*-------------------------------------------------------------------*/
2020
parseArgs: procedure expose debug verbose
2121
/* Parse arguments */
2222
/*-------------------------------------------------------------------*/
23-
parse arg arg1 '(' flags ')'
23+
parse upper arg arg1 '(' flags ')'
2424
if arg1 = "?" | arg1 = "-H" then
2525
call help
26+
if arg1 = "-V" then
27+
verbose = 2
28+
if arg1 = "-D" then
29+
debug = 1
2630
if flags = "" then
2731
return /* all done */
2832
do i = 1 to LENGTH(flags)
@@ -39,7 +43,7 @@ parseArgs: procedure expose debug verbose
3943
end
4044
end
4145
return /* parseArgs() */
42-
46+
4347
/*-------------------------------------------------------------------*/
4448
getOSAs: procedure expose usedOSA. freeOSA. debug verbose
4549
/* Get the used and free OSAs */
@@ -62,7 +66,7 @@ getOSAs: procedure expose usedOSA. freeOSA. debug verbose
6266
freeOSA.0 = freeIndex
6367
end
6468
return /* getOSAs() */
65-
69+
6670
/*-------------------------------------------------------------------*/
6771
setColor:
6872
/* Change color of next line */
@@ -73,7 +77,7 @@ setColor:
7377
'conwait' /* flush output stack */
7478
'pipe cp screen outarea' color '| hole' /* no COMMAND COMPLETE */
7579
return /* setColor() */
76-
80+
7781
/*-------------------------------------------------------------------*/
7882
debugMsg: procedure expose verbose
7983
/* issue message in debug mode */
@@ -85,7 +89,7 @@ debugMsg: procedure expose verbose
8589
call setColor "green"
8690
end
8791
return /* debugMsg() */
88-
92+
8993
/*-------------------------------------------------------------------*/
9094
parseFreeLine: procedure expose freeOSA. freeIndex verbose
9195
/* get a line of 1 - 4 free OSA and populate stem var freeOSA. */
@@ -119,7 +123,7 @@ parseFreeLine: procedure expose freeOSA. freeIndex verbose
119123
freeOSA.freeIndex = rdev4 "FREE"
120124
end
121125
return /* parseFreeLine() */
122-
126+
123127
/*-------------------------------------------------------------------*/
124128
mergeOSA: procedure expose allOSA. freeOSA. numAllOSA usedOSA. verbose
125129
/* merge used and free OSA lists */
@@ -170,7 +174,7 @@ mergeOSA: procedure expose allOSA. freeOSA. numAllOSA usedOSA. verbose
170174
end
171175
allOSA.0 = allIndex - 1
172176
return /* mergeOSA() */
173-
177+
174178
/*-------------------------------------------------------------------*/
175179
getPchid: procedure expose verbose
176180
/* Given a CHPID, return the PCHID or "NONE" */
@@ -181,7 +185,7 @@ getPchid: procedure expose verbose
181185
if pchid = "physical" then /* no PCHID found */
182186
pchid = "NONE"
183187
return pchid /* getPchid() */
184-
188+
185189
/*-------------------------------------------------------------------*/
186190
prtLn: procedure expose verbose
187191
/* print one line of output formatting the 7 fields */
@@ -197,7 +201,7 @@ prtLn: procedure expose verbose
197201
JUSTIFY(devType,8) JUSTIFY(OSAType, 8) JUSTIFY(chpid,6),
198202
JUSTIFY(pchid,6)
199203
return /* prtLn() */
200-
204+
201205
/*-------------------------------------------------------------------*/
202206
prtFree: procedure expose verbose
203207
/* print one line of a free OSA - need to get CHPID and PCHID */
@@ -217,7 +221,7 @@ Device 2340, Status ONLINE
217221
dash = "-"
218222
call prtLn rdev "FREE" dash dash dash chpid pchid
219223
return /* prtFree() */
220-
224+
221225
/*-------------------------------------------------------------------*/
222226
prtUsed: procedure expose verbose
223227
/* print one line of a used OSA - need to get PCHID from CHPID */
@@ -228,7 +232,7 @@ OSA 0340 ATTACHED TO DTCVSW1 0600 DEVTYPE OSA CHPID F0 OSD */
228232
pchid = getPchid(chpid)
229233
call prtLn rdev userID vdev devType OSAType chpid pchid
230234
return /* prtUsed() */
231-
235+
232236
/*-------------------------------------------------------------------*/
233237
prtOutput: procedure expose allOSA. freeOSA. usedOSA. verbose
234238
/* print merged free and used OSAs */
@@ -248,15 +252,15 @@ prtOutput: procedure expose allOSA. freeOSA. usedOSA. verbose
248252
say " ----"
249253
say " Total:" FORMAT(allOSA.0, 4)
250254
return /* prtOutput() */
251-
255+
252256
/*-------------------------------------------------------------------*/
253257
help:
254258
/* give help */
255259
/*-------------------------------------------------------------------*/
256260
say "Name: CALCOSA EXEC - compute OSA statistics"
257261
say "Usage: CALCOSA {-h|?} {(vd)}"
258-
say "Where: -h or '|' = give help"
262+
say "Where: -h or '?' = give help"
259263
say " v = verbose"
260264
say " d = debug"
261265
exit 2 /* help() */
262-
266+

execs/cpformat.exec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
address COMMAND
88
firstchar = "J" /* first character of label */
99
arg dasds "AS " type .
10-
if dasds = "" | dasds = "?" then
10+
if dasds = "" | dasds = "-H" | dasds = "?" then
1111
call help
1212
labelPrefix = firstchar || getLabelPrefix(type)
1313
numDasd = parseDasd(dasds)

execs/diff.exec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ compareFiles: procedure expose fn1 ft1 fm1 fn2 ft2 fm2 flags,
181181
end
182182
diffs = 1
183183
end
184-
return
184+
return /* compareFiles() */
185185

186186
/*-------------------------------------------------------------------*/
187187
usage:

execs/grep.exec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* Name: GREP EXEC - search files for text patterns */
33
/* Usage: grep [lxFlags] ptrn FN [FT [FM]] [(vmFlags)] */
44
/* Licensed under the Apache License, Version 2.0 */
5-
/* https://github.com/openmainframeproject/zvm-community-tools/execs */
5+
/* https://github.com/openmainframeproject/zvm-community-tools/execs */
66
/*--------------------------------------------------------------------*/
77
/* parse for quoted pattern, if not found => single word pattern */
88
/* trace i */
@@ -218,10 +218,10 @@ regex: procedure expose chkCase debug numbers ptrn
218218
call debugMsg "ptrn:" ptrn "ptrnLen:" ptrnLen
219219
call debugMsg "line:" line "lineLen:" lineLen
220220

221-
/* check for leading */
222-
if LEFT(ptrn, 1) = "" then do /* must match begining of line */
223-
call debugMsg "found leading "
224-
ptrnLen = ptrnLen - 1 /* discount '' */
221+
/* check for leading 5 */
222+
if LEFT(ptrn, 1) = "5" then do /* must match begining of line */
223+
call debugMsg "found leading 5"
224+
ptrnLen = ptrnLen - 1 /* discount '5' */
225225
if LEFT(line, ptrnLen) = RIGHT(ptrn, ptrnLen) then
226226
return 1 /* match */
227227
else

execs/mkarczct.exec

Lines changed: 0 additions & 28 deletions
This file was deleted.

execs/mkvmarc.exec

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*-------------------------------------------------------------------*/
2+
/* MKVMARC EXEC - Create a VMARC file of all zvm-tools */
3+
/* Usage: MKVMARC */
4+
/* Licensed under the Apache License, Version 2.0 */
5+
/* Source: https://github.com/mike99mac/zvm-tools */
6+
/*-------------------------------------------------------------------*/
7+
vmarcFile = "ZVMTOOLS VMARC A" /* output file */
8+
'ESTATE' vmarcFile
9+
if rc = 0 then do
10+
say "Erasing old file:" vmarcFile
11+
'ERASE' vmarcFile
12+
if rc <> 0 then do
13+
say "ERROR: ERASE" vmarcFile "returned" rc
14+
exit rc
15+
end
16+
end
17+
18+
/* List of EXECs */
19+
execs = "CALCDASD CALCOSA CFM CFN CFT COPYDISK CPFORMAT ",
20+
||"DIFF GREP HEAD HISTORY MAN MKVMARC QA RFN RFT RM ",
21+
||"SPC SSICMD TAIL WC WCZVMTLS WHICH WHO"
22+
do i = 1 to WORDS(execs) /* Add each to the VMARC file */
23+
nextFile = SUBWORD(execs,i,1) "EXEC A"
24+
address COMMAND "VMARC PACK" nextFile vmarcFile "(APPEND"
25+
end
26+
say "Created file:" vmarcFile
27+

execs/who.exec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ exit
2828
/*-------------------------------------------------------------------*/
2929
/* process one line of QUERY NAMES output */
3030
/*-------------------------------------------------------------------*/
31-
processLine: procedure expose userIDs. userNum
31+
processLine: procedure expose userIDs. userNum filter
3232
parse arg line /* get 4 triplets per line */
3333
line = TRANSLATE(line, " ", ",") /* remove commas */
3434
line = TRANSLATE(line, " ", "-") /* remove dashes */
@@ -82,11 +82,11 @@ printOutput:
8282
say userIDs.i
8383
end
8484
end
85-
else /* no filter applied */
85+
else do /* no filter applied */
86+
numUsers = numUsers + 1
8687
say userIDs.i
88+
end
8789
end
88-
if numUsers = 0 then /* no filter */
89-
numUsers = userNum - 1
9090
say "Total: " numUsers
9191
return /* printOutput() */
9292

0 commit comments

Comments
 (0)