Thursday, July 14, 2011

FoxPro Tips: How to Passes Parameters into FoxPro's Executable

Passing command line parameters from Windows to Visual FoxPro (VFP) created executable is different from passing parameters to FoxPro programs or functions in VFP application, as;

- All parameters are passed to .exe file as strings,
- Parameters should not be enclosed in a single quotes because
  quotes will be treated as part of a parameter,
- Parameters which contains spaces can be enclosed in double quotes,
- For a list of parameters, it's must be separated by spaces not commas.

In order to accept command line parameters Visual FoxPro application main program must begin with lparameters or parameters statement. In this case, a VFP's form cannot be main in Visual FoxPro application because command line parameters are not passed to the form's Init method.

It's not recommended to use a switch like parameters (that starts with '-' or '/') because they may conflict with FoxPro command line switches. You can finds the complete list of VFP switches in Command Line Switches topic in Visual FoxPro help.

Also be careful with data type passed and it's casts.

No comments: