xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HB_ArgV()

Retrieves the value of a command line argument.

Syntax

HB_ArgV( <nPos> ) --> cArgValue

Arguments

<nPos>
This is a numeric value indicating the ordinal position of the command line argument to check. The value zero is

Return

The function returns the value of the command line argument at position <nPos> passed to thexHarbour application as a character string. If <nPos> is larger than HB_ArgC(), a null string ("") is returned.

Description

HB_ArgV() is used to retrieve the contents of command line arguments passed to an xHarbour application when it is started. The values are retrieved by their ordinal position and are returned as character strings. To ordinal position zero has a special meaning: it retrieves the name of xHarbour application.

Info

See also:HB_ArgC(), HB_ArgCheck(), HB_ArgString(), PCount(), PValue()
Category: Debug functions , Environment functions , xHarbour extensions
Source:rtl\cmdarg.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example implements the user-defined function AppName()
// which builds the application name upon initial call and
// returns it with or without complete path.

   PROCEDURE Main( ... )
      ? AppName()
      ? AppName(.T.)
   RETURN

   FUNCTION AppName( lFullName )
      STATIC scAppName

      IF scAppName == NIL          // path information
         scAppName := CurDrive() + ":\" + CurDir() + "\"

         scAppName += HB_ArgV(0)   // EXE file name

         IF .NOT. ".exe" IN Lower( scAppName )
            scAppName += ".exe"
         ENDIF
      ENDIF

      IF Valtype( lFullName ) <> "L"
         lFullName := .F.
      ENDIF

      IF .NOT. lFullName
         RETURN SubStr( scAppName, RAt( "\", scAppName ) + 1 )
      ENDIF

   RETURN scAppName

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe