KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Compiler Errors with Object Attributes
PRODUCT: 4D | VERSION: 18 | PLATFORM: Mac & Win
Published On: May 25, 2021

It is always nice to have the 4D compiler return no errors. When using objects attributes as parameters of methods and 4D commands, compiler errors can be returned complaining about typing or missing parameters. This is because attributes do not have a declared typing and the 4D compiler can get confused about the intended use for the attribute.

For example, there are many 4D commands which have an optional first parameter, such as the DIALOG command or METHOD GET PATHS command. If the intended use of the command is to omit the first paramter and use an object attribute as the second paramter, the compiler will not be able to figure this out and will assume that the object attribute is intended to be used as the first parameter, causing a missing parameter error.

As such, the parameter should be typed specifically. Two ways to do so are to assign the value of the attribute to a declared variable of the required type. The second way is to cast the attribute as the inteded type using commands such as String, Num, Date, Time, Bool, ect.