The proper syntax of the If/Then structure is as follows:

if (Condition to Evaluate) then * Code to execute if condition evaluates to True*
else * Code to execute if condition evaluates to False*
end

where:

  • if, entered in all lower case, initiates the structure
  • (Condition to Evaluate) is a single field or block of code that results in a True or False determination
  • then, entered in all lower case, concludes the condition evaluation section of the structure
  • Code to execute if condition evaluates to True is the code block that Ninox will execute should the condition in the evaluation section of the structure results in a True determination
  • else, entered in all lower case, is an optional clause that indicates that there are actions to be taken (code to be executed) at such time that the condition in the evaluation section results in a False determination
  • Code to execute if condition evaluates to False is the code block that Ninox will execute at such time that the evaluation condition returns a False determination
  • end, entered in all lower case, is a required clause that closes (concludes) the if/then structure.

Things to keep in mind when constructing an If/Then structure are:

1. The key elements of the structure, if, then, else and end, are case sensitive and must be entered in all lower case

2. the if, then and end elements of the structure are required

3. the else clause and the code that follows it, are optional

4. In the absence of an else clause and code block, Ninox will perform no action should the evaluation condition of the If/Then structure return a false value and there is no else clause

5. Variables created inside and If/then structure can only be referenced from inside the structure. Once the end clause is recognized by Ninox, all variables created inside the structure cease to exist. For this reason, and at such time that a variable may be referenced both inside and outside the structure, it should be created and initialized outside the structure.

Below is an example, and analysis, of the if/then structure being used within a Ninox database application.

In the example above, the condition being evaluated in order to determine what action to take is ‘Unit Price’ = null. This line of code translates into “is the field ‘Unit Price’ currently empty?”. If the code returns a True result, then the second line of code – ‘Unit Price’ := Item.Price will be executed. In this line of code, Ninox is looking up the price of an item selected from inventory and assigning that value to a field called ‘Unit Price’ in the current record of the current table. Finally, the end clause on line 3 indicates that no action is to be taken if the ‘Unit Price’ field is not empty.

Below is an example, and analysis of an if/then structure, with both a true and a false code block and an embedded if/then, being used within a Ninox database application.

The structure above is assigned to a Formula Object in a database data model. The purpose of this formula field is to display text that indicates to the user how many pieces of inventory are currently in stock. The evaluation of this structure is as follows:

The first condition to be evaluated (on line 1) is “are we currently out of stock?” If the result of this evaluation is true – ‘Current Stock’ = 0 – then the text string “Out of Stock” is to be displayed. However, if there is more than zero items in the current stock, then a second loop – the embedded loop – is evaluated to determine just how much stock there is. On line 4, the evaluation condition is “is there only one item left in stock”. If the result of this evaluation is true – ‘Current Stock’ = 1 – then the text string “Last One” will be displayed. However, if the conditional evaluation of stock is such that there are more than 1 item(s) remaining – the clause ‘Current Stock’ = 1 results in a False determination – then the text string “Many in Stock” shall be displayed.

Not that there is not condition to be evaluated to determine exactly how many items are in stock. The evaluations of the clauses on lines 1 and 4, if both true, have determined that there is, in fact, more than zero and more than 1 item(s) in stock. Whether that means there are two items remaining or two hundred items remaining is irrelevant. What is relevant (and, more importantly, true) however is that there are indeed “many” items in stock.

Note that there are two end statements required as there are two if/then clauses.

Revision: 4
Last modified: 2019/03/31

Zpětná vazba

Bylo to užitečné ?

Ano Ne
Označili jste toto téma za neužitečné...
Mohli byste nám, prosím, říct, proč ? Děkujeme !
Děkujeme za vaši zpětnou vazbu.

Sdělte nám váš názor na toto téma.

Prosím, nepoužívejte toto pro otázky k podpoře.
Pro zákaznickou podporu, nás kontaktujte zde.

Zveřejnit komentář.