|
-
Nov 3rd, 1999, 10:44 PM
#1
Thread Starter
Lively Member
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]
-
Nov 3rd, 1999, 10:46 PM
#2
Hyperactive Member
look at the command$
this is for running an exe with parameters you get it as a string is this what you meant???
-
Nov 4th, 1999, 04:54 AM
#3
Thread Starter
Lively Member
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]
-
Nov 4th, 1999, 05:03 AM
#4
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).]
-
Nov 4th, 1999, 05:18 AM
#5
Thread Starter
Lively Member
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]
-
Jul 27th, 2001, 06:14 PM
#6
PowerPoster
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|