September 27, 2020, 10:22:03 am

News:

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


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.
Code Select
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:
Code Select
control w,"B,Exit,(800-70)/2,490,70,30,0,1"
instead of:
Code Select
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:
Code Select

sub back
..
return

not as:
Code Select

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:
Code Select
i = i + 3, not as
Code Select
i += 3

Incrementing by one is simple Basic
Code Select
i = i + 1, not the obscure
Code Select
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:
Code Select

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
forum for hobby programming:<br />https://aurelsoft.ucoz.com

GWS

Tomorrow may be too late ..