Deprecated: Array and string offset access syntax with curly braces is deprecated in /homepages/21/d38531796/htdocs/jose/smfforum/Sources/Subs.php on line 3825
Purebasic x64 - A beginners guide for Powerbasic Users.

Author Topic: Purebasic x64 - A beginners guide for Powerbasic Users.  (Read 42491 times)

0 Members and 1 Guest are viewing this topic.

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 936
  • User-Rate: +30/-4
    • it-berater
Purebasic x64 - A beginners guide for Powerbasic Users.
« on: November 17, 2009, 06:28:06 PM »
Normally I'd not look around and just do everything in Powerbasic.
Coming to a project where i need a x64 executable and DLL, I had no other choice then to look around.

I could have choosen for example "Pele's C" - its freeware and people like it. Anyway, personally I do not like C and all this stuff, this time I decided to stay with Basic.

So I remembered that I have a Purebasic licence for long time (since 30.01.2001).
Just never used it really, because I had PowerBasic.

So this time I had to go through this and learn "BASIC from New" to be able to make also x64 excutables and DLL's.

So i updated for the actual Version which is 4.31 and checked - yes there is also a Version of Purebasic x64 included in the Package. And its still the same licence which i bought 2001.

So the first Point goes to Purebasic. Purebasic is really a cheap thing, seeing that for the same licence, you never need to pay for Updates and you even get a basic Visual Designer included in the package.

Fine, so having no choice, I started to take a deeper look. The first days I was lost as a Powerbasic-Fan because the Syntax is quite different. But lets start with the Purebasic-Basics.

The first thing to know is that you have to install the PureBasic 4.31 x64 on a 64 bit OS.
You can't simply compile a x64 executable on a 32-bit OS. You may be able to do so with Visual Studio, but not with Purebasic.

The next thing to know is that the compatibility between the Purebasic x32 and the Purebasic x64 is suprisingly good.
Assume you have the PureBasic x64 in a Virtual Box installed under a X64 OS.
Then you just drag the code-files there - compile it new - and voila its now an x64  - DLL or executable.

One thing to watch for when transfering code from x32 to x64 are Pointers into memory:
The LONG-Datatype will stay as 32 bit when you just copy the code. This may crash on a 64 bit OS, because Memory needs 64 bit for adressing. Therefore better use the Purebasic INTEGER Datatype. This one will automatically change from 32 to 64 bit dependent on where you compile it. So using Pointers, you need to use the INTEGER Datatype. As a Powerbasic user, don't intermix with the INTEGER from Powerbasic which is a signed 16 bit Datatype.

So we come to the first issue which is the Purebasic Editor. The Purebasic Editor in 2001 was really a mess.
I remember when I mailed with "Fred" the creator of Purebasic:

Quote
> - there is no UNDO button.

    Yes it's missing.. I think I will add undo feature very soon..

At that time the Powerbasic Editor was already a fine tool as stable as it is today. But since then things greatly changed.
The original Powerbasic Editor did not change that much, but the Purebasic Editor made its way to a professional and reliable tool.
We must say taht Powerbasic Users will use SED and will then have a comparable Surface to the actual Editor that is included with PureBasic.

