Results 1 to 6 of 6

Thread: App Parameters

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Location
    Classified
    Posts
    234

    Question

    What must be done in order to allow my application to take in parameters, such as 'myapp.exe /myparam1 /myparam2' ?
    My ICQ Status: (85634850)

    Seriously Sick Tshirts

  2. #2
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    Use the command function...

    Code:
    MsgBox Command
    and if you want to test certain command line arguments without compiling your app goto Project/Project Properties and fill in the Command Line Arguments Edit Box.
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  3. #3
    Addicted Member KrishnaSantosh's Avatar
    Join Date
    Feb 2001
    Location
    Coimbatore
    Posts
    210
    VB Supports Command Line Parameters
    Through Command

    Command Doesn't Parse The
    Command Line For You. It
    Just Stores The Command Line
    Params As Such

    In Your Example : MyAPP.Exe /myparam1 /myparam2

    Command Stores "/myparam1 /myparam2".

    For More Details And Samples EMail Me.

  4. #4
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628
    its pretty easy to parse though.
    dim params(10) as string
    dim cl as integer
    dim ltr as string
    der = 0
    for cl = 1 to len(command$)
    do
    ltr = mid$(command$, cl, 1 )
    loop while ltr = " "
    if ltr = / or ltr = "-" or ltr = "\" then
    der = der + 1
    if der = 11 then exit sub
    end if
    params(der) = params(der) + mid$(command$, cl, 1)
    next cl
    'may contain bugs. But basically, it parses command$ into an array, removing spaces.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  5. #5
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    If you have VB6 you can use the Split function...

    Code:
    Dim v
    Dim iCt as Integer
    
    v = Split(Command, " ")
    
    For iCt = LBound(v) to UBound(v)
     Debug.Print v(ict)
    Next iCt
    and if you have VB4 or 5 you can use the Split2 function on this thread.
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  6. #6
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Wink

    but what results will he get if they put more than one space between parameters? That's why my little routine looped back on itself as long as it found spaces.
    This is the actual sub i use in my dos vb. (with sub declaration corrections)
    I did not write it. It is copied from the visual basic 1.0 help file.
    Code:
     SUB Comline (NumArgs as integer, Args(99) as string, MaxArgs)
     CONST TRUE = -1, FALSE = 0
    
         NumArgs = 0: in = FALSE
         ' Get the command line using the COMMAND$ function
         Cl$ = COMMAND$
         L = LEN(Cl$)
         ' Go through the command line a character at a time
         FOR I = 1 TO L
              C$ = MID$(Cl$, I, 1)
              ' Test for character being a blank or a tab
              IF (C$ <> " " AND C$ <> CHR$(9)) THEN
              ' Neither blank nor tab; test if you're already inside
              ' an argument
                   IF NOT in THEN
                   ' You've found the start of a new argument
                        ' Test for too many arguments
                          IF NumArgs = MaxArgs THEN EXIT FOR
                          NumArgs = NumArgs + 1
                          in = TRUE
                   END IF
                   ' Add the character to the current argument
                   Args$(NumArgs) = Args$(NumArgs) + C$
              ELSE
              ' Found a blank or a tab.
                   ' Set "Not in an argument" flag to FALSE
                   in = FALSE
              END IF
         NEXT I
    
     END SUB
    Last edited by Lord Orwell; Feb 17th, 2001 at 03:51 AM.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width