HB_ArgV

HB_ArgV

Retrieves the value of a command line argument

Syntax

      HB_ArgV( [<nPos>] ) --> cArgValue

Arguments

<nPos> : ordinal position of the command line argument to inspect

Returns

This function returns diffetrent values as character strings depending on [<nPos>] :

         Value         Return
         -----         -------
         NIL           Full file specification ( path + file name and estension of .exe file )
         zero          Same as NIL
         1             First argument in the command line
         2             Second argument in the command line
         ...
         >HB_ArgC()    Null String

Description

HB_ArgV() is used to retrieve the contents of command line arguments passed to an Harbour application when it is started. To ordinal position NIL or zero has a special meaning: it retrieves the full file specification of Harbour application (excecutable).

Example

      // If command line is :  C:\temp>test.exe p1 p2

        ? HB_ArgV()     // C:\temp\test.exe
        ? HB_ArgV( 0)   // C:\temp\test.exe
        ? HB_ArgV( 1 )  // p1
        ? HB_ArgV( 2 )  // p2
        ? HB_ArgV( 3 )  // ( Null String )

Seealso

HB_ArgC(), HB_ArgCheck(), HB_ArgString(), HB_ArgShift(), PCount(),HB_PValue(), HB_AParams()

HB_ArgShift

HB_ArgShift

Updates HB_ARG*() parameter list removing the 1-st one and replacing it by others

Syntax

      HB_ArgShift( [<lProgName>] ) -> NIL

Argument

<lProgName> : If .T. first non internal parameter is moved to hb_argv(0) and all next are shifted.

Returns

NIL

Description

This procedure shifts command line argument each time called and can be used for implementing command line arguments by a loop.

Note

Each time HB_ArgShift() called, return value of HB_ArgC() decremented

Example

      // If command line is :  C:\temp>test.exe p1 p2 //p3 p4 p5
      lProgName := .F.
      nArgC := HB_ArgC()
      FOR nArgNo := 1 TO nArgC // HB_ArgC()     // Each time HB_ArgShift() called, return value of HB_ArgC() decremented
         ? nArgNo, HB_ArgV( 1 )
         HB_ArgShift( lProgName  )
      NEXT
      // Result  :
      // <lProgName>
      // .F.       .T.
      // --------- ---------
      // 1 p1      1 p1
      // 2 p2      2 p2
      // 3 //p3    3 //p3
      // 4 p4      4 //p3
      // 5 p5      5 //p3

Seealso

HB_ArgV(), HB_ArgC(), HB_ArgCheck(), HB_ArgString(), PCount(), HB_PValue(), HB_AParams()

HB_ArgCheck

HB_ArgCheck

Checks existence of an internal switch on the command line

Syntax

      HB_ArgCheck( <cSwitch> ) --> <lExists>

Arguments

<cSwitch> : A character string holding the symbolic name of of an internal switch

Return

.T. (true) when the command line include an internal switch, otherwise .F. (false)

Description

There are two kind of internal switches : prefixed and regular. Prefixed internal switches always have two slashes as prefix. This function tests existence of prefixed switches.

Note

Use function HB_ArgString() to retrieve the value of an internal command line switch

Example

      // If command line is :  C:\temp>test.exe p1 p2 //p3
      ? HB_ArgCheck( 'p' ) // .T.

Seealso

HB_ArgC(), HB_ArgV(), HB_ArgString(), HB_ArgShift(), PCount(), HB_PValue(), HB_AParams()

HB_ArgC

HB_ArgC

Returns the number of command line arguments

Syntax

      HB_ArgC() --> nArgCount

Returns

The function returns the number of command line arguments

Description

When an Harbour application is started, it can be passed arguments from the command line which are received by the initial routine of the application.

HB_ArgC() determines this number of arguments. The contents of command line arguments can be retrieved with function HB_ArgV().

Example

      // If command line is :  C:\temp>test.exe p1 p2
      ? HB_ArgC() // 2

Seealso

HB_ArgV(), HB_ArgCheck(), HB_ArgString(), HB_ArgShift(), PCount(), HB_PValue(), HB_AParams()