×
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

Command Line Parameters

Command Line Parameters

(OP)
Can I pass a parameter to a compiled Visual FoxPro executable? If so, how do I pass it and where do I need to put the parameters statement in my project?

RE: Command Line Parameters

You will need to set a PRG file as the main project file, then this is your entry point in the EXE.
And there goes your LPARAMETERS. The OS limits you to receive string values only, you only get the typical .F. value for non passed in parameters, all parameters up to PCOUNT() will be string type.

You don't get command line parameters like -C to specify a config.fpw or -L to specify a certain language resource runtime DLL. Those are handled by the runtime before your code is executed.

Besides, even without LPARAMETERS you could determine parameterization of the EXE via

CODE

Declare String GetCommandLine in win32api
? GetCommandLine() 
Eg if doing so for your VFP IDE you get the EXE name itself. The string will always begin with the path and EXE file name and then continue with parameters, including the command-line options the runtime already consumed of course.

Bye, Olaf.

PS: Also see https://www.berezniker.com/content/pages/visual-fo...

Important to notice: EXE Parameters have to be separated by spaces and if you want a parameter to contain a space put it in double quotes, actually just the way EXE parameters work, but not the way you parameterize a VFP function with comma separated values and native types. There also are no by reference parameters to an EXE, so eg you can't call param="Hello, World" and then RUN YOUR.EXE @param and expect param to change after the exe finishes, actually I'd expect you'd get "@param" in the first parameter of YOUR.EXE, then, not even the param value "Hello, World".

RE: Command Line Parameters

Yes, this is easy. Just add an LPARAMETERS statement at the start of your main program. For details of the syntax of this statement, see the relevant Help topic.

Note that the values received will be local to the main program. If you need to use those values elsewhere, you will need to store them in a suitable variable or property, or pass them down the chain as parameters to lower-level functions or methods.

To pass the parameters, just add them to the command line in the normal way, that is, after the name of the executable. You can do that in a desktop shortcut, from a Run command, from a Dos session, or anywhere else.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Command Line Parameters

(OP)
Thanks! Seems pretty simple and extremely useful.

RE: Command Line Parameters

Quote:

You don't get command line parameters like -C to specify a config.fpw or -L to specify a certain language resource runtime DLL. Those are handled by the runtime before your code is executed.

Just to amplify this a bit, you should review the help file entry on startup switches.

You cannot pass, for example, /complete because VFP will look for a config file named "omplete". Avoid ALL of the startup switches VFP uses internally.

RE: Command Line Parameters

Yes, dan, at least avoid them for your own concerns, of course you can combine switches the runtime acts on and pass in further parameters arriving at your LPARAMETERS.

Bye, Olaf.

RE: Command Line Parameters

Some of those I use are as follows, they seem to be safe enough.

-P
-I
-S
-J
-F

You only really need one, to specify that the real parameters are in a file happy shades

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.

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