From abe500dc5a2fa2e1e2403f59af530303ac293af1 Mon Sep 17 00:00:00 2001 From: Antonio Linares Date: Fri, 25 Jan 2002 17:47:59 +0000 Subject: [PATCH] New function HB_ForNext() added --- harbour/source/vm/eval.c | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/harbour/source/vm/eval.c b/harbour/source/vm/eval.c index e8af3a33d5..48d065705f 100644 --- a/harbour/source/vm/eval.c +++ b/harbour/source/vm/eval.c @@ -342,4 +342,49 @@ void hb_evalBlock( PHB_ITEM pCodeBlock, ... ) va_end( args ); hb_vmFunction( uiParams ); +} + +HB_FUNC( HB_FORNEXT ) /* nStart, nEnd | bEnd, bCode, nStep */ +{ + LONG lStart = hb_parnl( 1 ), lEnd; + PHB_ITEM pEndBlock = hb_param( 2, HB_IT_BLOCK ); + PHB_ITEM pCodeBlock = hb_param( 3, HB_IT_BLOCK ); + LONG lStep = ( hb_pcount() > 3 ) ? hb_parnl( 4 ) : 1; + + if( ! pEndBlock ) + lEnd = hb_parnl( 2 ); + + if( pCodeBlock ) + { + if( pEndBlock ) + { + hb_evalBlock0( pEndBlock ); + lEnd = hb_parnl( -1 ); + + while( lStart <= lEnd ) + { + hb_vmPushSymbol( &hb_symEval ); + hb_vmPush( pCodeBlock ); + hb_vmPushLong( lStart ); + hb_vmFunction( 1 ); + + lStart += lStep; + + hb_evalBlock0( pEndBlock ); + lEnd = hb_parnl( -1 ); + } + } + else + { + while( lStart <= lEnd ) + { + hb_vmPushSymbol( &hb_symEval ); + hb_vmPush( pCodeBlock ); + hb_vmPushLong( lStart ); + hb_vmFunction( 1 ); + + lStart += lStep; + } + } + } } \ No newline at end of file