Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

command-line parameters limitations?

Status
Not open for further replies.

thatguy

Programmer
Aug 1, 2001
283
US
hey there folks--

I'm trying to pass in a command-line parameter to an exe and it seems that there are a couple "special" characters that aren't allowed? the code is simple enough:

Code:
LPARAMETERS tcCLP

LOCAL llInvalidCLP

STORE .f. to llInvalidCLP

=MESSAGEBOX(TRANSFORM(PARAMETERS()))
=MESSAGEBOX(TRANSFORM(tcCLP))

IF PARAMETERS() > 0
	IF TYPE('tcCLP') == 'C'
		tcCLP = UPPER(ALLTRIM(tcCLP))
		DO CASE 
			CASE tcCLP == '/C'
				llNewConfig = .t.
			OTHERWISE 
				llInvalidCLP = .t.
		ENDCASE
	ELSE
		llInvalidCLP = .t.
	ENDIF
	IF llInvalidCLP
		=MESSAGEBOX("Command-line parameter usage:"+CHR(13)+CHR(13)+;
		  "/c -"+CHR(9)+" Create a new INI file"+CHR(13)+;
		  "/? -"+CHR(9)+" This help screen",0+16,"")
		dropout(plDev)
	ENDIF
ENDIF

this works just fine unless the parameter starts with "/" (slash), "-" (dash), or "+" (plus) (without the quotes).. in those cases, parameters() returns 0 and tcCLP is .F. i get the same results starting from Start->Run or a command prompt, altho, running the prg from the command window works fine, tho there i have to enclose the parameter in quotes.

are these special characters that aren't allowed to start a command-line parameter? i'd like to be able to use a / or - since it's pretty standard.

any thoughts?

thanks
-- frank~
 
Hi,

I am probably misreading your post, but there are some 'reserved' parameters - I've taken the items below from the help text:

Code:
Switch  Description  
-A 
 Ignore the default configuration file and Windows registry settings.
 
-BFileName,Duration 
 Display a custom bitmap (.bmp), .gif, or .jpg graphic file and specify its display duration in milliseconds when Visual FoxPro starts. You can also include the -B command-line switch in a Visual FoxPro shortcut.

Note:  
If the bitmap you specify cannot be located, the bitmap does not display when Visual FoxPro starts. 
 

 
-CFileName 
 Specify a configuration file, including a path if necessary, other than the default file, Config.fpw.
 
-LFileName 
 Specify a resource file, including a path if necessary, other than the default, vfp*ENU.dll, so you can use Visual FoxPro in a language other than the current language specified by Windows.
 
-R 
 In earlier versions, refresh the Windows registry with information about Visual FoxPro, such as associations for Visual FoxPro files. In later versions, use /regserver.
 
-T 
 Suppress the display of the Visual FoxPro splash screen. By default, when Visual FoxPro starts, it displays a splash screen that shows the Visual FoxPro logo, version number, and other information. If you prefer that users of your application not see this splash screen, you can prevent Visual FoxPro from displaying it using the -T command-line switch.
 
/? 
 List the available command-line arguments. Available in Visual FoxPro 7.0 and later.
 
/regserver 
 Register Visual FoxPro default registry keys.
 
REGSVR32 server.dll 
 Register a .dll component.
 
/unregserver 
 Remove Visual FoxPro default registry keys.
 
/u server.dll 
 Remove a .dll component.



Regards

Griff
Keep [Smile]ing
 
DOH!!

thanks for the response..

i saw those in the help file too, but i didn't notice the line just above the grid:

Add the switch after Vfp8.exe or any Visual FoxPro-created .exe on the command line or in a shortcut.

i guess there's no way to get around those so i can use the "/C" for my own program...?

-- frank~
 
thatguy,

Super questions and brilliant observation. I, unfortunately, do not have a solution to this. I'm looking into it though. "Switches" appear to be completely ignored by VFP. You can even interlace them amongst other parameters being sent in and only the parameters that do not begin with "/" or "-" are sent. I've never noticed this before, but you're absolutely right that switches are fairly common in command line parameters.

boyd.gif

 
Hi again,

You have to restrict yourself to switches which AREN'T used by VFP.

I use -P, -I and -S at present.

The only solution is likely to be a kludge - using a reference to point to a text file, which contains parameters in plain english.

for example:

Code:
myprog.exe -PConfig.ini

Then access it within the opening lines of your code, using the location of the .exe - sys(16) as a basis


Regards

Griff
Keep [Smile]ing
 
Sorry, I said use the location of the .exe - because a windows path may have spaces in it, and then you get a parameter for each 'segement' of the path (as delimited by the spaces).


Regards

Griff
Keep [Smile]ing
 

It does seem a bit odd that you can't use parameters reserved for VFP, even though some of those parameters have no meaning in an EXE -- such as suppressing the display of the VFP splash screen. It's a pity because prefixing params with / or - is a very common convention.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Some other suggestions:

1. Begin all your options with "/opt:"

This makes your command line options stand out more and prevents any conflicts with VFP's built in parms.

2. Use a small C based loader app that grabs all command line parms, prefixes them with a special string (for example "/vfp:") and then passes these on to your real EXE.

Interesting thread!

Malcolm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top