Mandelbrot sample code (if statement issue)
Posted: Sun Mar 08, 2009 1:02 pm
Hi,
I have an issue with the line
in the code below. The error message is:
error: COBRA INTERNAL ERROR / FallThroughException / info=TruthExpr-sh(12369, didBindInh=false, didBindInt=false, didStartBindImp=true, didBindImp=false, token=Token(DOT, '.', '.', ln 18, col 9, Mandelbrot.cobra), Treatment=AsIs, type=nil, 12369)
If I replace the if .calc…. with if .doIt (a dummy Boolean function), I get the same compiler error. So what is the correct Cobra syntax here?
Regards
Csaba
I have an issue with the line
if .calc(x/40, y/40) # error: here
in the code below. The error message is:
error: COBRA INTERNAL ERROR / FallThroughException / info=TruthExpr-sh(12369, didBindInh=false, didBindInt=false, didStartBindImp=true, didBindImp=false, token=Token(DOT, '.', '.', ln 18, col 9, Mandelbrot.cobra), Treatment=AsIs, type=nil, 12369)
If I replace the if .calc…. with if .doIt (a dummy Boolean function), I get the same compiler error. So what is the correct Cobra syntax here?
Regards
Csaba
# See <!-- m --><a class="postlink" href="http://www.timestretch.com/FractalBenchmark.html">http://www.timestretch.com/FractalBenchmark.html</a><!-- m -->
# 2009-01-13 Csaba Urbaniczky
# if .calc( x/40 , y/40) does not compile
class Program
const bailOut as int = 16
const maxIterations as int = 1000
def doIt as Boolean is shared
return true
def mandelbrot is shared
try
print 'Rendering'
for y as int in -39 :39 : 1
print
for x as int in -39 :39 : 1
# if .doIt , print '*', stop # give same kind of error
if .calc(x/40, y/40) # error: here
print '*', stop
else
print ' ' , stop
catch ex as Exception
print 'mandelbrot EXCEPTION: [ex]'
def calc(ci as number, y as number) as Boolean is shared
try
cr as decimal = y-0.5
zr as decimal = 0.0
zi as decimal = 0.0
for i as int in 0 : .maxIterations :1
zr2 = zr * zr
zi2 = zi * zi
if zi2 + zr2 > .bailOut, return false
temp = zr * zi
zr = zr2 - zi2 + cr
zi = temp + temp + ci
return true
catch ex as Exception
print 'calc EXCEPTION: [ex]'
return true
def main is shared
try
print 'Cobra Mandelbrot Start [ DateTime.now]'
startTime= DateTime.now
.mandelbrot
print
print 'Cobra elepsed [DateTime.now.subtract(startTime)] seconds'
catch ex as Exception
print 'main EXCEPTION: [ex]'