POV-Ray : Newsgroups : povray.general : possible #switch error : Re: possible #switch error Server Time
30 Jul 2024 04:12:29 EDT (-0400)
  Re: possible #switch error  
From: Chris B
Date: 12 Nov 2009 08:57:18
Message: <4afc143e$1@news.povray.org>
"Brickman Brick" <ano### [at] anonymousorg> wrote in message 
news:4afbff1c@news.povray.org...
> The code reads a
> text file with integers. These integers are passed to the #switch
> statement.
> ...
> When the data is read from a file it is read as floats. So a converion to
> integers wouldn't be a bad idea?
>

Well strictly speaking there's no separate integer data type in POV-Ray, so 
everything is a float and it just comes down to the value, but if any 
calculations have been done on the value then there's a risk that it could 
potentially result in precision errors. If in doubt you could use the 'int' 
function to make sure.


> When I try to find the exact place where the code breaks, e.g. with a
> #debug statement. The code suddenly doesn't break anymore. When I remove
> the #debug the code is broken again.

Yes I can see how that would be frustrating :-)

I'm just thinking out loud here, so no clear thoughts, but if the 
#switch/#case statements are being used in conjunction with nested macro 
calls, then I wonder whether a wayward macro could sometimes return 
something that's interfering with the #case statements. I can't imagine how 
that could happen though without it producing a parse error of some sort, 
unless the macro contained a #break or a #case statement, which would 
probably be pretty self evident on looking at it.


> This is the frustrating part, when I try to provide a cut-down working
> example the code suddenly works again. So it is very hard to find the bug.

Well, if you do manage to get a version that consistently reproduces the 
problem (even if it's not cut-down), you could maybe post it somewhere like 
povray.text.scene-files or zipped on povray.binaries.scene-files and I'd be 
happy to try and take a look. I can't promise to spot the problem with 
something so intermittent, but sometimes just a fresh pair of eyes can help 
:-)

Regards,
Chris B.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.