For To Step command

Official Content
This documentation is valid for:

Iterates a value for a certain number of times.

Syntax

For &var = start to end [step leap]
       code
Endfor

Where:

&var
   
Is a variable based on the Numeric data type.

start, end
    Are numeric expressions showing the start and the end of the loop.

step
    Specifies the leap of the loop.

leap
    Is a constant value.

code
    Sequence of valid language commands.

Scope

Objects: Procedure, Transaction, Web Panel
Generators: .NET, .NET Framework, Java, RPG, Ruby (up to GeneXus X Evolution 3), Visual FoxPro (up to GeneXus X Evolution 3)

Description

This command allows iterating a value for a certain number of times. It is a loop from the start value of &var and it increases a leap, as long as &var is <= than end. The leap default value is 1, but it can also be a negative number. 

Notes:

  • As it's usual in GeneXus, the scope of the loop variable is the whole object
  • The value of the loop variable outside the loop is not defined/documented and may change through platforms and versions.

Samples

Event Refresh
    &Tabs = LoadPageTabs(&PageType, &PageFullName, &PageId, &PageLastVersionId1)
 
    // Select the subset of tabs that will be shown.
    &FirstTab = 1
    &LastTab  = &Tabs.Count

    &IsFirstTab = True
    For &Index = &FirstTab To &LastTab
        &Tab = &Tabs.Item(&Index)
        Do 'LoadItem'
        &IsFirstTab = False
    EndFor
    ...
EndEvent