KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Compiling Object and Collection Values and Data Type
PRODUCT: 4D | VERSION: 17 | PLATFORM: Mac & Win
Published On: December 19, 2018

Objects and collections are a powerful and flexible feature in 4D, however, that flexibility comes at the cost of higher chance of accidents and mistakes.

When using an object or collection it may be known to the developer that a value may have a specific data type such as a longint and even if preventitive measures were placed to make sure that the value is supposed to be a longint, if the expression evaluating the property or element is used the compiler may not accept the expression as a longint and can cause an error.

For example the following image shows that the code has a compiler error due to the Get database parameter having two possible first parameters, a table or a longint selector and the compiler can not arbitrarily make a choice.



In these situations a simple work around is to assign the value to an intermediate variable or use an evaluating command on the expression.

Using an intermediate variable:

C_OBJECT($obj_ob)
C_LONGINT($res_l)

$obj_ob:=New object("minTLS";105)

C_LONGINT($temp_l)
$temp_l:=$obj_ob.minTLS

$res_l:=Get database parameter($temp_l)

Using an evaluating command on the expression:
C_OBJECT($obj_ob)
C_LONGINT($res_l)

$obj_ob:=New object("minTLS";105)
$res_l:=Get database parameter(Num($obj_ob.minTLS))