From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 29-MAR-1993 03:44:43.47
To:	gharpure@POWER.PSL.EE.VT.EDU, INFO-VAX@SRI.COM
CC:	
Subj:	Re: parameter passing to exe files?

> Is it possible to pass parameters from the command line while running
> 
> an .exe file? Rather like the p1, p2 etc for .com files?

I have already several replies with references to foreign command, the
MCR command and CLD-files, so I assume the original poster has already
solved his problem.

The COM-file below illustrates some of the possible methods in an
attempted systematic way !

Notes:
  - It assumes VAX PASCAL, VAX C and VAX FORTRAN installed
  - It creates files Z.OBJ and Z.EXE

                                                          Arne

Arne Vajhxj                             local DECNET:  KO::ARNE
Computer Department                     PSI:           PSI%238310013040::ARNE
Business School of Southern Denmark     Internet:      ARNE@KO.HHS.DK

================================================================================

$ set ver
$ !
$ !  The foreign command method for all languages
$ !  (example in PASCAL)
$ !
$ pascal/object=z sys$input
[inherit('sys$library:pascal$lib_routines')]

program z(input,output);

var
  line : varying [80] of char;

begin
  lib$get_foreign(resultant_string:=line.body,resultant_length:=line.length);
  writeln('Command line was : >'+line+'<');
end.
$
$ link z
$ ! -- variant I --
$ mcr sys$disk:[]z A bb "ccc" "DDDD"
$ ! -- variant II --
$ z:=$sys$disk:[]z
$ z A bb "ccc" "DDDD"
$ del/symb z
$ !
$ !  The foreign command method for C
$ !
$ cc/object=z sys$input
#include <stdio.h>

main(int argc,char *argv[])
{
  int i; 
  for(i=1;i<argc;i++) printf("P%d=>%s<\n",i,argv[i]);
};
$
$ link z+sys$input/opt
sys$share:vaxcrtl/share
$
$ ! -- variant I --
$ mcr sys$disk:[]z A bb "ccc" "DDDD"
$ ! -- variant II --
$ z:=$sys$disk:[]z
$ z A bb "ccc" "DDDD"
$ del/symb z
$ !
$ !  The CLD-method
$ !  (example in FORTRAN)
$ !
$ fortran/object=z sys$input
      PROGRAM Z
      INTEGER*4 LP1,LP2,LP3,LP4
      CHARACTER*80 P1,P2,P3,P4
      CALL CLI$GET_VALUE('P1',P1,LP1)
      WRITE(*,*) 'P1=>'//P1(1:LP1)//'<'
      CALL CLI$GET_VALUE('P2',P2,LP2)
      WRITE(*,*) 'P2=>'//P2(1:LP2)//'<'
      CALL CLI$GET_VALUE('P3',P3,LP3)
      WRITE(*,*) 'P3=>'//P3(1:LP3)//'<'
      CALL CLI$GET_VALUE('P4',P4,LP4)
      WRITE(*,*) 'P4=>'//P4(1:LP4)//'<'
      END
$
$ link z
$ set command sys$input
DEFINE VERB Z
   IMAGE "SYS$DISK:[]Z.EXE"
   PARAMETER P1
   PARAMETER P2
   PARAMETER P3
   PARAMETER P4
$
$ z A bb "ccc" "DDDD"
$ set command/delete=z
$ !
$ !  Mixing the foreign command method and the CLD-method
$ !  (example in FORTRAN)
$ !
$ fortran/object=z sys$input
      PROGRAM Z
      INTEGER*4 LL,LP1,LP2,LP3,LP4
      CHARACTER*80 LINE,P1,P2,P3,P4
      EXTERNAL ZZ
      CALL LIB$GET_FOREIGN(LINE,,LL)
      CALL CLI$DCL_PARSE('Z '//LINE(1:LL),ZZ)
      CALL CLI$GET_VALUE('P1',P1,LP1)
      WRITE(*,*) 'P1=>'//P1(1:LP1)//'<'
      CALL CLI$GET_VALUE('P2',P2,LP2)
      WRITE(*,*) 'P2=>'//P2(1:LP2)//'<'
      CALL CLI$GET_VALUE('P3',P3,LP3)
      WRITE(*,*) 'P3=>'//P3(1:LP3)//'<'
      CALL CLI$GET_VALUE('P4',P4,LP4)
      WRITE(*,*) 'P4=>'//P4(1:LP4)//'<'
      END
$
$ set command/object=zz sys$input
MODULE ZZ

DEFINE VERB Z
   PARAMETER P1
   PARAMETER P2
   PARAMETER P3
   PARAMETER P4
$
$ link z+zz
$ ! -- variant I --
$ mcr sys$disk:[]z A bb "ccc" "DDDD"
$ ! -- variant II --
$ z:=$sys$disk:[]z
$ z A bb "ccc" "DDDD"
$ del/symb z
$ !
$ set nover
$ exit

