comparison operators behaving oddly

Just starting out? Need help? Post your questions and find answers here.
veganisafreak
User
User
Posts: 32
Joined: Mon Jun 02, 2008 6:55 pm
Location: UK

comparison operators behaving oddly

Post by veganisafreak »

This is on Windows and Linux. I'm not posting it in the bug reports in case it's not a bug but...

Code: Select all

a.l
b.l

a = 1

b = a <> 1

Debug b

End
Shouldn't this debug 0 or "False"? I noticed this when I was converting a program from Blitz Basic and it didn't work.
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: comparison operators behaving oddly

Post by Demivec »

veganisafreak wrote:This is on Windows and Linux. I'm not posting it in the bug reports in case it's not a bug but...

Code: Select all

a.l
b.l

a = 1

b = a <> 1

Debug b

End
Shouldn't this debug 0 or "False"? I noticed this when I was converting a program from Blitz Basic and it didn't work.
PureBasic only allows comparison operators in 'If/ElseIF/EndIf' and in the expressions of the 'While/Wend' and 'Repeat/Until' commands. It is also possible to sneak them in a few other places, though it is unsupported and must be done carefully.

With your example, the value displayed by Debug is the right side of the expression 'a <> 1' because conditionals aren't supported in an assignment statement. This means it is not a bug, you're expecting the code to do something that is unsupported at this time.

Look here for some discussion on unsupported tricks to sneak comparisons into other places (for now). :wink:
Last edited by Demivec on Sat Jun 14, 2008 5:24 pm, edited 1 time in total.
veganisafreak
User
User
Posts: 32
Joined: Mon Jun 02, 2008 6:55 pm
Location: UK

Re: comparison operators behaving oddly

Post by veganisafreak »

Hi,

Thanks for the quick reply. PureBasic certainly is an idiosyncratic language. I guess I should have tried the demo, but I can't stand crippleware. I bought it on the basis that there are so many satisfied customers... and I hear it was spawned by Blitz... well I'm fairly happy so far anyhow. :D
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: comparison operators behaving oddly

Post by Demivec »

veganisafreak wrote:Hi,

Thanks for the quick reply. PureBasic certainly is an idiosyncratic language. I guess I should have tried the demo, but I can't stand crippleware. I bought it on the basis that there are so many satisfied customers... and I hear it was spawned by Blitz... well I'm fairly happy so far anyhow. :D
Once I tried it I knew it was the language I was looking for. The idiosyncracies took a little bit of time for me to get use to, but that is true of anything. I was most challenged by the terminology used to described different aspects of the language, not by the language itself.

As you become more familiar with the language you will find there is a great deal of information on these forums. If you search you will often find that something you're interested in has been discussed (and just as often, solved) many times already. :wink:



@Edit: ...a belated welcome also. :D
Last edited by Demivec on Sat Jun 14, 2008 5:26 pm, edited 1 time in total.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: comparison operators behaving oddly

Post by rsts »

veganisafreak wrote:Hi,

I bought it on the basis that there are so many satisfied customers... . :D
I believe you won't be disappointed. It's a fabulous language at a very reasonable price.

And a somewhat belated "Welcome" :)

cheers
veganisafreak
User
User
Posts: 32
Joined: Mon Jun 02, 2008 6:55 pm
Location: UK

Re: comparison operators behaving oddly

Post by veganisafreak »

Thanks a lot both of you for the warm welcome. :D

My favourite thing about PB so far is the freedom - it doesn't try to shelter the user from all the pointer/assembly type stuff like BB used to... BB was so restricting... and I took one look at BlitzMax and thought the syntax was a mess - it looked like it was trying to be three different languages at once - BASIC, Pascal and C++. Urgh.

Having said that, I don't think PB is as "BASIC" as it could be. I imagine if I didn't know what a pointer/array was... I would read the manual and still not know. Could be quite offputting for beginners. There should be an "absolute beginners" tutorial included.

PS Sorry for not searching the forum for my operators question. I guess I am impatient sort of person. :P
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

the pointers topic is only ~mentioned~ in the Manual, and it's said "for experienced users".
the thing is, playing with pointers is nothing for beginners, so it would be in the wrong place in an "absolute beginners" manual.

it would be a nice topic in a "so, now I am advanced, now I can start messing with pointers and programming my last nerve off"-tutorial.. ;)
oh... and have a nice day.
veganisafreak
User
User
Posts: 32
Joined: Mon Jun 02, 2008 6:55 pm
Location: UK

Post by veganisafreak »

Point taken.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

Go here:

http://www.xs4all.nl/~bluez/datatalk/pu ... xpressions

It's something I started writing as I had some 'adjusting' to do as well, coming from another basic dialect (GfaBasic).

However, PureBasic has definitely surpassed GfaBasic.

But... PureBasic is NOT C(++) so some things may differ, and assinging the result of an evaluation to a variable is simply not supported.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Post Reply