March 28, 2024, 03:21:57 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Why Use Creative Basic ..

Started by GWS, June 01, 2015, 10:51:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GWS

June 01, 2015, 10:51:00 PM Last Edit: June 02, 2015, 01:58:11 AM by GWS
Hi folks,

In another thread, http://www.ionicwind.com/forums/index.php?topic=5598.msg41896#msg41896
the discussion raised the question of why CBasic might be a good choice for program development.

So I guess as a long time fan of Creative, I should add my view of this little jewel of a language. :)

Simplicity ..  ;D

There is only one file type needed - .cba for source code. Although at a suitable time, you can create an .exe file for distribution.  There are no .obj, .asm, .opts files.

If you want a Window, you use a Window command - not OpenWindow.
window w,0,0,800,600,wstyle,0,"Creative Basic",messages
Notice there is no obscure & required in front of the message handler routine name.

To set up a Button Control, the syntax in CBasic is:
control w,"B,Exit,(800-70)/2,490,70,30,0,1"
instead of:
CONTROL w,@BUTTON,"Exit",350,470,bW,bH,0,1

The argument list is a String - and can be processed using any string functions - such as when you want to place the command in a loop generating lots of similar controls using just one statement.

There are no superfluous ENDSUB statements in CBasic subroutines. The termination is just a RETURN statement, not requiring an obscure '0' argument (unless you actually are returning a value).

If a subroutine has no argument list, it is simply written as for example:

sub back
..
return

not as:

sub back(),int
..
return 0
endsub


In CBasic, there are no erudite 'compund' operators.  If you want to increment a variable by say 3, you write:
i = i + 3, not as i += 3

Incrementing by one is simple Basic i = i + 1, not the obscure i++

If you need to use a Maths function in CBasic such as SIN, just use it with a radian argument.

You do not need to worry whether you should be using FSIN for floating point, FSIND for double precision, SIN, or SIND.

CBasic's clever feature is that all arithmetic is carried out behind the scenes using double precision , and converted to the receiving value's data type when done.  Simple is always best. ;)

Then consider finding logic problems as you develop a program.  CBasic has a great debug facility.

Paste this little test program into the CBasic editor window:

openconsole
cls

def pi,2pi,y:double

pi = 4 * atan(1)

2pi = 2 * pi

stop

y = 2pi / 4

do:until inkey$<>""
closeconsole
end



If you run it, it will stop at the STOP statement.

Now click on the Build - Show Variables menu item.  This will bring up the Variable List window, showing all the variables and their current contents.  You will see that the variable 'y' is still set at 0.
That's because the program hasn't got there yet.

With the focus in the code window, press F5 - this advances one line in the program, and then you see immediately as 'y' is set.

If arrays are involved, all elements of an array can be inspected.

This debug facility is most useful when fathoming out where a program may be going wrong.

The CBasic user guide is always there to explain how all the features are used.

So is it always better to use CBasic rather than EBasic ?  Of course not.

EBasic and IWBasic have had years of further development and extra features added.  If you need to use those features, then the choice is obvious.

But for ease of use and simplicity, CBasic is my usual choice. :)

Best wishes, :)

Graham  

Tomorrow may be too late ..

Andy

Thanks Graham,

I can see why you like CB, and thanks a the detailed explanation.

Think you can come across a programming language and it sits well with you and that's the one you prefer.

Andy.
:)



Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Egil

Thanks Graham,

I knew you could explain this much better than me...  ;D ;D


Egil
Support Amateur Radio  -  Have a ham  for dinner!

aurelCB

my explanation is far simplier
i like CB  ;D

GWS

Tomorrow may be too late ..