Re: New "base document" available




"Richard" <riplin@xxxxxxxxxxxx> wrote in message
news:1175553898.274402.133460@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Apr 2, 10:29 pm, "Pete Dashwood"
<dashw...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

Compare, for MS-DOS, the pairs:
dir /p *.
dir *. /p
and
copy a.txt b.txt
copy /b a.txt b.txt

The arguments to the "dir" command are not position
sensitive. The arguments to the "copy" command are
relative position sensitive for the input and output files;
but are not absolute position sensitive.

These are implicit/shorthand keyword parameters. The / indicates a
"keyword" is about to follow. If it is boolean (as in the examples you
posted (and they are good examples)) nothing further is required,
otherwise
the keyword is followed by an = or a colon and a value... (explicit
keyword
parameter)

Note that the '/' is a CP/M convention and conflicits with the prior
use of this in Unix as a path separator. Because MS-DOS adopted the CP/
M '/' it had to use '\' as its path separator when it adopted Unix
hierarchical directories.

Unix uses '-' as a parameter leadin. The convetion is that it may have
short code parameters or long name parameters:

xxx -f name
or xxx --filename=name

and shortnames may be concatenated so that these are the same:

ls -a -l
ls -al

You may be expressing a convention that you have seen, and you may
have seen no other, but command lines have been used for decades in
ways that seem to have never occured to you.

And you are doing exactly that also.

This discussion is NOT about Unix command lines; it is about application
programs written in COBOL and activated from a command line interface.

I never claimed expertise with Unix command lines; I do know something about
running COBOL applications in both mainframe and PC environments.

You could think of /p as implying "/page=yes".

The file description parameter is easily identifiable as such and so does
not need to be position sensitive, as you observed. This is equivalent to
"file=a.txt".

XCOPY /A /D:04-03-2007 /EXCLUDE:".obj" /E c:\MyStuff\*.*
d:\MyOldStuff\

Note that /D and /EXCLUDE are non-Boolean and therefore reqire a keyword
parameter format.

The above expands as:

Copy all files with the archive bit set (/A...implicit ATTRIB=A) that
are
in the directory c:\MyStuff and any of its subdirectories, that were
changed
on or after the 3rd April 2007 (/D...explicitly stated), to the directory
d:\MyOldStuff, excluding (/EXCLUDE...explicitly stated) any files with
an
extension of ".obj".

This is all very well for OS commands, which need to be brief and
consistent, and can be documented in a manual, but for applications the
case
is a little different. Especially in the mainframe environment,
non-keyword
parameters are normally positional so that no keyword needs to be
entered.

They are only relatively positional, not absolutely. In your example
the first two parameters could be moved to the end of the command, or
even spread through it.

That's because they were OS commands and used only to make the point that
even these are really implicit name/value pairs.

The APPLICATION example of positional parameters given below is NOT
relational; it is absolute.

Missing parameters must be identified by a separator.


However in some cases the positioning of short parameters may be
significant. For eample with compiling a list of source files an 'add
debug' parameter may be repeatedly used to turn on or off this feature
for each file.

hypothical -o outputname -g off a.src b.src -g on c.src -g off d.src


While this is interesting, it has no bearing on what I am suggesting here.
My comments apply to application command lines intended for COBOL programs.


The use of separators indicates the position and only the runtime
parameter
value needs to be specified.

MyProg 123,Y,,,xyz

Even so, some sites prefer the use of Keyword parameters which obviously
don't need to be positional so there is no misunderstanding...

MyProg OUTFILE=Something.member INFILE=Something.else.member

(The order is immaterial, and separators are not required.)

My point is that one can not necessarily assume that
a user will place a particular type of argument at a fixed
position and, in my experience with a number of utilities,
there is little dependence on absolute positioning of
arguments.

I see your case and what you based it on, but there is a difference
between
OS parameters and system utilities which can be considered an extension
of
the OS. Our COBOL requirement is purely for applicatiions.(It will be
issued from COBOL application programs...)

If you are arguing that the tables need ot be mainupaleted after they are
loaded, I would not disagree. However, my point is that they can be
EASILY
manipulated with the COBOL SEARCH verb and that was one of the design
goals
in the proposal. I would rather see a SEARCH than a bunch of ACCEPTS and
compares.

You will actually see a _bunch_ of SEARCHes.

Not at all. You should never need more than two of them (one for each of the
pointer sets). Depends how smart your SEARCH is...

Coming back to the original posted example...

CONTEXT:

1. Environment Variables... EV1=X, EV2=Y, PARMX=Z

2. Command Line... myProg A, , C, PARMX=D, E

(The command line must cater for positional and keyword parameters and a
mixture of both, see below.)


WORKING-STORAGE SECTION.

01 Command-line-parms.
12 clparms occurs max-clparms-for-program
indexed by cl-x1.
15 clp-name usage pointer.
15 clp-value usage pointer.

