This is actually pretty simple in UniData - UniBasic. The call to
'SYSTEM(17)' tells you whether you're running from the command line or
as a called routine. Here's a program I wrote along these lines.
SUBROUTINE GET.UDT.OPTION(RES, OPTNO)
* GET.UDT.OPTION - Get the value of one specific UDT.OPTION
* May be invoked either as a Subroutine or from the command line.
* M. Blum, 12/7/2004
FROM.CMD = SYSTEM(17) = 0 ;* Invoked from the Command Line
IF FROM.CMD THEN ;* Invoked from Command Line
SENT = CONVERT(' ', @FM, TRIM(@SENTENCE))
OPTNO = SENT<2>
END
EXECUTE 'UDT.OPTIONS' CAPTURING XX.OUT
XX.OUT = TRIM(XX.OUT)
OPT.LINE = ''
LOOP
REMOVE A.LINE FROM XX.OUT SETTING DELIM
IF FIELD(A.LINE,' ',1) = OPTNO THEN
OPT.LINE = A.LINE
EXIT
END
WHILE DELIM DO
REPEAT
IF FROM.CMD THEN
IF OPT.LINE = '' THEN OPT.LINE = 'Not Found!'
PRINT OPT.LINE
END ELSE
RES = FIELD(OPT.LINE, ' ', 3)
RETURN
END
END
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/