MU-VMS Archives

December 1995

MU-VMS@LISTSERV.MIAMIOH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Kent Covert <[log in to unmask]>
Reply To:
Miami University OpenVMS <[log in to unmask]>
Date:
Fri, 1 Dec 1995 11:38:59 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (44 lines)
In article <1995Nov30.153022@miavx1>, [log in to unmask] (The King)
writes:
> I would like to write a VMS pascal program... I know how to enter, compile,
> and link everything, but I am curious how to get arguments from the command
> line. Can someone help me out? And no, I don't want to use C.... I already
> put up with that language enough in my classes.
 
You don't have to put up with C, but you do have to use some VMS library
routine.  The Pascal standard does not specify how to handle command line
arguments (just like it doesn't specify how to handle strings).  Therefore
every implementation is different.
 
Here is a small program to do what you want.  Realize, though, that VMS
always uppercases the command line.  You can get around this, but it's not
easy.
 
  [INHERIT ('SYS$LIBRARY:PASCAL$LIB_ROUTINES')]
 
  PROGRAM CmdLine (OUTPUT) ;
 
    VAR Rst : INTEGER := 0 ;
        Command : VARYING [80] OF CHAR := '';
 
  BEGIN
    Rst := LIB$GET_FOREIGN (%DESCR Command) ;
    IF NOT ODD (Rst)  THEN
      LIB$SIGNAL (Rst) ;
 
    WRITELN(Command);
  END.
 
This program gets the command line arguments and prints them to the screen.
The INHERIT statement at the beginning specifies the system library
routines.  The LIB$GET_FOREIGN is the VMS library routine to get access
to the command line.  It returns the arguments into the variable called
Command.  The routine returns an ODD number if the routine failed.  The
LIB$SIGNAL routine then prints this error message to the screen.
 
--
                                     Kent Covert, Software Coordinator
                                     Miami Computing and Information Services
                                     Miami University, Oxford, OH
                                     [log in to unmask]

ATOM RSS1 RSS2