Everything is there, what we would expect from an Editor - and a lot more.
Some parts are still a bit more complex to realize then with Powerbasic (couldn't find a simple #COMPILE DLL that will do this).

Some parts are much easier then with Powerbasic -for example adding resource, Icons and a file-description.
Even a automatic Increasing of Built Numbers is there. In short just looking at the editor Purebasic will get another point.

Coming to the language itself, Purebasic was going (and maybe in some parts is still going) from a better Macro-Assembler to a real Hi Level language.

You can see the actual evolution in the Purebasic Forums at several place.

Also means, Code you wrote with an older Purebasic version (old is maybe 3.9) can not compile with a newer version (new is 4.3) without significant changes. Still new datatypes are added to complete the compiler, and some things are just still missing.

About code-backwards-compatibility the point goes to Powerbasic. You can just compile old code with the new Powerbasic.
Even code from 2001 will mostly work without many changes.

Even Example code which is delivered together with the Purebasic package may not compile with the same version.
Something that will definitely not happen with Powerbasic.

In my next Post we'll just take a closer look at the Code-differences between Powerbasic and Purebasic x64 to help those who need to make something in x64 "to get the drift" while staying with Basic.
« Last Edit: November 17, 2009, 07:31:47 PM by Theo Gottwald »

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 936
  • User-Rate: +30/-4
    • it-berater
Re: Purebasic x64 - A beginners guide for Powerbasic Users.
« Reply #1 on: November 17, 2009, 07:10:23 PM »
My first experinece with Purebasic was "Where is my SUB MAIN()" ?

The answer is very simple - there is none!

Anything you write in the Editor is automatically inside the SUB MAIN (implicite).
Thats a disadvantage for somebody coming from Powerbasic, as the code just doesn't look as clean as we are used to it.

But knowing that it is like that, you just live with it.
Where is my SUB MAIN() ? Anywhere outside of a PROCEDURE.

So we start declaring our Variables. In Powerbasic we would write:

Code: [Select]
GLOBAL T01 AS LONG,T02 AS STRING
In Purebasic it looks like this:

Code: [Select]
GLOBAL T01.l,T02.s
Which is somehow the same, less to write, maybe not as good readable, but no problem, so long you do not intermix "." and ",".

A bigger difference is with Pointers and structures.
Assume you have a structure in Powerbasic and you want to rebuilt the same structure in Purebasic.

While you would write in Powerbasic:
Code: [Select]
TYPE DATA
  a(9) AS LONG
   rft(10) AS STRING*256
END TYPE
LOCAL D01 AS DATA
You will be able to access your

Code: [Select]
D01.a(9)=1Which won't work like this in Purebasic.

This time you need to write more:

Code: [Select]
Structure DATA
   a[10].l
   rft.s{256}[11]
EndStructure

And the first thing you see is, that while in PowerBasic all "Ends" are separate from the thing they end:

Quote
END IF, END SELECT, END SUB

In Purebasic all "ENDs" are always together as a single word:

Quote
EndIf, EndSelect, EndProcedure

and the second thing you see, is that you have to add one more element to the Array to get the same number of elements.
Which is just true in structures, but not in normal Arrays. So better keep these special rules in mind.

Now take a look at the fixed lenght string in the Array and you see that the readabilty of the Purebasic code is a thing of discussion. At least for us long time Powerbasic users.

Saying that we come to pointers. In Purebasic the "*" in a Pointer-declaration is a part of the name.
Means a variable "*POI" is another variable then "POI". They would be declared like this:

Code: [Select]
GLOBAL POI.l,*POI.iTo get a value out of a Pointer you will take PeekL() and PeekQ()

Code: [Select]
xpos=PeekL(@*Point\x)

or use constructs with Unions like this

Code: [Select]
Structure Point64
  StructureUnion
    p.POINT
    q.q
  EndStructureUnion
EndStructure

Procedure.l EventHoverGadget()
  GetCursorPos_(cursor.POINT64)
  hndl = WindowFromPoint_( cursor\q )

For me this is far from the readablitiy of Powerbasic code, but still much better then C. But this may be a thing of behavior.
There is another thing, which is  a bit different in Purebasic. As you can see, API calls always end with an underscore, to make a difference to user procedures and Purebasic commands:

 hndl = WindowFromPoint_( cursor\q )

Like in old times before Powerbasic 9, all Procedures must be in the right sequence or you need to declare them first, because there is no second Pass in the Purebasic compiler. This is a issue, which makes me wonder because they implemented a lot of things into Purebasic ... even a OGRE-based 3D Engine, but no second pass.

Also actually there are MACROS which may be used for some sort of "OOP" but there is no real Object-Implementation like the one in PB 9.
Actually the Points for the compiler go to Powerbasic. But i have no doubt that we'll see things like a second Pass in one of the next Updates.

Another thing i missed in Purebasic are Procedure-LOCAL LABELS. I can define Labels in Purebasic. But they are always GLOBAL.
The fact that Labels are generally GLOBAL looks to me like a problem for complex projects.

I can make a GOSUB LABEL. I even have a FAKERETURN to take the return-adress from the stack when i want to jump back via a GOTO, for example in case of an error (nice Feature). But only in the "SUB MAIN" which is outside of any Procedure. Why not inside Procedures?

And then MACROS. No LOCAL labels. No MACROTEMP. How can i use a Jump inside an MACRO, if i do not have MACROTEMP ?
Maybe there are tricks out there at least they are not explained in the help for MACROS. And thats the place where i expect these things.
There may be chances to do such things inside the underlying Assembler. But actually we are talking only from the Purebasic compiler.

About the general stability, i can say that all things i did until now (while its not much code) worked really fine.
The possibility to just compile something for 32 and 64 bit is also a nice thing.

So after all i can recommend PureBasic for x64 things.

The editor is well done, the language has gone through many evolutions since 2001 - while from my point of view its not yet where Powerbasic is, in terms of code-quality and Syntax-Design, and COM Objects.

But then there are other things which are great features. For example - the compiler leaves out unused PROCEDURES from the final executable. So you can load all your libraries and the code will not blow up unnecessary. You can compile residents and these will just work as internal commands.

And this is my last tip for today. I hope this will help you to get a good start into Purebasic x64. If you already use it and you have more comments for Powerbasic users, post them here.

Code: [Select]
;Resident File
; Example from the Purebasic Forums
; Save as myres.pb in \PureBasic430\Compilers Folder
; use CMD and change (CD ..) to that folder.
; type: "pbcompiler myres.pb /resident myres.res"
; copy the resulting "myres.res" into the "\Resident" Folder
; restart Purebasic
; the structures are now available in the Tools-Help
; the MACROS can be used like builtin commands.

Macro MakeLong(low, high)
  low | (high<<16)
EndMacro

Macro LowWord(Value)
  Value & $FFFF
EndMacro

Macro HighWord(Value)
  (Value >> 16) & $FFFF
EndMacro

Structure char_array
  c.c[0]
EndStructure

Structure strg_array
  s.s{1}[0]
EndStructure

Structure Point64
  StructureUnion
    p.POINT
    q.q
  EndStructureUnion
EndStructure
« Last Edit: November 17, 2009, 07:37:27 PM by Theo Gottwald »

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 936
  • User-Rate: +30/-4
    • it-berater
Re: Purebasic x64 - A beginners guide for Powerbasic Users.
« Reply #2 on: November 18, 2009, 07:21:39 AM »
Here is another good tip. A completely free Book for Beginners.

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 936
  • User-Rate: +30/-4
    • it-berater
Re: Purebasic x64 - A beginners guide for Powerbasic Users.
« Reply #3 on: December 14, 2009, 08:11:12 PM »
Another funny thing is  - wether a problem or by concept -  Purebasic 4.40 does not have the ability to make FOR ... NEXT LOOP with non Integer values.

For this you need to use If or carefully selected REPEAT UNTIL Loops.
Therefore care must be taken when transfering code from other languages to Purebasic 1:1.

See here:
http://www.purebasic.fr/english/viewtopic.php?f=13&t=40282

For a Powerbasic user this is just funny ,and shows where both systems have their strenghts and weaknesses.
« Last Edit: December 16, 2009, 09:20:39 AM by Theo Gottwald »

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 936
  • User-Rate: +30/-4
    • it-berater
Re: Purebasic x64 - A beginners guide for Powerbasic Users.
« Reply #4 on: September 30, 2011, 10:12:16 AM »
I needed to do x64 stuff these days again. And doing so i had the chance to take a closer look at the actual PureBasic.
Here are some things i want to share with you.

First i thought of making a nice GUI.

Great, unlike in PowerBasic there is a Visual Designer included in PureBasic.

So i gave it a try and made a very simple form having nothing else then a treeview in it.

Doing so i realized that this thing doesn't work (at least under 7/x64).
The generated code doesn't compile. It brings error, even syntax errors!

Nice to look at - doesn't work.

Ok, so i needed to look around a bit, and as we have QTab as a free Visual Designer for PowerBasic,
the PureBasic People have PureFORM from here:

http://gnozal.ucoz.com/PureFORM.zip

there is even a manual available here:

http://gnozal.ucoz.com/PureFORM/PureFORM_Manual.htm

this thing works and produces fine code that compiles without changes under PureBasic x64 and also without changes under PureBasic x32.

Here is another Hint, for PowerBasic users who use PureBasic x64.

In PureBasic all API Calls end with an "-". Example:

SendMessage_(hTreeView, #TVM_HITTEST,0,Result)

don't forget that underscore or you may end up with a PureBasic command with the same name and another functionality.

Example: IsWindow() and IsWindow_()

The first one works only with PureBasic internal Handles, and the later one is the expected API call.

After all my actual tests, PureBasic compiled fine and worked without problems.
It has support for x64, unicode, DirectX and much nore already builtin.

The compiler-options about resources and Executable/Project/building are far ahead of any Editors we currently have for PowerBasic.

There are easy ways for adding Icons, increasing Build-Numbers, you can compile many different targets - at the same time and save all that as "Project settings". And much more.
In short: the PureBasic IDE is very good and beats the PowerBasic IDE with AutoCompletion and a lot nice features easily.

Having said that, the PureBasic Syntax is still (and this will never change) more like "C" then like BASIC.
But it develops in a good direction to my No. 2 Compiler after PowerBasic and my favourite x64 compiler.
« Last Edit: September 30, 2011, 10:17:33 AM by Theo Gottwald »

Offline Brice Manuel

  • Full Member
  • ***
  • Posts: 154
  • User-Rate: +0/-0
Re: Purebasic x64 - A beginners guide for Powerbasic Users.
« Reply #5 on: October 01, 2011, 09:30:46 PM »
Ok, so i needed to look around a bit, and as we have QTab as a free Visual Designer for PowerBasic,
the PureBasic People have PureFORM from here:

http://gnozal.ucoz.com/PureFORM.zip

there is even a manual available here:

http://gnozal.ucoz.com/PureFORM/PureFORM_Manual.htm

There is also PBDev which is free and very good.  PureVision costs money, but is very popular.

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 936
  • User-Rate: +30/-4
    • it-berater
Re: Purebasic x64 - A beginners guide for Powerbasic Users.
« Reply #6 on: October 04, 2011, 05:19:18 PM »
I have tried PureVision and it did not work for me, so i can'trecommend it.

Thanks for the Link for PBDev/PureBasic, it seems to work fine also.
« Last Edit: October 04, 2011, 05:43:43 PM by Theo Gottwald »

Offline Brice Manuel

  • Full Member
  • ***
  • Posts: 154
  • User-Rate: +0/-0
Re: Purebasic x64 - A beginners guide for Powerbasic Users.
« Reply #7 on: October 04, 2011, 07:15:35 PM »
Thanks for the Link for PBDev/PureBasic, it seems to work fine also.

One thing worth noting with PBDev.  Although there is no license included with the latest version, when the free version was first posted on the forums, it was free only for non-commercial use.  Commercial use required a purchase of a license.  I have no idea what the status is now, but if anybody is using it for commercial purposes, they might want to double check with the author to make sure they don't inadvertently step on any toes.

Offline Edwin Knoppert

  • Sr. Member
  • ****
  • Posts: 254
  • User-Rate: +11/-4
    • Hellobasic.com
Re: Purebasic x64 - A beginners guide for Powerbasic Users.
« Reply #8 on: October 05, 2011, 06:10:26 AM »
There is no way anymore to use it commercially.
I left it online until the website is being terminated in 2014 (or before)
PwrDev has support until 2014, PBDev not.
PureBasis looks complete but is in fact hobby, 90+ percent of the users are hobby and i had mostly poor experiance how people solved matters and such.
I abandoned PureBasic over a year ago, not my taste any longer.
My experiances are based on then, how it is now... ?

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 936
  • User-Rate: +30/-4
    • it-berater
Re: Purebasic x64 - A beginners guide for Powerbasic Users.
« Reply #9 on: October 05, 2011, 07:14:35 AM »
PureBasic? You buy a licence once and you have it forever.
Means that the users are always the same.

As the price is very competitive, the userbase is where people must look at the cent.
Students and such.

Opposite to that would be WinDev, Patrice recommends it.

Will have a higher part of commercial users because the price is "like a small car".
Too expensive for hobbyists.

Offline Brice Manuel

  • Full Member
  • ***
  • Posts: 154
  • User-Rate: +0/-0
Re: Purebasic x64 - A beginners guide for Powerbasic Users.
« Reply #10 on: October 05, 2011, 07:42:33 AM »
My experiances are based on then, how it is now... ?
More stable and a few more features.  It is what I am stuck with using now and I have not experienced any major issues even though there have been some changes in my multi-year absence.

Offline Patrice Terrier

  • ROMs
  • Hero Member
  • *****
  • Posts: 934
  • User-Rate: +62/-1
    • www.zapsolution.com
Re: Purebasic x64 - A beginners guide for Powerbasic Users.
« Reply #11 on: October 05, 2011, 10:22:36 AM »
Theo,

Look at the design interface and number of applications that have been done, then ask yourself with each specific programming tools they have been programmed, then it should not be too harsh to determin which are for hobbyist, and which are for the professional audience.

Visual Studio, WinDev and PowerBasic are making my days.
And the combination of WinDev + PowerBASIC is the most powerful bundle to use with the Windows 32-bit platform, now let's see how long it would take to PowerBASIC to produce a 64-bit version...
« Last Edit: October 05, 2011, 10:28:48 AM by Patrice Terrier »
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 936
  • User-Rate: +30/-4
    • it-berater
Re: Purebasic x64 - A beginners guide for Powerbasic Users.
« Reply #12 on: October 05, 2011, 12:18:01 PM »
Patrice, do you use WinDev for x64, or VS?

Actually a PB x64 would make my day. I hope its not too far.

But no matter if its far or near.
Until i have it, I have to look around somewhere else.

About WinDev, I downloaded a DEMO,and did not understand a thing even how to make a "Hello world".
It would only make sense if i find somebody to teach me a crash course maybe.

Also what i have seen in their forums, the support can not compare to the PowerBasic support, which is fast and helpful.
However their marketing is great, no doubt.
« Last Edit: October 05, 2011, 12:25:41 PM by Theo Gottwald »

Offline Patrice Terrier

  • ROMs
  • Hero Member
  • *****
  • Posts: 934
  • User-Rate: +62/-1
    • www.zapsolution.com
Re: Purebasic x64 - A beginners guide for Powerbasic Users.
« Reply #13 on: October 05, 2011, 01:44:12 PM »
Theo

WinDev is able to produce both 32-bit and 64-bit, however the problem occures when you use third party DLL(s) that are not 64-bit, then you have to write them with VS.

There are many video to learn how to use WinDev.
Creating an interface with WinDev is a piece of cake once you know how to do it (note: i could explain here in case you realy want to know). The strength of WinDev becomes obvious when you have to manage very large projects that could involve a pool of programmers, but it is also well suited to produce single developer application.

You can't compare PC-Soft with small workshops like those you are accustomed to. With WD17 they will release a brand new native unicode version, with everything converted to Mandarin for Chinese programmers, these peoples have a clear vision of the future and they aknowledge the new leadership of asian countries...

...
 
« Last Edit: October 05, 2011, 01:46:52 PM by Patrice Terrier »
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 936
  • User-Rate: +30/-4
    • it-berater
Re: Purebasic x64 - A beginners guide for Powerbasic Users.
« Reply #14 on: October 05, 2011, 02:35:31 PM »
Patrice, thanks for that offer.
i have no doubt in that WinDev is on the right track. Once i have it and time to look for it, I'll contact you and take your advice about how to step into it.