Page 1 of 1

[PB 4.31 x86 Windows] Please generate an Error Message here

Posted: Sun Jun 14, 2009 4:08 pm
by Octopus
Well, today I have learned, that compare operators in parameter expressions are not (yet) supported. But then I would like to see a related error message generated in such cases.

Following example will compile still without errors even when the comment semicolon would be deleted, but crashes badly when been started then.

Code: Select all

If OpenConsole()
  Define.l answ, value = 7
  If value*2 < 3 : answ = 0 : Else : answ = 1 : EndIf
  PrintN(Str(answ))
;  PrintN(Str(value*2 < 3))
  Input()
EndIf

Posted: Mon Jun 15, 2009 9:28 pm
by harkon
With debugger on I get an invalid memory access

pbv4.30

Posted: Mon Jun 15, 2009 11:33 pm
by Kaeru Gaman
well, actually I see it as a Bug in the Str() Function, or in the container handling.

see this:

Code: Select all

a = ( value*2 < 3 )
Debug Str( a )
The fact that we get an IMA here shows that an operation returns an invalid pointer,
what should not happen, no matter if the expression is embedded in the function or not.


Boolean Expressions are not supported, so the Result is useless, not realy unpredictable but useless.
but the compiler does not forbid to use them, so they should not produce an IMA either.

Posted: Tue Jun 16, 2009 3:20 pm
by harkon
Kaeru,

In your example Str(a) is evaluated as "3" regardless of "value". :shock:

I must be missing something here. It's odd but I've never had to do bools this way, I've always used an "IF". I know I've done otherwise in VB but so far have never run up against this. Guess I've just been lucky.

Posted: Tue Jun 16, 2009 3:47 pm
by Kaeru Gaman
harkon wrote:In your example Str(a) is evaluated as "3" regardless of "value". :shock:
yes, thus I wrote "not really unpredictable but useless"

... but it works without IMA, and this is what it should.

I must be missing something here.
not really.
just remember that PureBasic does not support an Epression-to-Value functionality, always use an If and everything is shiny.

Posted: Tue Jun 16, 2009 4:04 pm
by harkon
Kaeru,

Yup will continue to do just that.