Log In    |    Knowledge Base    |    4D Home
Tech Tip: Use a 4D method in the "Variable or Expression" property of a form widget
Published On: May 24, 2023

When looking at the "Variable or Expression" section of a form widget's property list, it is easy to first think that either a process variable or a primitve data value are the only options to insert here. In reality, you can also insert the name of a project method that would contain an algorithm to output a value. Take a look at the example below.

Here, we have a simple form with a single text input box that displays a numeric value. In the property list, the "Variable or Expression" property is populated with the name of a method, "myMethod". This method outputs the result of a simple arithmetic expression:

// My Method Method
// returns a value to be inserted into the the text box

// declare parameters
#DECLARE()->$c : Integer

// declare variables
var $a; $b; $c : Integer


return $c

When the form is run, you get the following result, where the text input box displays the result of the "myMethod" method: