OpenVMS Source Code Demos
BASIC-FOREIGN-CMD.BAS
1000 %title "vax_basic_foreign_cmd.bas"
%ident "version 1.00"
!
!0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
!1 2 3 4 5 6 7 8 9 0 1 2 3
!=========================================================================================================================
! Title : vax_basic_foreign_cmd.bas
! Author : Neil S. Rieck (Waterloo, Ontario, Canada)
! : (https://neilrieck.net) (mailto:n.rieck@bell.net)
! Purpose: to demo how to read command line parameters (works like "main(int argc, char *argv[])" in DEC-C)
! Usage : this program must be loosely connected to DCL as a foreign command like so:
! $command :== $ mypath:myprogram.exe
! then started from DCL like so:
! $command param1 param2 param3 (where params are optional command line args)
! History:
! 1.00 991126 1. original program
!=========================================================================================================================
option type=explicit
!
external long function lib$get_foreign( string by desc, string by desc, word by ref, long by ref)
!
declare long rc% ,&
i%, j% ,&
string junk$
!
rc% = lib$get_foreign(junk$,,,)
print "command line params: "; junk$
!
if junk$ <> "" then
junk$ = junk$ + " " ! add a trailing space
junk$ = edit$( junk$, 16%) ! multiple spaces + tabs to one space
i% = 1% ! start at char #1
j% = 9999% ! for 1st pass thru while/next
while j% > 0%
j% = pos( junk$, " ", i%) ! find next space
if j% > i% then ! if one was found
print "param: "; seg$( junk$, i%, j%-1%) ! then extract the string in between
i% = j% + 1% ! advance the starting pointer
end if
next
end if
!
end
Back to
Home
Neil Rieck
Waterloo, Ontario, Canada.