Module cCommandLine.pkg

     1// CLASS: cCommandLine
     2// Author: SWB
     3
     4use VDFBase.pkg
     5
     6{ ClassLibrary=Common }
     7{ HelpTopic=cCommandLine }
     8Class cCommandLine is a cObject
     9
    10    Procedure Construct_Object
    11        Forward Send Construct_Object
    12
    13        Property Handle phoArgs // private object-handle of internal array of arguments
    14    End_Procedure
    15
    16    { Visibility=Private }
    17    Procedure Private_DoCreateArgsArray
    18        // creates the array for holding the arguments. Created upon demand only!
    19        Integer icArg
    20        String sArg
    21
    22        Object oArgs is an Array
    23            Delegate Set phoArgs To self
    24            Repeat
    25                CmdLine sArg
    26                If (sArg <> "") Begin
    27                    Increment icArg
    28                    Set Value  (icArg -1) To sArg
    29                End
    30            Until (sArg = "")
    31        End_Object
    32    End_Procedure
    33
    34    Function CountOfArgs Returns Integer
    35        //Returns the number of arguments passed
    36        If (phoArgs(self) =0) Send Private_DoCreateArgsArray
    37        Function_Return (Item_Count(phoArgs(self)))
    38    End_Function
    39
    40    Function Argument Integer iIndex Returns String
    41        //Returns the one-based argument string
    42        If (phoArgs(self) =0) Send Private_DoCreateArgsArray
    43        Function_Return (Value(phoArgs(self), iIndex -1))
    44    End_Function
    45
    46End_Class
    47