KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Avoiding problems with 4DACTION in compiled databases
PRODUCT: 4D | VERSION: | PLATFORM: Mac & Win
Published On: September 27, 2002

Compatibility: 6.7 and later

The 4D Web server handles requests starting with 4DACTION by calling a specific method. For example, after receiving the URL shown below, the 4D Web server calls the "sendfoo" method to answer the request:

https://www.example.com/4daction/sendfoo

The "sendfoo" method is shown here:

SEND HTML TEXT("Foo!")

In an uncompiled database, this method works perfectly and the user receives the text:

Foo!

In a compiled database, the same code produces an error like the one shown below:

A runtime error occurred at line number:
When executing the method:

Invalid parameters in an Execute command.


This error occurs because methods called by 4DACTION have implicit text parameters $0 and $1. Even though the code may not use these parameters, they should be declared for 4D's internal use. Here's how to rewrite the method to work correctly compiled and uncompiled:

C_TEXT($0;$1)

SEND HTML TEXT("Foo!")

Additional Notes :

ON ERR CALL does not catch the missing parameter declaration.
Compiling with "All variables are typed" will not reveal missing implicit parameter declarations.
The $0 parameter is no longer encouraged since 4D v6.7 and a declaration is not needed if the parameter is unused. The conservative approach is to declare it for compatibility reasons.