Click to See Complete Forum and Search --> : Program.exe C:\Dir\Filename.txt
Ryan
Nov 3rd, 1999, 09:44 PM
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
support@niresoft.com
john_murphy
Nov 3rd, 1999, 09:46 PM
look at the command$
this is for running an exe with parameters you get it as a string is this what you meant???
Ryan
Nov 4th, 1999, 03:54 AM
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)
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
support@niresoft.com
Aaron Young
Nov 4th, 1999, 04:03 AM
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.
If Left(Command, 1) = "/" Then
' Switch Command
Else
' File Path
End If
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net
[This message has been edited by Aaron Young (edited 11-04-1999).]
Ryan
Nov 4th, 1999, 04:18 AM
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)
If InStr(Command$, ".ext") = True Then
'does something
End If
------------------
Ryan French
Niresoft Incorporated
http://www.niresoft.com
support@niresoft.com
eiSecure
Jul 27th, 2001, 06:14 PM
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.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.