Viva Clipper !

HB_ForNext

Advertisements

HB_ForNext

Inline FOR…NEXT loop

Syntax

         HB_ForNext( <nStart>, <nEnd> | <bEnd>, <bCode> [, <nStep> ] )

Arguments

<nStart> : initial value for loop counter

<nEnd> : the final value of loop counter

<bEnd> : a code block to define end of loop

<bCode> : a code block include statement(s) to execute within loop. This code block automatically receives the nIndex of the For…Next loop as a parameter:

             { | nIndex | ...code... }

<nStep> : increment value for loop counter

Description

HB_ForNext() is function to implement a FOR…NEXT loop implementation in a single line

Example

      PROC MAIN
           * SETMODE( 58, 128 )

            HB_ForNext( 1, 10, { | i1 | QQOUT( STR( i1, 3 ) ) } )

           ?

           aDays := ADays()

            HB_ForNext( 1, LEN( aDays ), { | i1 | QOUT( i1, aDays[ i1 ] ) } )

           ?
           WAIT 'EOF HB_ForNext.prg'
        RETU // MAIN

        /*

        Result :

          1  2  3  4  5  6  7  8  9 10

                 1 Sunday
                 2 Monday
                 3 Tuesday
                 4 Wednesday
                 5 Thursday
                 6 Friday
                 7 Saturday

        EOF HB_ForNext.prgEOF HB_ForNext.prg

        */

Files

Library is misc

Seealso

FOR…NEXT

Advertisements

Advertisements