×
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

Jobs

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

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

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

(OP)
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: VFP 6.0 - Don't understand the 'No Parameter statement is found'..:

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.


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

Make sure your project references the right prg file

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

Can you show us the actual code that throws the error.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

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

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
https://www.doschke.name

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

(OP)
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)

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

(OP)
Olaf,

From this related thread : thread184-1539944: Parameter statement not found

I used your code:

CODE --> Foxpro

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

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

(OP)
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!

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

Aha, OK.

Actually you can do a function with the syntax you gave: myfunc(var1,var2) and by DO myfunc WITH var1,var2. 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
https://www.doschke.name

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!

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