User Tools

Site Tools


command_file_parameters

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
command_file_parameters [2018/11/16 23:41] – WIP lrickercommand_file_parameters [2018/11/20 18:29] – summary/conclusion stmt lricker
Line 142: Line 142:
 ==== But My Script Needs More Than 8 Parameters ==== ==== But My Script Needs More Than 8 Parameters ====
  
-Normally, eight parameters P1...P8 is sufficient for almost any script/application, but sometimes you might need more.  There are two ways to handle this -- The first one requires the assistance (and approval) of your VMS system administrator; the second one you can just implement yourself.+Normally, eight parameters P1...P8 is sufficient for almost any script/application, but sometimes you might need more.  There are two ways to handle this -- The first one requires the assistance (and approval) of your VMS system administrator; the second one you can just implement yourself.  Specifically:
  
-TODO --+  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.  If bit-3 of this bit-mask system parameter is set (asserted, meaning that its integer value will be greater than or equal to eight (>=8)), then DCL will permit the use of up to sixteen (16) command line parameters ''P1''...''P16'' rather than the traditional eight parameters. 
 +  - Create explicit DCL code (programming) to turn one or more "ordinary" command line parameter(s) into a "compound parameter value," which the DCL code can "pick apart" and use.
  
-JOB_CTLFLAGS+(**Note to system administrators**: If you consider using the DCL_CTLFLAGS approach, be sure to read the help text ''$ MCR SYSGEN HELP SYS_PARAMETERS DCL_CTLFLAGS'' in its entirety; and see the text for ''Bit 3'' specifically.  If you elect to make this change for your system, be certain to include this parameter and its new value in your system's ''SYS$SYSTEM:MODPARAMS.DAT'' file so that it will be included in future AUTOGEN operations.  In practice, this change is //rarely// justified and/or actually done; the value ''0'' is quite normal for this parameter on most VMS systems.)
  
-compound parameter string+Here's an example of the second method, "compound parameter values":
  
 +<code>
 +$ ! 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:  "val8;val9;val10;val11;..."
 +$ !
 +$ ! ...Process parameters P1..P7 here...
 +$ !
 +$ SEP = ";"  ! the "separator character", here, a semicolon... (can be any single character you want)
 +$ j = 0      ! initialize ("j" is a short-&-sweet name for an "index" variable)
 +$CPLOOP1:
 +$ arg'j' = F$ELEMENT( j, SEP, P8 )
 +$ IF ( arg'j' .EQS. SEP ) THEN GOTO CPCONTINUE1  ! =SEP character means no more elements in P8
 +$ ! ...else, got a good element/value from P8...
 +$ ! ...so edit that element: Upcase it, remove leading/trailing space, compress multiple spaces
 +$ arg'j' = F$EDIT( arg'j', "TRIM,COMPRESS,UPCASE" )
 +$ j = j + 1     ! since it's a good one, count it
 +$ GOTO CPLOOP1  ! and try again...
 +$ !
 +$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&sweet index variable
 +$ WRITE sys$output "Echo P8 compound parameter values:"
 +$CPLOOP2:
 +$ ! When i > j, we're done...
 +$ IF ( i .GT. j ) THEN GOTO CPCONTINUE2  ! done with all compound parameters?
 +$ ! ...nope, process the compound parameter (here, just display it):
 +$ tmp = arg'i'   ! makes single-tick substitution easy in the quoted-output:
 +$ WRITE sys$output "  ''tmp'"
 +$ ! ...or, this works too:  $ WRITE sys$output "  ", arg'i'
 +$ i = i + 1      ! next counted-element...
 +$ GOTO CPLOOP2
 +$ !
 +$CPCONTINUE2:
 +$ ! ...script continues here
 +$ WRITE sys$output ""
 +$ WRITE sys$output "...processing continues"
 +$ WRITE sys$output ""
 +$Done:
 +$ EXIT 1
 +</code>
  
 +Then you could invoke (call) this script, //with more than 8 parameter values//, as follows:
  
 +<code>
 +$ @COMPOUND_PARAMETERS value1 value2 value3 value4 value5 value6 value7 -
 +     "value8; value9; value10 is    multiword; value11; value12"
 +Echo P8 compound parameter values:
 +  VALUE8
 +  VALUE9
 +  VALUE10 IS MULTIWORD
 +  VALUE11
 +  VALUE12
 +
 +...processing continues
 +
 +$
 +</code>
 +
 +This approach has the benefit of being generally //portable// to other VMS systems //without// needing to involve other system admins in messing with the DCL_CTLFLAGS system parameter.
command_file_parameters.txt · Last modified: 2019/11/12 16:02 by mmacgregor

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki