comp.lang.ada
 help / color / mirror / Atom feed
* Re: How to pass commandline parameters to a vax vms ada main prog
  1997-01-23  0:00 How to pass commandline parameters to a vax vms ada main prog Markus Wolfgart
  1997-01-23  0:00 ` Larry Kilgallen
@ 1997-01-23  0:00 ` Peter Amey
  1997-01-24  0:00 ` Ken Garlington
  2 siblings, 0 replies; 6+ messages in thread
From: Peter Amey @ 1997-01-23  0:00 UTC (permalink / raw)



On Thu, 23 Jan 1997, Markus Wolfgart wrote:

> I'm running in a programing problem and can't find a satisfactory
> solution, please help if you know the right anwser.
> 
> How to pass comandline parameters to an ada main procedure written
> in vax vms 5.1 ada. Do I need to import the starlet lib ?
> 
> thanks for help in advance.
> 
> markus
> 

Useful fragments follow:

  LenCmdLine                  : constant INTEGER := 255;

  subtype TypCmdLineRange     is INTEGER range 1..LenCmdLine;
  subtype TypCmdLine          is STRING (TypCmdLineRange);



with STARLET;
....
  procedure ReadCmdLine( CmdLineFound : out BOOLEAN;
                         CmdLine      : out TypCmdLine;
                         CmdLinePntr  : out TypCmdLineRange )
  --# derives CmdLine      from CmdLine &
  --#         CmdLinePntr  from &
  --#         CmdLinefound from;
  is
  --# hide ReadCmdLine
  -- FUNCTION :
  --
  -- Checks if command line supplied, if supplied sets 'CmdLineFound' 
True, else
  -- sets it False. Reads any supplied command line into the array 
'CmdLine' and
  -- sets 'CmdLinePntr' to initial value of 1.
  --
  -- The command line string returned in 'CmdLine' does not include the 
program name.
  --
  -- OPERATION :
  --
  -- Uses VAX/VMS run time library procedure Lib$Get_Foreign ( which is 
documented in
  -- the VAX/VMS Runtime Library manual Volume 8B )

    Status     : COND_VALUE_TYPE;
    Found      : BOOLEAN;
    CmdLineLen : UNSIGNED_WORD;
    StsValue   : INTEGER;
    PrmptFlag  : INTEGER;

    procedure GetForeign( Status    : out COND_VALUE_TYPE;
                          CmdString : out STRING;
                          Prompt    : in  STRING := STRING'NULL_PARAMETER;
                          OutLen    : out UNSIGNED_WORD;
                          Force     : in  INTEGER );

    pragma interface( VAXRTL, GetForeign );
    pragma import_valued_procedure( GetForeign, "LIB$Get_Foreign" );

    --  This declaration is mapped to the VAX/VMS RTL function 
LIB$Get_Foreign.
    --  It reads the programs invoking command line ( if any ) and 
returns it
    --  in 'CmdString' and the number of characters it contains in 'OutLen'.
    --  If 'Force' is set to 1 it prompts with string 'Prompt' if no 
command line
    --  is supplied. It does not prompt if 'Force' is set to 0. The returned
    --  command line does not include the program name. Success of 
operation is
    --  returned in the function result and should be SS_Normal if 
successful.

  begin
    for Index in TypCmdLineRange loop 
        CmdLine( Index ) := ' '; 
    end loop;

    PrmptFlag := 0;                -- no Prompt if command line is not found
    CmdLineLen := 0;

    GetForeign( Status, CmdLine, STRING'NULL_PARAMETER, CmdLineLen, 
PrmptFlag );

    Found := ( CmdLineLen > 0 ) and ( Status = STARLET.SS_Normal );  -- 
SS$_Normal implies
                                                                 -- a 
successful exit
    CmdLinePntr := 1;

    if not Found then
       for Index in TypCmdLineRange loop 
           CmdLine( Index ) := ' ';  
       end loop;
    end if;
    CmdLineFound := Found;

  end ReadCmdLine;

  
----------------------------------------------------------------------------

Sorry about some of the lie wraps in the above!

regards Peter





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to pass commandline parameters to a vax vms ada main prog
  1997-01-23  0:00 How to pass commandline parameters to a vax vms ada main prog Markus Wolfgart
@ 1997-01-23  0:00 ` Larry Kilgallen
  1997-01-23  0:00 ` Peter Amey
  1997-01-24  0:00 ` Ken Garlington
  2 siblings, 0 replies; 6+ messages in thread
From: Larry Kilgallen @ 1997-01-23  0:00 UTC (permalink / raw)



In article <32E71F0B.270@dfd.dlr.de>, Markus Wolfgart <wolfgart@dfd.dlr.de> writes:

> How to pass comandline parameters to an ada main procedure written
> in vax vms 5.1 ada. Do I need to import the starlet lib ?

On operating systems which have command line parameters, Ada 83
access to those parameters is only via implementation-specific
mechanisms.

For DEC Ada on VMS, the Starlet package supports System Services,
but access to command line parameters is not supported via those
System Services.  (There is a way to do it, but it is purposefully
undocumented so that DEC is free to change the details.  Kind of
like a thick binding.)

Access to command line parameters is via Run-Time libraries,
and you have two choices.

For a quick-and-dirty (i.e., Unix emulation) style of access to
the command line, use the LIB package and in particular the
subprogram LIB$GET_COMMAND.  Parse the result yourself.

For full-featured command line access appropriate if the users
of your program are accustomed to VMS, use the CLI package and
the various command line retrieval and parsing subprograms
therein.

Larry Kilgallen





^ permalink raw reply	[flat|nested] 6+ messages in thread

* How to pass commandline parameters to a vax vms ada main prog
@ 1997-01-23  0:00 Markus Wolfgart
  1997-01-23  0:00 ` Larry Kilgallen
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Markus Wolfgart @ 1997-01-23  0:00 UTC (permalink / raw)



hallo,

I'm running in a programing problem and can't find a satisfactory
solution, please help if you know the right anwser.

How to pass comandline parameters to an ada main procedure written
in vax vms 5.1 ada. Do I need to import the starlet lib ?

thanks for help in advance.

markus




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to pass commandline parameters to a vax vms ada main prog
  1997-01-23  0:00 How to pass commandline parameters to a vax vms ada main prog Markus Wolfgart
  1997-01-23  0:00 ` Larry Kilgallen
  1997-01-23  0:00 ` Peter Amey
@ 1997-01-24  0:00 ` Ken Garlington
  1997-01-25  0:00   ` Larry Kilgallen
  2 siblings, 1 reply; 6+ messages in thread
From: Ken Garlington @ 1997-01-24  0:00 UTC (permalink / raw)



Markus Wolfgart wrote:
> 
> hallo,
> 
> I'm running in a programing problem and can't find a satisfactory
> solution, please help if you know the right anwser.
> 
> How to pass comandline parameters to an ada main procedure written
> in vax vms 5.1 ada. Do I need to import the starlet lib ?
> 
> thanks for help in advance.
> 
> markus

In addition to the Ada advice already posted, don't forget that you
will need to define your executable as a foreign command; e.g. for
executable TEST.EXE

TEST :== $disk:[directory]TEST.EXE

The dollar sign at the front is important. Then, you should be able to
execute TEST as a verb:

$ TEST stuff

and read/parse "stuff" successfully.

You can also use the DEFINE/VERB command (I think that's right, anyway;
I always use the first option presented).

--
LMTAS - The Fighter Enterprise - "Our Brand Means Quality"
For job listings, other info: http://www.lmtas.com or
http://www.lmco.com




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to pass commandline parameters to a vax vms ada main prog
  1997-01-24  0:00 ` Ken Garlington
@ 1997-01-25  0:00   ` Larry Kilgallen
  1997-01-27  0:00     ` Ken Garlington
  0 siblings, 1 reply; 6+ messages in thread
From: Larry Kilgallen @ 1997-01-25  0:00 UTC (permalink / raw)



In article <32E94CAC.4148@lmtas.lmco.com>, Ken Garlington <GarlingtonKE@lmtas.lmco.com> writes:

> In addition to the Ada advice already posted, don't forget that you
> will need to define your executable as a foreign command; e.g. for
> executable TEST.EXE
> 
> TEST :== $disk:[directory]TEST.EXE
> 
> The dollar sign at the front is important. Then, you should be able to
> execute TEST as a verb:
> 
> $ TEST stuff
> 
> and read/parse "stuff" successfully.

You can get away without defining a symbol if you are willing to do more
typing for each invocation:

	$ MCR disk:[directory]TEST.EXE StUFf

An example of a situation where lots of typing per invocation is when
every invocation will be from a command procedure.  The computer does
not care.

The basic rule about command line parsing in VMS, no matter how you
do it, is that there will be nothing to parse if you use the RUN
command to invoke the program.

Larry Kilgallen




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to pass commandline parameters to a vax vms ada main prog
  1997-01-25  0:00   ` Larry Kilgallen
@ 1997-01-27  0:00     ` Ken Garlington
  0 siblings, 0 replies; 6+ messages in thread
From: Ken Garlington @ 1997-01-27  0:00 UTC (permalink / raw)



Larry Kilgallen wrote:
> 
> In article <32E94CAC.4148@lmtas.lmco.com>, Ken Garlington <GarlingtonKE@lmtas.lmco.com> writes:
> 
> > In addition to the Ada advice already posted, don't forget that you
> > will need to define your executable as a foreign command; e.g. for
> > executable TEST.EXE
> >
> > TEST :== $disk:[directory]TEST.EXE
> >
> > The dollar sign at the front is important. Then, you should be able to
> > execute TEST as a verb:
> >
> > $ TEST stuff
> >
> > and read/parse "stuff" successfully.
> 
> You can get away without defining a symbol if you are willing to do more
> typing for each invocation:
> 
>         $ MCR disk:[directory]TEST.EXE StUFf

However, you have to be careful with MCR, since it may not be portable.
I just tried it on my VAX, and got an error (RSX image not found). One
of the advantages of defining the image as a symbol (and, if you're
using the DCL parse routines, linking the CLD file in as an object file
vs. keeping it a separate CLD file) is that it will work just about
anywhere.

> 
> An example of a situation where lots of typing per invocation is when
> every invocation will be from a command procedure.  The computer does
> not care.

True, although you can define a symbol in this case as well.

> 
> The basic rule about command line parsing in VMS, no matter how you
> do it, is that there will be nothing to parse if you use the RUN
> command to invoke the program.
> 
> Larry Kilgallen

--
LMTAS - The Fighter Enterprise - "Our Brand Means Quality"
For job listings, other info: http://www.lmtas.com or
http://www.lmco.com




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1997-01-27  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-01-23  0:00 How to pass commandline parameters to a vax vms ada main prog Markus Wolfgart
1997-01-23  0:00 ` Larry Kilgallen
1997-01-23  0:00 ` Peter Amey
1997-01-24  0:00 ` Ken Garlington
1997-01-25  0:00   ` Larry Kilgallen
1997-01-27  0:00     ` Ken Garlington

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox