1

The Compile() method returns an error when Windev can not compile it.

For instance (correct code):

teller is int = hnbrec("client")
result teller

This code returns the amount of items in de Client datafile.

But when I make a typo like:

teller is int = hnbrec("client")
result telles //should be teller

Windev does not mention an error...

But when I make a typo like:

teller iss int = hnbrec("client") //should be is
result teller

It throws a syntax error telling me it does not recognize iss.

How do I check the second example so it will throw an error?

EDIT: However when I execute the code with

ExecuteProcess("<the process name>", trtProcedure)

The process will return an error saying it does not know telles... But I don't want to execute the process, I only need to check it and write it to the database.

Teysz
  • 741
  • 9
  • 33

1 Answers1

0

The compile function will only return errors if they are fatal enough:

"result telles" is not an error, as windev can't guess if it will exist at the time of execution; "telles" could be the name of a global variable or some other external ressource that isn't known by the compiler at this point since the context of the compilation here is that you are already in a running app that was precompiled and it does have access to the source code and cannot scan it to validate syntax anymore.

It will know that there is an error only when the interpretor executes the line (Yes it's more an "instanciated" code than a truly "compiled" code in traditionnal term that the name of the function Compile() would make believe...).

It just can't know that "telles" is wrong in such a dynamic context unless PCSFOT breaks the compile() function and forces a limited scope of just himself :)

I think in your case this will require a more defensive coding style:

WHEN EXCEPTION IN
    teller is int = hnbrec("client")
    result teller
DO
    result -1 //Meaning something whent wrong in your function
END

And then when you call your dynamic proc you will have to test the returned value.

I hope this helps, happy holidays!