KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Type variables when using commands with parameters that take in multiple data types
PRODUCT: 4D | VERSION: 19 | PLATFORM: Mac & Win
Published On: April 4, 2023

As a general rule of thumb, it is important to always type your variables when developing your database; this is especially important when working with commands with parameters that can take in multiple data types.

Take the BASE64 ENCODE and BASE64 DECODE commands, for example. Their input and return parameters can be of either the BLOB or Text data types.





When inputting an untyped variable into one of these parameters, unexpected results can come about (see below).


With untyped variables:


With typed variables:


When the $decoded variable is untyped, the command defaults to decoding the base64 text to a text value; in this case the returned output is a blob value rendered as a string of various symbols, when it should have been returned as the blob data type. This is why to ensure that the command returns your expected value, it is imperative to type your variables.