Command Line Parameters Command Line Parameters tkee (Programmer) (OP) 22 Jul 15 18:44 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 Olaf Doschke (Programmer) 22 Jul 15 19:05 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 CODEDeclare 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 Mike Lewis (Programmer) 22 Jul 15 19:06 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 tkee (Programmer) (OP) 22 Jul 15 19:10 Thanks! Seems pretty simple and extremely useful. RE: Command Line Parameters Dan Freeman (Programmer) 23 Jul 15 02:51 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 Olaf Doschke (Programmer) 23 Jul 15 05:36 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 GriffMG (Programmer) 23 Jul 15 08:31 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 Regards Griff Keep ing 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.