cliargslib
A program started from the CLI gets the words typed after its name as
parameters; one started from the Workbench gets the icons selected
with it, with Shift, or the project whose default tool it is.
NumPars tells how many there are and Par$ returns each, counted
from 1. FromCLI tells how the program was started.
For i=1 To NumPars
NPrint "Parameter ",i,": ",Par$(i)
NextWith runtime error checking, a parameter number below 1 or above
NumPars is the error “Non-Existent Parameter.” (“No parameters
passed.” if there are none); without it, such a
number reads beyond the list of parameters
(#106).
Based on the cliargslib guide by Acid Software.
Library number 106.
Commands
FromCLI
True (-1) if the program was started from the CLI (or from the editor), false (0) if it was started from the Workbench.
Function, result .w. Help text: result=FromCLI 0=Run from WorkBench, -1=Run from CLI
No arguments.
NumPars
The number of parameters given to the program, 0 if there are none.
Function, result .w. Help text: pars.w=NumPars Number of paramters passed to program.
No arguments.
From the CLI, myprog file1 file2 gives 2 parameters, separated by
spaces.
Par$
The text of parameter number Parameter#, from 1 to NumPars. For a Workbench parameter, this is the name of the icon’s file, and empty for a drawer, a disk or another icon that is not a file.
Function, result $. Help text: parameter$=Par$(Paramter#) Returns the string value of a parameter.
Arguments: .l
ParPath$
The drawer of Workbench parameter number Par#. With a type of 1 (or any other type but 0), it is the full name of the file, the drawer and the name joined. It needs AmigaOS 2.0 or newer and a start from the Workbench.
Function, result $. Help text: path$=ParPath$(Par#,#type) Full/Dir path of WB arg. (v36+ only!)
Arguments: .l, .w
For a drawer given as parameter, the drawer itself is the result with
type 0, while type 1 adds a / with the empty name. So: if Par$ is
empty, use ParPath$(x,0), else ParPath$(x,1). With runtime error
checking, a program started from the CLI gets the error “Can only call
ParPath$() when run from WB.”; without it, the result is not usable
(#107).