Skip to main content Skip to complementary content
Close announcements banner

Tests and branches

 

If – Compare

This parameter compares the contents of two strings/Constants/Null values.

IF b.Field1/N@n =/<>/</<=/>/>= b.Field2/N@n/Constant/Null Then  … 
…
Else
…
EndIf

 

IF b.Field1/N@n =/<>/</<=/>/>= b.Field2/N@n/Constant/Null Then Goto Tag 

 

You can compare to Null only with = or <> operator.

/* Assign value 1 in W.Field_2 if W.Field_1 is ‘O’,
/* else assign 0 
  W.Field_2 = 0
  If W.Field_1 <> 'O' Then
    W.Field_2 = 1
  EndIf 
 
/* Skip when I.codeX equal to X
  If I.CodeX = 'X' Then Goto *SKIP

 

SCAN – Search and branch

This parameter searches for the first occurrence of a string within another string from a given position and branches to a tag depending on whether or not the string was found.

SCAN b.Field1 WITH b.Field2/Constant POS N@n IFFOUND    Tag 
                                             IFNOTFOUND 

 

SCAN searches in field1 for the byte series contained in field2 as the position specified in N@n, and places the position of the first occurrence found in N@n which must be numeric.

The branch to the tag depends on the test condition.

/* Find all occurrences in buffer I.DESCRIPTION
/* with the character à to replace it with @. 
  N@0 = 0 
  BEGIN_SCAN: 
    SCAN I.LIBELLE WITH 'à' POS N@0 IFNOTFOUND END_SCAN
    I.LIBELLE(N@0:1) = ’@’ 
    GOTO BEGIN_SCAN 
  END_SCAN:

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!