command_file_parameters
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
command_file_parameters [2018/11/16 19:05] – WIP lricker | command_file_parameters [2018/11/20 17:37] – lricker | ||
---|---|---|---|
Line 71: | Line 71: | ||
Here, '' | Here, '' | ||
- | ==== Parameters | + | ==== Parameters |
* All parameters are treated as character strings -- you cannot (directly) pass an integer as a parameter value: | * All parameters are treated as character strings -- you cannot (directly) pass an integer as a parameter value: | ||
Line 87: | Line 87: | ||
$ sum = ival1 + ival2 | $ sum = ival1 + ival2 | ||
$ ! or also: $ sum = F$INTEGER( P1 ) + F$INTEGER( P2 ) | $ ! or also: $ sum = F$INTEGER( P1 ) + F$INTEGER( P2 ) | ||
- | $ WRITE sys$output "Sum of the values is: '' | + | $ WRITE sys$output "The arithmetic sum of the values is: '' |
</ | </ | ||
yields this output: | yields this output: | ||
< | < | ||
- | Sum of the values is: 45801 | + | The arithmetic sum of the values is: 45801 |
</ | </ | ||
Line 99: | Line 99: | ||
$ ! ...again, in the command file: | $ ! ...again, in the command file: | ||
$ not_a_sum = P1 + P2 | $ not_a_sum = P1 + P2 | ||
- | $ WRITE sys$output " | + | $ WRITE sys$output " |
- | $ WRITE sys$output "This is just a concatenated string of digit-characters..." | + | $ WRITE sys$output "That is just a concatenated string of digit-characters..." |
</ | </ | ||
yields: | yields: | ||
< | < | ||
- | Wrong! | + | Wrong! |
- | This is just a concatenated string of digit-characters... | + | That is just a concatenated string of digit-characters... |
</ | </ | ||
+ | ==== Parameters for Batch Jobs ==== | ||
+ | You know to execute a command file " | ||
+ | < | ||
+ | $ @UTILS: | ||
+ | </ | ||
+ | which will execute the command file '' | ||
+ | You likely know how to run that same command file in a batch job, perhaps delaying it until sometime this evening when everyone' | ||
+ | |||
+ | < | ||
+ | $ SUBMIT / | ||
+ | </ | ||
+ | |||
+ | But what if you need to provide parameters to that batch job when it runs? Certainly __not like this__: | ||
+ | |||
+ | < | ||
+ | $ SUBMIT / | ||
+ | $ ! wrong!---^^^^^ ^^^ ^^^^^^^ ^^^^^^ | ||
+ | </ | ||
+ | |||
+ | That's wrong syntax for the '' | ||
+ | |||
+ | < | ||
+ | $ SUBMIT / | ||
+ | $ !... or like this -- double-quoting continues to work for lowercase and/or multi-word values: | ||
+ | $ SUBMIT / | ||
+ | </ | ||
+ | |||
+ | ==== But My Script Needs More Than 8 Parameters ==== | ||
+ | |||
+ | Normally, eight parameters P1...P8 is sufficient for almost any script/ | ||
+ | |||
+ | - DCL_CTLFLAGS -- This is a VMS system parameter (controlled with SYSGEN, SYSMAN and/or AUTOGEN), thus requires the system administrator to decide whether or not to use/alter it, and if yes, then to implement the necessary change. | ||
+ | - Create explicit DCL code (programming) to turn one or more " | ||
+ | |||
+ | (**Note to system administrators**: | ||
+ | |||
+ | Here's an example of the second method, " | ||
+ | |||
+ | < | ||
+ | $ ! COMPOUND_PARAMETERS.COM | ||
+ | $ ! | ||
+ | $ ! Assume that com-line parameters P1..P7 are allocated and used | ||
+ | $ ! for specific purposes in this script, but you need "a few more" | ||
+ | $ ! | ||
+ | $ ! Make P8 function as a compound parameter: | ||
+ | $ ! | ||
+ | $ ! ...Process parameters P1..P7 here... | ||
+ | $ ! | ||
+ | $ SEP = ";" | ||
+ | $ j = 0 ! initialize (" | ||
+ | $CPLOOP1: | ||
+ | $ arg' | ||
+ | $ IF ( arg' | ||
+ | $ ! ...else, got a good element/ | ||
+ | $ ! ...so edit that element: Upcase it, remove leading/ | ||
+ | $ arg' | ||
+ | $ j = j + 1 ! since it's a good one, count it | ||
+ | $ GOTO CPLOOP1 | ||
+ | $ ! | ||
+ | $CPCONTINUE1: | ||
+ | $ ! At this point, we've got from zero (0) to j+1 elements extracted from P8 | ||
+ | $ ! (j is our upper-limit)... | ||
+ | $ ! Process these compound values (here, demo'd by just echoing them out to display): | ||
+ | $ i = 0 ! another short& | ||
+ | $ WRITE sys$output "Echo P8 compound parameter values:" | ||
+ | $CPLOOP2: | ||
+ | $ ! When i > j, we're done... | ||
+ | $ IF ( i .GT. j ) THEN GOTO CPCONTINUE2 | ||
+ | $ ! ...nope, process the compound parameter (here, just display it): | ||
+ | $ tmp = arg' | ||
+ | $ WRITE sys$output " | ||
+ | $ ! ...or, this works too: $ WRITE sys$output " | ||
+ | $ i = i + 1 ! next counted-element... | ||
+ | $ GOTO CPLOOP2 | ||
+ | $ ! | ||
+ | $CPCONTINUE2: | ||
+ | $ ! ...script continues here | ||
+ | $ WRITE sys$output "" | ||
+ | $ WRITE sys$output " | ||
+ | $ WRITE sys$output "" | ||
+ | $Done: | ||
+ | $ EXIT 1 | ||
+ | </ | ||
+ | |||
+ | Then you could invoke (call) this script, //with more than 8 parameter values//, as follows: | ||
+ | |||
+ | < | ||
+ | $ @COMPOUND_PARAMETERS value1 value2 value3 value4 value5 value6 value7 - | ||
+ | " | ||
+ | Echo P8 compound parameter values: | ||
+ | VALUE8 | ||
+ | VALUE9 | ||
+ | VALUE10 IS MULTIWORD | ||
+ | VALUE11 | ||
+ | VALUE12 | ||
+ | |||
+ | ...processing continues | ||
+ | |||
+ | $ | ||
+ | </ | ||
command_file_parameters.txt · Last modified: 2019/11/12 16:02 by mmacgregor