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

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Octopus
User
User
Posts: 55
Joined: Sat Jun 13, 2009 6:42 am
Location: Munich (Germany)
Contact:

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

Post 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
harkon
Enthusiast
Enthusiast
Posts: 217
Joined: Wed Nov 23, 2005 5:48 pm

Post by harkon »

With debugger on I get an invalid memory access

pbv4.30
Missed it by that much!!
HK
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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.
oh... and have a nice day.
harkon
Enthusiast
Enthusiast
Posts: 217
Joined: Wed Nov 23, 2005 5:48 pm

Post 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.
Missed it by that much!!
HK
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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.
oh... and have a nice day.
harkon
Enthusiast
Enthusiast
Posts: 217
Joined: Wed Nov 23, 2005 5:48 pm

Post by harkon »

Kaeru,

Yup will continue to do just that.
Missed it by that much!!
HK
Post Reply