Two weeks and running... I like it!
Two weeks and running... I like it!
First experiences with Pure Basic
=====================
I though that some users of this forum might be interested in my experience as a new boy with Pure Basic. I purchased PB two weeks ago and have learned some of its many features, mainly working in free time in the evenings and at the weekends.
I have experience with various flavours of Basic starting with Commodore’s PET 2001 through the bigger PETs, C64, C128 and the 500 / 600 series. For the Commodore range I wrote an assembler in Basic and then used it to create its replacement all in assembler. I then used the assembler to write language extensions for the ROM based Basic and an English / Arabic word processor in a plug-in cartridge for the C64. (Last heard off being copied in a back street in Cairo!). I also wrote an auto-formatting editor for the assembler and similar utilities for the Basic. I can still program 6502 / 6509 assembler in my sleep!
Before trying Pure Basic on the PC I had used 16-bit GFA Basic for about eight years, Visual Basic for about two weeks (two too long!) and had a few months with Power Basic. The software I write nowadays is mainly to control lab equipment and configuration utilities for setting up and testing radio telemetry systems.
Why did I try Pure Basic? First, the 16 bit GFA system that has worked very well for me is showing its age. The most recent application I wrote with this language is 17,383 lines of code and grew over the last two years. I still add to it when new features are needed and I expect to support it for a year or two more. I now need my software to have the look and feel of more modern applications and this has become progressively more difficult with GFA. Also, although working with segmented memory is easy, it is so untidy; a proper 32-bit memory space is much easier to use when working with big file images.
I liked the style of Power Basic except for the editor; and that Power Basic pushes the user into using the API much too soon. I need a simple graphics capability, to draw graphs and to show sequences of pictures for use in test and maintenance jobs. I see nothing wrong with expecting a modern Basic to provide features to create an image, write text on it, and draw lines, shapes etc and then show the image on the screen. Power Basic could not do this natively. I expect access to the API when I need it; but not to perform simple tasks.
I like Pure Basic’s try-before-you-buy method of marketing. I tried, I liked and I bought; in just a few days.
Having programmed computers for many years I hold the view that the editor is the most underrated item. In think the standard editors provided to support Pure and Power Basics are letting their products down. It is interesting that both products have superior editors produced by enthusiastic users of the language. Taking the best features from Power Basic’s SED and Pure Basic’s jaPBe would result in a truly first class item. At present jaPBe is in front because it has automatic un-indent and effective auto-completion of Basic keywords, procedures, API calls and variable names. These features make writing source files less error prone. In my opinion GFA still has the best indent management; it can always be relied upon to correctly show nested structures, I hope that jaPBe will reach a similar level of refinement.
Pure Basic has some unconventional language features, I’m not saying they are right or wrong but, for example, what is wrong with INSTRING ? (With minor word variations.) Why be different for no apparent reason? INC x and DEC x are fairly standard, X+1 isn’t. I’m trying not to be critical of features that are just different, everyone senses a degree of annoyance when they first come across variation of what they consider normal! However, standards are a good thing.
As a learning project I set myself the task of reading a 60MB binary file from a telemetry receiver Multi Media Card, copying the card to disk, reading the file, analysing the content and displaying the result in graphical form with a “magnifying glassâ€
=====================
I though that some users of this forum might be interested in my experience as a new boy with Pure Basic. I purchased PB two weeks ago and have learned some of its many features, mainly working in free time in the evenings and at the weekends.
I have experience with various flavours of Basic starting with Commodore’s PET 2001 through the bigger PETs, C64, C128 and the 500 / 600 series. For the Commodore range I wrote an assembler in Basic and then used it to create its replacement all in assembler. I then used the assembler to write language extensions for the ROM based Basic and an English / Arabic word processor in a plug-in cartridge for the C64. (Last heard off being copied in a back street in Cairo!). I also wrote an auto-formatting editor for the assembler and similar utilities for the Basic. I can still program 6502 / 6509 assembler in my sleep!
Before trying Pure Basic on the PC I had used 16-bit GFA Basic for about eight years, Visual Basic for about two weeks (two too long!) and had a few months with Power Basic. The software I write nowadays is mainly to control lab equipment and configuration utilities for setting up and testing radio telemetry systems.
Why did I try Pure Basic? First, the 16 bit GFA system that has worked very well for me is showing its age. The most recent application I wrote with this language is 17,383 lines of code and grew over the last two years. I still add to it when new features are needed and I expect to support it for a year or two more. I now need my software to have the look and feel of more modern applications and this has become progressively more difficult with GFA. Also, although working with segmented memory is easy, it is so untidy; a proper 32-bit memory space is much easier to use when working with big file images.
I liked the style of Power Basic except for the editor; and that Power Basic pushes the user into using the API much too soon. I need a simple graphics capability, to draw graphs and to show sequences of pictures for use in test and maintenance jobs. I see nothing wrong with expecting a modern Basic to provide features to create an image, write text on it, and draw lines, shapes etc and then show the image on the screen. Power Basic could not do this natively. I expect access to the API when I need it; but not to perform simple tasks.
I like Pure Basic’s try-before-you-buy method of marketing. I tried, I liked and I bought; in just a few days.
Having programmed computers for many years I hold the view that the editor is the most underrated item. In think the standard editors provided to support Pure and Power Basics are letting their products down. It is interesting that both products have superior editors produced by enthusiastic users of the language. Taking the best features from Power Basic’s SED and Pure Basic’s jaPBe would result in a truly first class item. At present jaPBe is in front because it has automatic un-indent and effective auto-completion of Basic keywords, procedures, API calls and variable names. These features make writing source files less error prone. In my opinion GFA still has the best indent management; it can always be relied upon to correctly show nested structures, I hope that jaPBe will reach a similar level of refinement.
Pure Basic has some unconventional language features, I’m not saying they are right or wrong but, for example, what is wrong with INSTRING ? (With minor word variations.) Why be different for no apparent reason? INC x and DEC x are fairly standard, X+1 isn’t. I’m trying not to be critical of features that are just different, everyone senses a degree of annoyance when they first come across variation of what they consider normal! However, standards are a good thing.
As a learning project I set myself the task of reading a 60MB binary file from a telemetry receiver Multi Media Card, copying the card to disk, reading the file, analysing the content and displaying the result in graphical form with a “magnifying glassâ€
While I use the standard editor for small quick projects, I mostly use Edwin Knoppert's PBDev program for PureBasic. Try it at: http://www.hellobasic.com/pbdev.htm
It's an editor and a program generator combined and handles events as well. Great for a new Windows programmer... You can press the F8 key and open the Pure editor to see the code it generates, etc. etc. and it's very cheap at 39.00
My 2 cents
--blueb
It's an editor and a program generator combined and handles events as well. Great for a new Windows programmer... You can press the F8 key and open the Pure editor to see the code it generates, etc. etc. and it's very cheap at 39.00
My 2 cents
--blueb
-
Randy Walker
- Addict

- Posts: 1129
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
Welcome to PB Richard... I'm also a former GFA Basic user and new to PureBasic. You'll find several others here too. Speaking of helpful. This is a very helpful forum. This was my fisrt post on the board here:
viewtopic.php?t=11859
Read though that and you'll find lots of answers to your questions about PB command background, and usefull references from other former GFA users. Like yourself, I am very pleased and somewhat stumpted trying to convert. I find most of the commands I used from GFA are quite different here so I spend a lot of time trying to hunt down eqivelent commands. Some equivelents simply don't exist but the many new commands more than make up for the loss I think. Just getting that 32 bit access is a major benefit.
I recently began porting a 11334 line project from GFA into PB format and that has been going rather well. If you didn't get it yet, get the JaBPe editor. It will allow you to collapse procedures as we did in GFA, along with many other cool features. Good luck and have fun!
viewtopic.php?t=11859
Read though that and you'll find lots of answers to your questions about PB command background, and usefull references from other former GFA users. Like yourself, I am very pleased and somewhat stumpted trying to convert. I find most of the commands I used from GFA are quite different here so I spend a lot of time trying to hunt down eqivelent commands. Some equivelents simply don't exist but the many new commands more than make up for the loss I think. Just getting that 32 bit access is a major benefit.
I recently began porting a 11334 line project from GFA into PB format and that has been going rather well. If you didn't get it yet, get the JaBPe editor. It will allow you to collapse procedures as we did in GFA, along with many other cool features. Good luck and have fun!
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy
I *never* claimed to be a programmer.
welcome to purebasic!
if any of you gfa converts would like to make additional suggestions for the survival guide gfa page, feel free to tell me
http://www.xs4all.nl/~bluez/datatalk/pure2.htm#top
just like you guys i ran into the same 'conversion' troubles, i had quite some troubles understanding api calls, and that i did not have to force variable types
now we do need that alternative select ... case ... endselect syntax...
if any of you gfa converts would like to make additional suggestions for the survival guide gfa page, feel free to tell me
http://www.xs4all.nl/~bluez/datatalk/pure2.htm#top
just like you guys i ran into the same 'conversion' troubles, i had quite some troubles understanding api calls, and that i did not have to force variable types
now we do need that alternative select ... case ... endselect syntax...
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
-
dontmailme
- Enthusiast

- Posts: 537
- Joined: Wed Oct 29, 2003 10:35 am
Hi Richard,
Your experiences seem very similar to mine.... I always get a 'Lost old friend' feeling whenever the PET is mentioned
Although unlike you, I have forgot 6502 ( must be getting old
)
Good luck with your programming
Your experiences seem very similar to mine.... I always get a 'Lost old friend' feeling whenever the PET is mentioned
I did exactly the same, although I sent the money after a few hours!.... after looking through the examples and compiling them I realised that the language was very capable and with the addition of the API to play with, anything was possible.....I like Pure Basic’s try-before-you-buy method of marketing. I tried, I liked and I bought; in just a few days.
Good luck with your programming
Paid up PB User !
Still running... still liking it. In fact I'm copying all my Pure Basic stuff on to my laptop to take on holiday for the next few weeks. (Sad, what!).
Miscellaneous comments
================
A problem I face is that I will be supporting several GFA programs we use for lab work for some years to come; so I expect I will be writing lots of procedures in Pure Basic to mimic GFA functions.
I have already done EXIST(filename) because I like to check the existance of a file before accessing it and would rather the user did not get system messages relating to missing drives, media etc.
I Wrote BMOVE(Source, destination, #bytes) and use this to assemble string fragments into a blank string... this gets round the lack of Mid$(....) = MyString$
The 2D graphics are excellent and I got a graphing program almost finished before I used any API calls at all... better than GFA.
I do not like PeekB(Address) returning a signed value. I wrote my own function Peek(Address) to return an unsigned value.
My enduring dislike is the poor options provided by CASE. I'm not alone in this and maybe something will get done... it is a true weakness.
I'm getting on top of the RS232 functions I need for equipment control.
I have got at the parallel port under GFA running WindozeXP using a utility called PortTalk; I see no reason for PB not also working the same way. Then I want to do it all myself and not rely on 3rd party addon-ons.
jaPBe is excellent... GFA was better at sorting out indenting... jaPBe is clever at keeping its functionality secret due to lack of an English manual! Highlighting a block and Cntrl+TAB tidies up the indenting.
I've taken some time out to produce some HTML help files and OpenHelp() to access them from within my software. I used Helpmatic to create/edit the files, its OK and like PureBasic I can try before I buy.
Anyway, off to pack my bags, load up the laptop and get into a holiday frame of mind.
Miscellaneous comments
================
A problem I face is that I will be supporting several GFA programs we use for lab work for some years to come; so I expect I will be writing lots of procedures in Pure Basic to mimic GFA functions.
I have already done EXIST(filename) because I like to check the existance of a file before accessing it and would rather the user did not get system messages relating to missing drives, media etc.
I Wrote BMOVE(Source, destination, #bytes) and use this to assemble string fragments into a blank string... this gets round the lack of Mid$(....) = MyString$
The 2D graphics are excellent and I got a graphing program almost finished before I used any API calls at all... better than GFA.
I do not like PeekB(Address) returning a signed value. I wrote my own function Peek(Address) to return an unsigned value.
My enduring dislike is the poor options provided by CASE. I'm not alone in this and maybe something will get done... it is a true weakness.
I'm getting on top of the RS232 functions I need for equipment control.
I have got at the parallel port under GFA running WindozeXP using a utility called PortTalk; I see no reason for PB not also working the same way. Then I want to do it all myself and not rely on 3rd party addon-ons.
jaPBe is excellent... GFA was better at sorting out indenting... jaPBe is clever at keeping its functionality secret due to lack of an English manual! Highlighting a block and Cntrl+TAB tidies up the indenting.
I've taken some time out to produce some HTML help files and OpenHelp() to access them from within my software. I used Helpmatic to create/edit the files, its OK and like PureBasic I can try before I buy.
Anyway, off to pack my bags, load up the laptop and get into a holiday frame of mind.
-
dontmailme
- Enthusiast

- Posts: 537
- Joined: Wed Oct 29, 2003 10:35 am
LOL, although not as sad as the guy who joined my company a few years ago.....Still running... still liking it. In fact I'm copying all my Pure Basic stuff on to my laptop to take on holiday for the next few weeks. (Sad, what!).
He had a two-week holiday booked with his wife and so joined the company when he got back...... I found out after he joined that his holiday was spent reading manuals so he could make a good impression when he started work!
Paid up PB User !
-
Randy Walker
- Addict

- Posts: 1129
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
What do you mean? Are you talking about Switch (which I never used) or are you talking about multiple values on a single case line. Not being able to use multiple values makes coding a little clumbsy. I also miss not being able to 'Cont' to next case operation.blueznl wrote:now we do need that alternative select ... case ... endselect syntax...
Last edited by Randy Walker on Wed Oct 13, 2004 4:20 am, edited 2 times in total.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy
I *never* claimed to be a programmer.
-
Randy Walker
- Addict

- Posts: 1129
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
Just put "If" in front of all your open file commands and the command will tell you if the operation failed. If you want an alternative to GFA "Exist()" then use FileSize() - more powerfull than Exist() !!!! Simpler to preface the OpenFile (creatfile etc) with IF OpenFile ... else... endif.RichardL wrote: I have already done EXIST(filename) because I like to check the existance of a file before accessing it and would rather the user did not get system messages relating to missing drives, media etc.
Try CopyMemoryI Wrote BMOVE(Source, destination, #bytes) and use this to assemble string fragments into a blank string... this gets round the lack of Mid$(....) = MyString$
Just AND your results using the return (value & 255)I do not like PeekB(Address) returning a signed value. I wrote my own function Peek(Address) to return an unsigned value.
Yes, would be nice to have 'Cont' and multiple values per case line.My enduring dislike is the poor options provided by CASE. I'm not alone in this and maybe something will get done... it is a true weakness.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy
I *never* claimed to be a programmer.
-
Randy Walker
- Addict

- Posts: 1129
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
Your site has been very helpful and I didn't want to say anything because this was your free contribution, but YES. I'm really annoyed that you left so much outblueznl wrote:if any of you gfa converts would like to make additional suggestions for the survival guide gfa page, feel free to tell me
Rather than one suggestion at a time, I was thinking I would get up a collection of notes to submit to you after a few months of adapting. Then maybe I will understand enough to offer something suitably comprehensive (like you did).
Thanks again for all your great help though!!
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy
I *never* claimed to be a programmer.
Hi Randy...
Just a quick comment on your posting regarding EXIST(Path/Filename). I tried various file related operations (Open, FileSize etc) to determine if a file exists or not. In my case I needed to look for the existance of the drives/media first, then check for a specific file. This came about because memory card adaptors can map a card at their choice of location...
Anyway, guided by comments in this forum I located a the drive string which told me which drives were installed and the set about looking for the file using Open, FileSize etc... but could not get around system messages appearing; which I very specifically wanted to avaoid, my end users are NOT computer literate and delight in phoning from strange parts of the planet asking what unexpected Windoze messages mean and can they have another day off due to computer induced stress
The method I ended up with shows no system messages even if the drive is absent or the media is missing from the drive.
I am not sure this is a 'proper system legal' solution and I am happy to be corrected by those who are more expert; but it has the distinct plus point of working:
Yes, I know I type every variable instance... a GFA habit that is proving hard to forget; particularly as I'm using vboth BASICS.
Just a quick comment on your posting regarding EXIST(Path/Filename). I tried various file related operations (Open, FileSize etc) to determine if a file exists or not. In my case I needed to look for the existance of the drives/media first, then check for a specific file. This came about because memory card adaptors can map a card at their choice of location...
Anyway, guided by comments in this forum I located a the drive string which told me which drives were installed and the set about looking for the file using Open, FileSize etc... but could not get around system messages appearing; which I very specifically wanted to avaoid, my end users are NOT computer literate and delight in phoning from strange parts of the planet asking what unexpected Windoze messages mean and can they have another day off due to computer induced stress
The method I ended up with shows no system messages even if the drive is absent or the media is missing from the drive.
I am not sure this is a 'proper system legal' solution and I am happy to be corrected by those who are more expert; but it has the distinct plus point of working:
Code: Select all
Procedure.l Exist(File$) ;- Check a drive + file exists, without system requesters etc.
; Check if a drive + file exists
; Return -1 if exists, else 0
Protected EFlag.l, OldErrorMode.l, Junk.l
OldErrorMode = SetErrorMode_(1) ; Turn off screen error messages
If GetFileAttributes_(@File$)=-1 ; Get file butes. -1 = fail
Junk.l=GetLastError_() ; Get last error, to flush system
SetLastError_(0) ; Set error to zero
EFlag.l = 0 ; Return value to flag FAIL
Else
EFlag.l = -1 ; Return value to flag a PASS
EndIf
SetErrorMode_(OldErrorMode) ; Reset the error flags
ProcedureReturn EFlag
EndProcedure
postfixes... that takes a while before one looses the habit 
interesting way around for drive file existence, currently looking into the consequences, i may use this approach in the future
interesting way around for drive file existence, currently looking into the consequences, i may use this approach in the future
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
-
Randy Walker
- Addict

- Posts: 1129
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
RichardL... here's a simple example that illustrates the use of FileSize. If it returns a -1 then the file or directory does not exist, else it returns a -2 for directory, or the actual file size. If you want to know if a file exists, the return must be greater than -1
Reliable and also better to avoid API stuff whenever possible... just in case you go cross platform down the road - less to convert.
Code: Select all
; FileSize() uses the full path for the object of interest.
; Run using F6 Debugger option to see output.
; Directory returns a negative 2.
If FileSize("c:\windows\") = -2
Debug "C:\WINDOWS directory is Present"
EndIf
Debug ""
; Good file with zero bytes or larger returns actual file length.
If FileSize("c:\windows\notepad.exe") >= 0
Debug "NotePad.exe file is Present"
Debug "Size is " + Str( FileSize("c:\windows\notepad.exe") )
EndIf
Debug ""
Debug ""
; No file or directory ALWAYS returns negative 1.
If FileSize("c:\jibberish\") = -1
Debug "C:\JIBBERISH directory is Absent"
EndIf
If FileSize("c:\windows\DoDoCoughCough.xyz") = -1
Debug "DoDoCoughCough.xyz file is Absent"
EndIf
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy
I *never* claimed to be a programmer.

