April 30, 2024, 11:59:28 AM

News:

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


A Fanfare for Creative Basic

Started by GWS, January 19, 2011, 10:15:03 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GWS

Hi folks,

It's been a while since I sang the praises of this little language, that's capable of so much ..  :)

Basic in my view, is the most readable, user-friendly language around.  It's general purpose and can tackle pretty well any applications you can think up.

The Creative Basic implementation takes all of 5 Mbytes of hard disk space  :o, and generates reasonably small executable files.

There's a comprehensive set of instructions for maths, 2D and 3D graphics.  It has a great debugging facility that allows you to stop and examine the contents of all your variable and array contents, single stepping if you wish.

The Help system is concise and well tried - with numerous code examples to demonstrate how instructions are used.

Many example programs can be downloaded from this site, demonstrating how easy it is to develop applications in this language.

The program has been thoroughly tested over many years, and is very reliable.

Here's a small demonstration program (For those who don't have CB loaded, an .exe file is attached) :


def win:window

def textW,textH,meanx,meany,sdev,c:int
def blend,hide,restore:int
def x,y,run:int
def pstep,pi,ret:float
def a$:string

autodefine "off"

declare "user32.dll",AnimateWindow(hwnd:int, dwTime:int, dwFlags:int),int

const blend = 0x80000 :' Blend flag
const hide  = 0x10000 :' Hide flag
const restore = 0x20000 :' Restore flag

window win,-800,0,800,600,@sysmenu,0,"CBasic Window",winh
setwindowcolor win,rgb(0,0,110)

control win,"B,Exit,(800-70)/2,480,70,30,@ctlbtnflat,1"
setfont win, "MS Sans Serif",12,600,0,1
setcontrolcolor win,1,rgb(100,200,250),rgb(10,10,100)

' draw a gradient fill in main window ..
pstep = 600.0 / 256 + 1
for band = 0 To 255
rect win, 0, int(band * pstep), 800, int((band+1) * pstep), rgb(0,0,band), rgb(0,0,band)
next band

pi = 4 * atan(1)

centerwindow win

' create some coloured spots ...
for i = 1 to 20
meanx = rnd(500)+150
meany = rnd(300)+100
sdev = 20
' c = rgb(rnd(250)+50,rnd(250)+50,rnd(250)+50)
c = rgb(rnd(255),rnd(255),rnd(255))
for j = 1 to 400
x = splot() * sdev + meanx
y = splot() * sdev + meany
pset win, x, y , c
next j
next i

' set intro text ..
a$ = "The Amazing Creative Basic"
frontpen win, RGB(60,60,255)
drawmode win,@transparent
setfont win, "Arial",30,700, @sfitalic
gettextsize win, a$, textW, textH
move win,(800-textW)/2,100
print win,a$

run = 1

waituntil run = 0
AnimateWindow(win,2000,blend|hide)
closewindow win

END

sub winh
select @class
case @idclosewindow
run = 0
case @idcontrol
if @controlid = 1 then run = 0
case @idcreate
setwindowcolor win,rgb(0,0,100)
centerwindow win
AnimateWindow(win,1500,blend|restore)
endselect
return

sub splot()
def x1,x2:float
' routine to give a random value from the normal distribution ..
x1 = rnd(1)
x2 = rnd(1)
' catch very small values of x1 ..
if (x1 < 1.E-5) then x1 = 1.E-5
' the Normal curve value ..
ret = sqrt(-2.0*log(x1)) * cos(2*pi*x2)

return ret


Give it a try .. I'm sure you'll like it ..

Best wishes, :)

Graham



Tomorrow may be too late ..

Brian

Graham,

How do I reproduce this line in EB? Specifically the E's?

if (x1 < 1.E - 5) then x1 = 1.E - 5

Brian

LarryMc

From the IWB\EB help file (even though this is CB)
QuoteA = 1.2e-10: REM Set a to equal 0.00000000012
So, my guess would be
if (x1 < 1.0e-5) then x1 = 1.0e-5

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

Brian

Larry,

I did have a look at the variables, etc, help, but couldn't find anything about 'E'. Seems like
it's a case of a lowercase 'e' rather than an uppercase 'E' !

Brian

GWS

Hi Brian,

I haven't got IWB loaded at the moment, so I can't check it out.

I'll load it up and have a look ..  :)

best wishes,

Graham


Tomorrow may be too late ..

LarryMc

Quote from: GWS on January 20, 2011, 03:53:48 AM
I haven't got IWB loaded at the moment, so I can't check it out.
I'll load it up and have a look ..  :)
????
Quote from: LarryMcFrom the IWB\EB help file (even though this is CB)
A = 1.2e-10: REM Set a to equal 0.00000000012

@Brian - you do realize you asked about EB?  ;)

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

January 20, 2011, 06:11:07 AM #6 Last Edit: January 21, 2011, 08:18:18 PM by GWS
Hi Brian,

I've loaded EB and this works ..


openconsole
cls

def x1:double
setprecision 15

x1 = 1.0E-6

if (x1 < 1.0E-5) then x1 = 1.0E-5

print x1

do:until inkey$<>""
closeconsole
end


.. but don't try 1.E-5 or 1.0E - 5  'cos they aren't accepted.  The case of the exponent E doesn't seem to matter.

(Larry > I should think IWB would be the same .. isn't it ?)

Creative Basic is a lot more flexible and will accept either.

all the best, :)

Graham

Tomorrow may be too late ..

Brian

Graham,
Thanks for that - I'll give it a whirl tonight

Larry,
Wasn't a question particularly about EB. I saw Graham's program, downloaded the source and exe,
and wondered how large the exe would be in EB compared to CB (a lot smaller but, of course, that
was always going to be the case, given the programs' differences)

Brian


LarryMc

@Graham
you're example works with IWBasic 2.0 (which is what I;m using and it accepts either e or E.

@Brian
I misunderstood you.  I thought you were asking about IWB/EB because of this:
QuoteHow do I reproduce this line in EB? Specifically the E's?

LarryMc


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