[futurebasic] Re: [FB] Tree Foliage Example Improvement

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 2009 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Fri, 15 May 2009 17:13:13 +1200
andy@... wrote:

>>> I have knocked an example of producing a fractal-ish tree using a
>>> recursive function.
>>
>> If you are running FB5, this line:
>>> if myinc/10>1 then pen myinc/10 else pen 1
>> provokes a bug in FBtoC causing it to hang.
>> Replace the line by:
>> long if myinc/10>1
>> pen myinc/10
>> xelse
>> pen 1
>> end if


>  I don't think I understand
> this bug. Is this a problem with IF THEN ELSE or the PEN statement?

Here's the fixed PenStatement() source, which will be in the next  
release of FBtoC.

local fn PenStatement
'~'1
dim as long  parameter

fn GetLexeme // eat 'pen'
fn SendTextFragmentToOutputStream( "  FBPen( " )
long if ( gTheToken != _commaToken)
fn Expression( _integerGenericType )
xelse
fn SendTextFragmentToOutputStream( "-1" )
end if
parameter = 1
do
select gTheToken
case _commaToken
fn GetComma
fn SendTextFragmentToOutputStream( "," )
long if ( gTheToken != _commaToken )
fn Expression( _integerGenericType )
xelse
fn SendTextFragmentToOutputStream( "-1" )
end if
parameter++

case _eolToken, _colonToken, _elseToken // #346 added _elseToken  
20090515
do
fn SendTextFragmentToOutputStream( ", -1" )
parameter++
until ( parameter == 5 )

end select
until ( parameter == 5 )
fn SendTextLineToOutputStream( " );" )
end fn

Robert P.