xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HB_ArgC()

Returns the number of command line arguments.

Syntax

HB_ArgC() --> nArgCount

Return

The function returns the number of command line arguments.

Description

When an xHarbour 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().

Info

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

Example

// The example outlines the difference between PCount() and
// HB_ArgC(). Command line arguments can be retrieved in the
// start routine with PCount()/PValue(), or anywhere in a program
// with HB_ArgC()/HB_ArgV()

   PROCEDURE Main( ... )
      LOCAL i

      FOR i:=1 TO PCount()
        ? i, PValue(i)
      NEXT

      ? "-----------"
      Test()
   RETURN


   PROCEDURE Test
      LOCAL i

      FOR i:=1 TO HB_ArgC()
        ? i, HB_ArgV(i)
      NEXT

   RETURN

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