Welcome, Guest. Please login or register.

Author Topic: Blitz Basic: Reading arguments from the command line  (Read 2739 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline uncharted

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 1520
    • Show all replies
Re: Blitz Basic: Reading arguments from the command line
« on: May 26, 2006, 09:30:39 AM »
From the manual (about page 129)...

Quote

- NumPars

The  NumPars  function  allows an executable  file  to  determine  how  many
parameters  were  passed to it by either Workbench or the  CLI.   Parameters
passed  from  the CLI are typed following the program name and separated  by
spaces.

For example. Iet's say you have created an executable program called myprog,
and run it trom the CLI in the following way:

myprog filer Olle2

In  this  case,  NumPars would return the value '2' - 'file I ' and  'file2'
beng the 2 parameters.

Programs  run  from  Workbench are only capable of picking  up  I  parameter
through the use of either the parameter file's 'Default Tool' entry in  it's
'.info' file, or by use of multiple selection through the 'Shift' key.

If no parameters are supplied to an executable file,  NumPars will return 0.
During program development,  the 'CLI Arguement' menu item in the 'COMPILER'
menu allows you to test out CLI parameters.

Par$ (Parameter)

Par$ return a striny equivalent to a parameter passed to an executable  file
through  either  the CLI or Workbench.  Please refer  to  NumPars  for  more
information on parameter passiny.


FromCLI

Returns TRUE (-1)  if your program was run from the CLI, or FALSE (O) if run
from the WorkBench.

ParPath$ (parameter,type)

ParPath$  returns the path that the parameter resides in,  'type'  specifies
how you want the path returned:

0  You  want only the directory of the parameter returned.  1   You  want  the
directory along with the parameter name returned.

If you passed the parameter "FRED" to your program from WorkBench,  and FRED
resides  in  the  directory   "work:mystuff/myprograms"  then  ParPath$(0,0)
willreturn  "work:mystuff/myprograms",    but   ParPath$(0,1)   will  return
"work:mystuff/myprograms/FRED".

The  way WB handles argument passing of directories is different to that  of
files.   When a directory is passed as an argument,  ArgsLib gets  an  empty
string for the name,  and the directory string holds the path to the  passed
directory AND the directory name itself.


Hope this is useful.