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

'No Parameter Statement is Found' thrown on built exe - but Running PRG works fine

Status
Not open for further replies.

OneLChela

Programmer
Oct 8, 2018
4
US
Hi,

I have a Visual Foxpro program, which I can run just fine as a prg in the Visual FoxPro IDE.

When I create an exe and try to run, however, it gives me an error.

'No Parameter Statement is Found'

Re this related thread: thread184-736412:

I do not begin with a parameter statement -because I am not passing it parameters via the command line.

However, I do declare local variables at the top of my PRG, and prompt the user with InputBoxes for values to store in them.

I then call a function within the prg with the local variables.

As mentioned, this works just fine running in a prg. When I run as a exe however, it will run the part of the program that prompt the user for input, and then throws the error above.

The function is set up with implicit declaration, EG, FUNCTION myFunc(parameter1, param2,...)
and being called with local variables like this: myFunc(var1, var2...)

I run the exe by simply double clicking on it.

Let me know if you need more information. Any help would be much appreciated.

Thanks,

OneLChela.


 
From what you describe the structure of your main PRG is:

Code:
Local var1, var2

var1=InputBox('prompt1','caption1','1')
var2=InputBox('prompt2','caption2','2')
myfunc(var1,var2)

Function myfunc(para1,para2)
  * do something with the parameters
  MessageBox(para1+para2)
EndFunc
And you get the error "No parameter statement is found".

Trying I don't get problems. So the problem has to be somewhere else you don't expect it to be. This structure alone does not produce that error.
Which version of VFP is this? Is there any config.fpw, do you use a shortcut for the start or start the EXE directly?

You should implement an error handling routine telling more details about the error, most important the line number, read about error handling, here's a simple thing you can do, put this as your first line of code in your main.prg:
Code:
On Error MessageBox(Textmerge("Error <<Error()>> in Line <<Lineno()>> of <<Program()>>:"+Chr(13)+Chr(10)+"<<Message()>>"))
If the error shows up without this message format telling error number and line of code of which PRG if you get the error as before just stating the error message and no location, the error happens even before this ON ERROR establishes the new error handling. Then - no matter why you think you don't pass any parameters - you do pass parameters to the EXE.

If that happens, just leave the error message up and don't react to it, instead open up the Windows task manager. Activate the details tab, and if the column "command line" isn't displayed, add that to the headers by right-clicking somewhere in the headers area and picking "choose columns". Somewhere in the list, you'll find command line.

If you're right the command line should contain nothing more than the path to your EXE, if you err, there you'll see which parameters were passed in.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Hello everyone, thanks for your replies:

foxincloud,

It has to be referencing the right prg, because I only have one prg, and the exe executes part of the code before throwing an error.

Olaf, you are correct about my program structure.

To answer your questions: I am running version 9, I use no config file, and I click on the exe directly.

Using the command-line field in Task Manager, I see that it is running with no parameters, only the exe.

Your error message reveals that there is an error on the line at the top of the program where I put your error statement.
This is line 15, due to my having some comments above the code at the top of the program.

(So I assume that means that it wanted to find parameters or LPARAMETERS there at the top, but didn't.)
This is strange, because the executable FIRST executes the code with the input boxes, (which come AFTER this top error line), before throwing the error message.

Curious.

ETA: I tried removing the comments, no help, same error

- OneLChela

P.S. As an aside, once I have added the error message, it seemed to be looping: It prompted me for input first, then threw an error message, then prompted for input again. (But my code has no loop. I guess it's retrying the same code over and over after the error message). I tried removing your error line statement and then noticed that it would also loop if I hit Ignore instead of Cancel)

 
Olaf,

From this related thread : thread184-1539944

I used your code:

Code:
LPARAMETERS lcPara1, lcPara2, lcPara3, lcPara4

* forgot to define lcParameters
Local lcParameters
* and more important, set it to empty string
lcParameters = ""

If Pcount()>0
   For lnCount = 1 to PCount()
       * this will error otherwise.
       lcParameters = lcParameters + ","+Transform(;
          Evaluate("lcPara"+transform(lnCount)))
   Endfor
   MessageBox("These parameters were passed in: "+;
   SubStr(lcParameters,2)+Chr(13)+Chr(10)+;
   "This exe should not be called with parameters, "+;
   "it does not accept parameters.")
Endif

When I run it, it shows me that it thinks the values I enter into the input boxes are parameters
 
I found it.

I noticed that Olaf's sample structure for my code did NOT cause the error when compiled to an exe.

So starting with his code, I started slowly transforming it into my code.

It was the name of the function. It was the same as the name of the Exe that I compiled (also the same name as the Project, FYI).
It was NOT the same name as the name of the prg.

I changed the function name slightly and it works.

Thanks everyone, especially Olaf, for your help!
 
Aha, OK.

Actually you can do a function with the syntax you gave: [tt]myfunc(var1,var2)[/tt] and by [tt]DO myfunc WITH var1,var2[/tt]. I would only expect the last syntax to cause DOing the EXE, but not the first one. But I also know myfunc(var1,var2) can also call a myfunc.prg, if it exists and no function of that name is defined in the current PRG.

Did you not find two processes listed once the error occured? The second start of the EXE caused the error, and it should still be a running process, as long as the error messagebox is displayed.

Seems to be interchangable in both directions. Maybe both ways of calling would even cause the same FXP object code, though the WITH syntax means passing parameters by reference and parameters passed as usual in brackets mean passing by value, unless you prefix them with @.

Something quite similar occurred to me by naming a cmd file as a shell command...

I have a naming convention I don't follow that strictly, but I name some functions prgFunctionname, so when I find a call to a function somewhere, maybe even from a method (not likely as you don't mix OOP code and structural programming) I know I find the definition of this function in a PRG file. Such a prefix will of course make it less likely it'd become the name of the EXE.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top