New function HB_ForNext() added

This commit is contained in:
Antonio Linares
2002-01-25 17:47:59 +00:00
parent 582e14dbc1
commit abe500dc5a

View File

@@ -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;
}
}
}
}