| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Retrieves the value of a command line argument.
HB_ArgV( <nPos> ) --> cArgValue
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.
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.
| 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 |
// 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
http://www.xHarbour.com