From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,560db337e2dbcd3e X-Google-Attributes: gid103376,public From: Peter Amey Subject: Re: How to pass commandline parameters to a vax vms ada main prog Date: 1997/01/23 Message-ID: #1/1 X-Deja-AN: 211704233 references: <32E71F0B.270@dfd.dlr.de> content-type: TEXT/PLAIN; charset=US-ASCII organization: Praxis plc, U.K. mime-version: 1.0 newsgroups: comp.lang.ada Date: 1997-01-23T00:00:00+00:00 List-Id: 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