×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

command-line parameters limitations?

command-line parameters limitations?

command-line parameters limitations?

(OP)
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~

RE: command-line parameters limitations?

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 ing

RE: command-line parameters limitations?

(OP)
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~

RE: command-line parameters limitations?

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.


www.sweetpotatosoftware.com

RE: command-line parameters limitations?

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 ing

RE: command-line parameters limitations?

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 ing

RE: command-line parameters limitations?


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)

RE: command-line parameters limitations?

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close