Results 1 to 6 of 6

Thread: Program.exe C:\Dir\Filename.txt

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Location
    California
    Posts
    115

    Post

    With most programs, you can type that and the program will open that file. How can I get my program to be able to use switches (flags in unix)? So it will be able to open a file in this format: MystupidProgram.exe c:\Filename.txt

    Thanks.

    ------------------
    Ryan French
    Niresoft Incorporated
    http://www.niresoft.com
    [email protected]

  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Galway, Ireland
    Posts
    316

    Post

    look at the command$

    this is for running an exe with parameters you get it as a string is this what you meant???


  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Location
    California
    Posts
    115

    Post

    Thanks for telling me about Command$ Here is what I tried out and seems to work ok, but I'm sure there must be a way to check to see if the Command$ command is a file or just a switch (flag)

    Code:
    Private Sub Form_Load()
    On Error Resume Next
    If Command$ > "" Then
    RichTextBox1.LoadFile Command$
    End If
    End Sub
    Is there a better way to do this?


    ------------------
    Ryan French
    Niresoft Incorporated
    http://www.niresoft.com
    [email protected]

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    The Command Function has no intelligence, all it does is returns a String which contains any Parameters passed to your Application.
    If you want to be able to pass switches aswell as files, just check the Command value before executing any code, eg.
    Code:
    If Left(Command, 1) = "/" Then 
        ' Switch Command
    Else
        ' File Path
    End If
    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


    [This message has been edited by Aaron Young (edited 11-04-1999).]

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Location
    California
    Posts
    115

    Post

    Would there be a way to check Command$ to see if my file .ext existed? If so, then it opens the file?

    I sorta know how it should be coded, something like (I'm sure this wouldn't work if tested)

    Code:
    If InStr(Command$, ".ext") = True Then
    'does something
    End If
    ------------------
    Ryan French
    Niresoft Incorporated
    http://www.niresoft.com
    [email protected]

  6. #6
    PowerPoster eiSecure's Avatar
    Join Date
    Jul 2000
    Location
    Texas
    Posts
    2,209
    Alternatively, you can loop through Command() and parse all the file names, so if the user has specified more than one file, your program will get it too.

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