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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runninig EXE with Parameter

Status
Not open for further replies.

IRABYY

Programmer
Apr 18, 2002
221
US
Fellows,

say, you made a program in VFP with the first line being LPARAMETER tcParam, then compiled it into an EXE.

Of course, it perfectly runs from VFP IDE as DO MyProgram.PRG WITH "StringParam" off the Command window.

Now you need to run this EXE off the Windows environment WITH PARAMETER - how do I do this?

I tried to run it of the Start Menu/Run box, where I entered something like C:\MyProgram\MyProgram.EXE "StringParam" - and EXE ignored my parameter.

I ran it like C:\MyProgram\MyProgram.EXE StringParam (no qutation marks) - same thing.

What am I doing wrong?

Thanks!

Regards,

Ilya

 
When passing parameters to a compiled *.exe program you would pass the parameters without quotes but you need to include commas for additional parameters (still no quotes). Perhaps you should provide the code snipet from the top of this 'prg'.
 
Ilya,
Actually with or without the quotes it should work. (You only need the quotes if the data provided includes embedded spaces.) Try a simple:
Code:
*Myprg.prg
LPARAMETERS tcMessage
Messagebox(tcMessage)
Rick
 
Hej Ilya
Do you remember me ?
Is type of your parameter is string ? Character parameter (like Rick code) is OK. But when the parameter is numeric - my program write error (eg. '27' or "27" or 27). Kind regards from Warsaw !!!!!
Monika (monikai@yahoo.com)
 
in the main program of the exe use
PARAMETER parm1, parm2, ..... Attitude is Everything
 
robsutonjr: "Perhaps you should provide the code snipet from the top of this 'prg'."

OK, Rob, here it is:
Code:
&& Main.PRG
LPARAMETERS tcSourceDir
Later on in Main
Code:
DO FORM 'frmMain.SCX' NAME frmMain LINKED WITH tcSourceDir

In the frmMain.Init:
Code:
LPARAMETERS tcCurrDir
And after running all the checks and balances on the validity of that directory:
Code:
lcCurrDir = UPPER(tcCurrDir)
...
WITH THISFORM
...
   .txtDir.Value = lcCurrDir
...
ENDWITH

Essentially, I need to get the location of the new data to append to the existing data. Originally, operator had to select that location when program was alredy running, using GUI. To automate the process, I want to let operator enter that location (full path) as a command line parameter. And that's where I hit the snag: works as PRG, does not as EXE when run from Start/Run as

MyProg.EXE "C:\MyData\".

Any hints/ideas/suggestions would be greatly appreciated.

Regards,

Ilya

 
When starting an exe with parameters, the startupparameter is always of type character.
It is up to you as the SE to evaluate the paramteres.

The program that has been set as the main program in your project (say f.e. MyMain.prg) will receive the paramters given on the command line.

If you will have to set a lot of paramters I would suggest using an ini file or something likewise. And use the location of the ini file as a paramter.

HTH,
Weedz (Edward W.F. Veld)
My private project:Download the CrownBase source code !!
 
Fellows,

new development in the issue in subject:

When run from the Start/Run menu - ain't working;

When run from the DOS emulation (I still use ol' good Norton Commander for that) - it works!

Have anybody encountered that kind of problem?

The bad thing about it is that DOS abbreviates long file/folder names to "adjust" them to 8.3 standard.

Any workaround this one?

Regards,

Ilya

Regards,

Ilya
[/b]
 
Ilya,
I created this project in VFP 7.0:
Code:
LPARAMETERS lcP1, lcP2
IF PCOUNT() <2
   lcP2 = &quot;Default Title&quot;
   IF PCOUNT() < 1
      lcP1 = &quot;Default Message&quot;
   ENDIF
ENDIF

MESSAGEBOX(lcP1,0,lcP2)

And it worked with the following in VFP:
DO testparams
DO testparams WITH &quot;Message&quot;
DO testparams WITH &quot;Message&quot;, &quot;Title&quot;
Then I ran the following from the Start / Run in XP Pro:
Code:
c:\vfp70\testparams.exe
c:\vfp70\testparams.exe Message Title
c:\vfp70\testparams.exe &quot;c:\Message Area&quot; &quot;Title Line&quot;
These all worked as expected.

I've done similar things in VFP 5 and 6, and I'm not sure why you are having problems. I'd probably start with a WAIT WINDOW or Messagebox() in your Main.PRG and see what value is in your tcSourceDir, and then again in your Form Init() for tcCurrDir.

Rick
 
I've done similar things in VFP 5 and 6, and I'm not sure why you are having problems. I'd probably start with a WAIT WINDOW or Messagebox() in your Main.PRG and see what value is in your tcSourceDir, and then again in your Form Init() for tcCurrDir.

Rick

I did it also, way back when, in the FoxBASE 2.10+ days!
The problem is that a) I does not work off the Start/Run - just ignores parameters, and b) DOS does not take long file/folder names and/or containing spaces.

Regards,

Ilya
 
Ilya,
What OS are you running? What does DOS have to do with this? VFP is a Windows application. Please don't confuse a Windows Command Prompt with DOS. You CAN use long file names (with embedded spaces) at the Start/Run Command. e.g.
Code:
&quot;c:\program files\vfp70\testparams.exe&quot; &quot;c:\Message Area&quot; &quot;Title Line&quot;
Rick
 
Ilya,
What OS are you running?

Windows ME

What does DOS have to do with this? [mad]

In theory - nothing. In reality - when you use the DOS simulation it behaves exactly like DOS, that is truncates the long names.[smile]

VFP is a Windows application.

Granted.

Please don't confuse a Windows Command Prompt with DOS. [mad]

I don't. [smile]

You CAN use long file names (with embedded spaces) at the Start/Run Command. e.g.
&quot;c:\program files\vfp70\testparams.exe&quot; &quot;c:\Message Area&quot; &quot;Title Line&quot;

And that's exactly what does nor work off the Start/Run, spaces or not. That's what I've started this thread with.
I even compiled some simple program like

Code:
LPARAMETERS tcString

WAIT tcString WINDOW

RETURN

and it worked from Start/Run menu.
But my production program did not, even though it worked from the simulation of the DOS environment, and even with spaces in the path when the path was taken into quotation marks.

Any ideas why that might happen?


Rick

Regards,

Ilya


 
Ilya,
I just tried the same program on an Win98 SE system, and it worked inside VFP, in the Start / Run dialog box and even in a DOS Prompt Window. I'm not sure where your problem is, but I don't believe it's in VFP or the OS. Note: I am using all the &quot;current&quot; versions of VFP - 5.0 SP3, 6.0 SP5, 7.0 SP1 (8.0 beta).

I hope you find your problem, but I've run out of ideas to test.

Rick
 
rgbean (Programmer): I've run out of ideas to test.

Well, thanks to all of you, guys!
If I find what's wrong with this matter - and is worth posting - I'll post the outcome of this struggle [smile] here.

Regards,

Ilya
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top