Official Content

Executes a block of commands if the condition evaluates to true.

Syntax

If cond
       block1
[Else
       block2]
EndIf
 

Where:

cond
   Condition evaluated in the If.

block1
   Block that is executed if the cond condition evaluates to true.

block2
   Block that is executed if the cond condition evaluates to false.

Scope

Objects: Procedure, Transaction, Web PanelWork Panel, Panel Work With for Smart Devices
Generators: .NET, .NET Framework Java, RPG, Cobol, Ruby (up to GeneXus X Evolution 3), Visual FoxPro (up to GeneXus X Evolution 3)

Description

The If command allows you to condition the execution of command blocks.

Any command can be defined within block1 and block2 respectively.

Samples

If &del                    //&del is a boolean variable
  DelCustomer(CustomerId)  //DelClient is a Procedure and CustomerId is an attribute (with value in that context) sent by parameter
Else
  Return
EndIf

Restriction

When using this command in a Panel object or a Work With pattern and Work With object there is a restriction for the cond syntax. It can only contain a variable, attribute or SDT element of Boolean data type to be evaluated. 

 

   


Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant