April 24, 2024, 03:34:05 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Anatomy of Creative Basic

Started by GWS, March 19, 2013, 03:34:36 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GWS

Hi folks,

It's just an interpreter - a sort of inferior being to a compiler right ? :P

There's a bit more to it than that.
Here are a few comments passed to me by Paul some time ago ..

_____________________________

Creative Basic is a C++ class.

That class has a method function that runs tokenised code.

Actually, it comprises two C++ classes .. the other one being the Editor class.

The editor class calls:

cbasic->Setbuffer
cbasic->Initialise
cbasic->Run

The editor also contains the code that creates the tokenised buffer.
Literally, it is the compiler - there isn't a Creative Basic without the IDE.

When you create an executable, the IDE takes the tokenised buffer and stores it in resources in one of three executables that contain the Creative Basic C++ class.

If you look in the install directory for CB, you will see the three executables, renamed with a .obj extension.

CB.obj
CBNODX.obj
CBCLI.obj

You can rename them as .exe, such as the CBCLI one, and double click it.  It will briefly flash the console and exit, since it can't find the resource containing the tokenised source code.

So when a Creative executable runs, it is the same sequence, except the tokenised source code is stored in resources.

cbasic->Setbuffer(LoadResource( ...
cbasic->Initialise
cbasic->Run

All Creative Basic commands are member functions of the CB class.  All are written in MSVC 5.0.

So in essence, the machine code compiler for execution is C++.

Creative Basic doesn't really have true subroutines ..  :o
Which is why they don't have addresses, and can't be used as callbacks.
It has pseudo subroutines.

When the interpreter comes across a GOSUB, or an implied GOSUB in the form MyFunc() that has been declared, it does the following ..

- If the GOSUB is from global code, it creates a linked list and stores all global variables in the list.
  If it's from another sub, it creates a linked list on a stack and stores the calling sub's variables.
  The stack is limited, which is why you can get a "stack overflow" error. [I've never had one of those  ::)]

- Sets an internal integer variable called PC (Program counter) to the line of the subroutine after the SUB   
  statement.

When it sees a RETURN statement, it sets the PC variable to the line following the GOSUB, and resets the linked list.

So there isn't really a subroutine, it's just more lines of code to interpret as far as CB is concerned.

As far as graphics is concerned .. Creative uses DirectX 7 retained mode for 3D.

Microsoft made it near impossible to link to their Direct3D import libraries from any language except theirs.

_____________________________


Of course, you don't need to know any of the above to just use and enjoy Creative Basic ..   ;D

all the best, :)

Graham





Tomorrow may be too late ..

aurelCB

Very well explanation Graham and i can agree with you in most of things.
But for me is a main question - how many people still use Creative Basic?
And if not --- why not?

GWS

Hi Aurel ..  :)

Good question - but I don't know the answer ..  ::)

I can guess .. that people might consider it a 'dead' language .. and of course who would want to use a 'dead' language ?  :(

I suppose the same could be said for DarkBasic and Blitz Basic.

Well I would.  It's an effective tool that has worked reliably for all sorts of applications for over 10 years.
It's still a pleasure to use, so why would I want to throw it away?  And use what? - maybe the free Microsoft Visual Studio Express, which is huge, and barely resembles standard Basic ?

I have a string-line for use in the garden, comprising two spade handles sharpened at the ends, with the original string wrapped around them, that belonged to my wife's Dad - must be nearly 100 years old now  :o

It still marks out a good straight line and I still use it.

No doubt I could buy some new-fangled laser device - but why should I ?
The string and spade handles work fine.  And I feel comfortable with old things. :)

best wishes, :)

Graham
Tomorrow may be too late ..

LarryMc

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

GWS

 ;D

Glad you're back from your trip safely  :)

Graham
Tomorrow may be too late ..

aurelCB

QuoteGood question - but I don't know the answer

Yes i understand that...
But i cannot understand where all this people gone...
almost any forum around looks dead... ::)

GWS

Dunno .. maybe all watching sports and soaps on TV  ::) ..

Perhaps they'll get back to doing something 'er Creative eventually ..  ;D

Graham
Tomorrow may be too late ..

LarryMc

Quote from: GWS on March 20, 2013, 01:04:21 PM
;D

Glad you're back from your trip safely  :)

Graham
Thanks,
I'm still sore all over. The worse is like a hip-pointer in my left hip joint.
Every step is agony.
I would whine about getting old but you would just say "tough it up, KID" ;D
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

GWS

Naw ! .. If we were nearer, I'd suggest going for a meal and drinks, where we could compare life's battle wounds.  ::)

At least we can still do a bit of this and that, to get a bit of pleasure out of life  ;D

all the best, :)

Graham
Tomorrow may be too late ..

tbohon

Quote from: aurelCB on March 20, 2013, 01:14:37 PM
QuoteGood question - but I don't know the answer

Yes i understand that...
But i cannot understand where all this people gone...
almost any forum around looks dead... ::)

Aurel I still use Creative Basic but am so busy at work with Visual Studio "stuff" and moving data files around our network via ftp and helping less experienced programmers do their jobs that time for 'fun' programming is pretty limited right now.  Add to that the fact that I am in charge of our local (county) Amateur Radio Emergency Service team and volunteer for two different animal rescue organizations and it's probably a good thing I'm single ... if I wasn't I suspect I would be fairly quickly.

Anyway in terms of CB I'm working on a small database program to help gather information from people interested in ham radio and/or in the ARES team.  I'm also still trying to sort out how to write a colorizing editor for my ftp library/engine at work ... CB is my tool of choice for that although my manager thinks the only 'real' code is written in C#.  While I like C# well enough, CB is a lot more fun and produces much smaller executables than VS2010.
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)

GWS

That's very interesting Tom ..  :)

You're another radio amateur - and using CB .. great  ;D

Your manager sounds like most experts I've heard - C's the thing .. :P

You'll probably know more than me that it's graphics capabilities are a wee bit primitive.
Here's a quote:
QuoteDeveloping C# applications harnessing the full range of graphics capabilities found in today’s PCs can be challenging.
Microsoft provides the GDI+ facility with its Visual C# product but learning to use it is anything but trivial.

Here's a few notes I found about getting even simple lines, circles and rectangles out of C# ..

http://twig.lssu.edu/courses/spring09/csci105/ch8.pdf

.. not something I'd fancy doing - I like things to be a bit more straightforward than that. :)

I've got a mostly silent TS830S here ..  (see pic)  ::) .. an easy 100watts from a couple of lovely 6146B's ..  :P

I can't say I'm keen on the amount of 'contest' noise on the bands - I prefer a chat myself.

I'm also amusing myself with some rather rare drums I found  ::) - take a listen to those ..

http://www.youtube.com/watch?v=JBokfCjFxXI

Phew .. nice eh?  ;D

Have fun with Creative Basic ..

best wishes, :)

Graham








Tomorrow may be too late ..