01 Environment-Variables.
12 EVparms occurs max-EVparms-for-context
indexed by EV-x1.
15 EV-name usage pointer.
15 EV-value usage pointer.

PROCEDURE DIVISION.
...
*> Load the pointer sets...
FUNCTION GET-RUNTIME-PARAMETERS (Command-line-parms,
Environment-Variables)
...

What happens next depends on the requirements of the programmer... At this
point, given the parameters in the example above, the two sets contain the
following:

clp-name (1) points to a string containing "P1"
clp-value (1) points to a string containing "A"
clp-name (2) points to a string containing "P2"
clp-value (2) points to a string containing "0x00" (null)
clp-name (3) points to a string containing "P3"
clp-value (3) points to a string containing "C"
clp-name (4) points to a string containing "PARMX"
clp-value (4) points to a string containing "D"
clp-name (5) points to a string containing "P5"
clp-value (5) points to a string containing "E"

EV-name (1) points to a string containing "EV1"

EV-value (1) points to a string containing "X"
EV-name (2 points to a string containing "EV1"

EV-value (2) points to a string containing "Y"
EV-name (3) points to a string containing "PARMX"

EV-value (3) points to a string containing "Z"

... all other entries are null pointers.

It is pretty trivial to check both tables and find that the original EV
value of PARMX ("Z") has been overridden on the command line to now be
"D".

It is also "pretty trivial" to do a smart search and get what you're
interested in.

Say the program is interested in the values of EV1 and EV3, and the command
line values of the second and fourth parameters. We also know that the
fourth value in the command line parameters is the value of PARMX and it may
be specified in Keyword format or positionally, with just the value. A
command line setting is to override an EV setting...

WS...

01 Program-parms.
12 EV1-value pic x(01).
12 EV3-value pic x(4).
12 PARMX-value pic x(3).
12 CLP2-value pic x(12).

PD...

(Note pointer sets have been loaded by code above...with a single FUNTION
GET-RUNTIME-PARAMETERS invocation.)
*> get what we need...
SEARCH EVparms
AT END continue
WHEN EV-name (EV-X1) = "EV1"
move EV-value (EV-X1) to EV1-value
WHEN EV-name (EV-X1) = "EV3"
move EV-value (EV-X1) to EV3-value
WHEN EV-name (EV-X1) = "PARMX"
move EV-value (EV-X1) to PARMX-value
END-SEARCH
move CL-value (1) to CLP1-value
move CL-value (4) to PARMX-value
*> finished getting parms...

The above is just one way... I have omitted some code that could be required
in the BASED-STORAGE section on some environments and I haven't used pointer
qualification where it might, in fact, be necessary...

It should also check for null pointers before moving values and, in this
specific instance, there is no need to get the PARMX EV value because it is
being overridden form the command line.

It is intended to demonstrate a concept; having the two sets available as
name/value pairs simplifies everything. However, it is not possible to get
by with doing no work whatsoever... :-)



In any case I generally use a table driven approach. I have a table
of parameter names that I am interested in and a simple loop through
this will recover all the values needed by the program whether this be
from a _single_ accept statement or a call (or a search).


Chacun a son gout (Alistair, please note :-))

You are just making up strawman arguments.

I have no idea what prompted that...:-)

First off, it is not a rhetorical device I use, secondly I have done nothing
to push anyone else's argument or re-interpret their argument to suit
myself, thirdly, I'm not actually ARGUING anything. I'm suggesting an
approach.


I guess I've said everything I want to about this :-) and as it is not
going
anywhere anyway, I might as well get back to work :-)


Pete.


.



Relevant Pages

  • Re: TextIO Tutorial
    ... listing command ... VARIABLE filename: String; ... actually a pointer to a string. ... WRITE (buf2, string'("My command 1")); ...
    (comp.lang.vhdl)
  • TIP #185: Null Handling
    ... nulls, and command modifications for manipulating them. ... Tcl deals with strings, the universal medium for representing data. ... is know and it is an empty string, but if a respondent forgets to give ...
    (comp.lang.tcl)
  • Re: New "base document" available
    ... implications of any approach to command line parameters. ... exactly as it is now") for environment variables is ... While an environment pointer is defined ... clp-name points to a string containing "P1" ...
    (comp.lang.cobol)
  • Re: Determine how Word was launched
    ... inspect the command line used to launch Word. ... Private Declare Function GetCommandLineA Lib "kernel32" As Long ... Public Function GetCommandLineAs String ... Dim lngCmdLinePtr As Long ...
    (microsoft.public.office.developer.vba)
  • Re: c program - command line prompt - need help
    ... string i should use the command line prompt and when i press the ... the program should print the string if it ends in "ed" ... argc is a count of the command line arguments, ... argvis defined to be a null pointer. ...
    (comp.lang.c)