Re: Possible Bug in 4.0 with warning()

new topic     » goto parent     » topic index » view thread      » older message » newer message
twbeaty said...

Hello all.

I might have a bug here, but I'm unsure if it's been reported. I've found that when I use warning() in my code, it is called even when, according to the code, it shouldn't be. Here's an example:

export function eqtQuadIntToSequence(integer count, atom ptr) 
 
	if (count < 1) or (count > 4) then 
trace(1) 
		warning("eqtQuadIntToSequence(): Parameter \"count\" out of range.") 
		if count < 1 then 
			count = 1 
		else 
			count = 4 
		end if 
                -- ? 1/0 
	end if 
	return peek4u({ptr, count}) 
 
end function 

If count is given the value of 36, then the expected happens. The trace window comes up, and the custom_warning is printed. However, if count is 3, there is no trace window (again, expected), but the warning still appears at the end of the run. I created an ex.err file with the ? 1/0 I have commented out in the code, and it showed that the count was 3 and the warning() code was never run. I don't want to flood the post by pasting the ex.err file here, but I can email it should anyone want a look at it.

- Travis.

This is the expected behaviour, and not (imho) a bug.

warning() is a parse time command. You'd use it to flag using a deprecated routine, for instance. All builtin warnings are like this. And since it is a parse time command, it is impervious to values of variables or expressions. It would work with constants though.

If you need run time warnings, the good ole print(2,"Here's a warning"), or using a message box, should be the thing to do. If the docis unclear about this, I'll clarify it.

CChris

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu