PureBasic 4.50 is out !

Developed or developing a new product in PureBasic? Tell the world about it.
Seymour Clufley
Addict
Addict
Posts: 1264
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Re: PureBasic 4.50 is out !

Post by Seymour Clufley »

I think this is a brilliant update.

4.4 was important with maps and the 2D drawing enhancements, but 4.5 is perhaps an even more important update with the new ability to have maps, lists etc. inside structures. For me this is an extremely useful ability that simplifies a lot of work, and drastically reduces memory consumption (compared to static arrays).

Thank you, thank you, thank you!

Seymour.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: PureBasic 4.50 is out !

Post by srod »

I agree, one of the most significant upgrades to Purebasic ever. Awesome.

Thanks team. Much appreciated.
I may look like a mule, but I'm not a complete ass.
PrincieD
Addict
Addict
Posts: 858
Joined: Wed Aug 10, 2005 2:08 pm
Location: Yorkshire, England
Contact:

Re: PureBasic 4.50 is out !

Post by PrincieD »

Seymour Clufley wrote:4.4 was important with maps and the 2D drawing enhancements, but 4.5 is perhaps an even more important update with the new ability to have maps, lists etc. inside structures. For me this is an extremely useful ability that simplifies a lot of work, and drastically reduces memory consumption (compared to static arrays).
Agreed definately! I'm already using maps and lists inside structures in the latest build of ProGUI im working on.

Thanks PB team! :D

Chris.
ProGUI - Professional Graphical User Interface Library - http://www.progui.co.uk
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Re: PureBasic 4.50 is out !

Post by Flype »

Congratulation Fred and Freak for this - must have - release.

All the new stuff is terrific and increase the interest of this language.

It's very pleasant to re-code some old programs cleaner thanks to the new features.
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
akee
Enthusiast
Enthusiast
Posts: 496
Joined: Wed Aug 18, 2004 9:52 am
Location: Penang, Malaysia

Re: PureBasic 4.50 is out !

Post by akee »

Hi! Out of programming habit with VBScript, I discovered this...

Code: Select all

Procedure LOGICAL(a, b)
  ProcedureReturn a = b
EndProcedure

delta = Not LOGICAL(1, 1)

Debug delta
PB Sample produces an error.

Code: Select all

Function LOGICAL(a, b)
  LOGICAL = a = b
End Function


delta = Not LOGICAL(1, 1)

WScript.Echo delta
VBScript does not.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: PureBasic 4.50 is out !

Post by blueznl »

Code: Select all

Procedure LOGICAL(a, b)
  ProcedureReturn a = b
EndProcedure

delta = Not LOGICAL(1, 1)

Debug delta
Dunno, but that is entirely unsensible code :-) so I'll forgive PureBasic for throwing an answer :-)

Let's start by turning this line

Code: Select all

ProcedureReturn a = b
into

Code: Select all

ProcedureReturn b
Then NOT is a keyword only used in combination with conditions, such as IF. PB doesn't do boleans, only ints and floats. Your procedure returns an integer, and how can one invert an integer? One cannot. Well, perhaps you could do something like this:

Code: Select all

Procedure LOGICAL(a, b)
  ProcedureReturn b
EndProcedure

delta = 0-LOGICAL(1, 1)

Debug delta
Better post this in the questions section next time I guess :-)
( 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... )
User avatar
Melissa
User
User
Posts: 71
Joined: Tue Sep 22, 2009 3:13 pm

Re: PureBasic 4.50 is out !

Post by Melissa »

Code: Select all

Procedure LOGICAL(a, b)
  ProcedureReturn b
EndProcedure
Image

Code: Select all

Procedure LOGICAL(a, b)
if a = b : ProcedureReturn #True : EndIf
EndProcedure

delta = (Not LOGICAL(1, 1))

Debug delta
...Simple as that.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: PureBasic 4.50 is out !

Post by blueznl »

True, but what I wanted to show is that you should not use a = b as a procedure return value. People should stop asking if the following works:

a = (a = b )

BECAUSE IT DOESN'T.

It's everywhere, in the docs, in the FAQ, even in my pathethic survival guide. I'm tempted to suggest to Fred to put a new feature in: whenever the demo or the normal version of PureBasic is started for the very first time, it should load a demo program that goes something like this:

Code: Select all

  ; please examine this example code carefully
  ; 
  ; a = (a = b )  ; <== THIS DOES NOT WORK. NO. IT DOESN'T. IT WON'T. IT WILL NOT BE SUPPORTED.
  ;
  ; please read the manual or visit the forum
I don't mind questions, no matter how dumb, but this one is so all over the place that it's frankly a little annoying.
Pfff.

I think I had a bad day :-)
( 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... )
User avatar
GWarner
Enthusiast
Enthusiast
Posts: 605
Joined: Fri Jul 24, 2009 1:34 pm
Location: USA

Re: PureBasic 4.50 is out !

Post by GWarner »

Maybe using the equal sign for two different purposes isn't such a good idea.

C and PHP solves the problem by using "=" as the assignment operator and "==" as the comparison operator.
Pascal solves the problem by using := as the assignment operator and = as the comparison operator.

Both remove the ambiguity about what the = is supposed to do.
User avatar
nase09
User
User
Posts: 33
Joined: Sat Jun 07, 2008 11:45 am

Re: PureBasic 4.50 is out !

Post by nase09 »

GWarner wrote:Maybe using the equal sign for two different purposes isn't such a good idea.
C and PHP solves the problem by using "=" as the assignment operator and "==" as the comparison operator.
Pascal solves the problem by using := as the assignment operator and = as the comparison operator.
Both remove the ambiguity about what the = is supposed to do.
but Purebasic is Basic, so it would be a bad idea to use e.g. Pascal or C syntax..
Mr Coder
User
User
Posts: 54
Joined: Tue Apr 13, 2010 8:02 am

Re: PureBasic 4.50 is out !

Post by Mr Coder »

nase09 wrote:but Purebasic is Basic, so it would be a bad idea to use e.g. Pascal or C syntax..
So true! Too many people here forget that, and want PureBasic to be something other than Basic. :roll:
User avatar
mk-soft
Always Here
Always Here
Posts: 6202
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: PureBasic 4.50 is out !

Post by mk-soft »

a small assistance without a warranty for future versions

Code: Select all

Macro BOOL(assert)
  ((assert) Or #False)
EndMacro

Procedure foo1(a,b)
  
  ProcedureReturn bool(a > b)
  
EndProcedure

Procedure foo2(a,b)
  
  ProcedureReturn bool(a < b)
  
EndProcedure

c = foo1(a,b)
Debug c

c = foo2(a,b)
Debug c
Show asm output :wink:

P.S. Also computations can be implemented

Code: Select all

Macro BOOL(assert)
  ((assert) Or #False)
EndMacro

For i = 1 To 10
  c = i * 10 * bool(i >= 5)
  Debug c
Next
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
GWarner
Enthusiast
Enthusiast
Posts: 605
Joined: Fri Jul 24, 2009 1:34 pm
Location: USA

Re: PureBasic 4.50 is out !

Post by GWarner »

I know that PureBasic is BASIC, nor am I suggesting that it should use C or Pascal syntax, if you had really read my message you would have seen that.

I'm just suggesting that using the same operator for two completely different purposes isn't such a good idea. The designers of C and Pascal apparently didn't think it was a good idea either.

Since this is dragging this thread way off topic, I'll stop here.
User avatar
Frarth
Enthusiast
Enthusiast
Posts: 241
Joined: Tue Jul 21, 2009 11:11 am
Location: On the planet
Contact:

Re: PureBasic 4.50 is out !

Post by Frarth »

I entirely agree with blueznl. People migrating from (Visual) BASIC are VERY used to boolean expressions as return values or as part of formulas.

With PureBasic working with boolean expressions is still very confusing. For example, this works:

Code: Select all

Procedure.i LeapYear(Year.i)
  ;returns:
  ;  - True (1) If the given year is a leapyear
  ;  - False (0) if the given year is not a leapyear
  ProcedureReturn ((Year % 4) = 0) And ((Year % 100) <> 0) Or ((Year % 400) = 0)
EndProcedure

Debug LeapYear(2008)
Debug LeapYear(2009)
Yet, this simple one does not work:

Code: Select all

Procedure Equal(a.i, b.i)
  ProcedureReturn (a = b)
EndProcedure

Debug Equal(1, 2) ;should return 0 (#False), but returns 2 instead.
IMHO people new to PureBasic should be thoroughly informed about this!
PureBasic 5.41 LTS | Xubuntu 16.04 (x32) | Windows 7 (x64)
Thorium
Addict
Addict
Posts: 1305
Joined: Sat Aug 15, 2009 6:59 pm

Re: PureBasic 4.50 is out !

Post by Thorium »

I read somewhere on the forum that boolean expressions are planed. So we will see how they solve the = issue. ^^

@Frarth: It's not confusing, because they are not supported outsite of if statements. So you should not use them in formulas at all. It's planed and i hope it will come, but it's not just yet supported.

Anyway a compiler error message would be nice.
Post Reply