Author |
Topic: Object Oriented Liberty BASIC? (Read 3294 times) |
|
Sean
New Member
member is offline


Posts: 6
|
 |
Re: Object Oriented Liberty BASIC?
« Reply #5 on: Jun 23rd, 2014, 10:39am » |
|
I would love to have OOPS, but we (the lb'ers) were kept waiting and are still waiting I think we have moved on. Does BBC basic support OOPS? I have moved on to AutoIt and Lazarus myself.
|
| « Last Edit: Jun 23rd, 2014, 10:40am by Sean » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Object Oriented Liberty BASIC?
« Reply #6 on: Jun 24th, 2014, 1:38pm » |
|
on Jun 23rd, 2014, 10:39am, Sean wrote:I would love to have OOPS, but we (the lb'ers) were kept waiting and are still waiting I think we have moved on. Does BBC basic support OOPS? I have moved on to AutoIt and Lazarus myself. |
|
I see. If you feel like that, why did you join this forum?
Richard.
|
|
Logged
|
|
|
|
Sean
New Member
member is offline


Posts: 6
|
 |
Re: Object Oriented Liberty BASIC?
« Reply #7 on: Jun 24th, 2014, 2:34pm » |
|
To praise your work. LBB definitely is going into my toolkit.
|
|
Logged
|
|
|
|
bluatigro
Full Member
member is offline


Gender: 
Posts: 111
|
 |
Re: Object Oriented Liberty BASIC?
« Reply #8 on: Jan 20th, 2015, 09:06am » |
|
i wood like it when objects can be stored sepredly in a *.bas
and can be added whit a 'import' or 'include' comand
and i like to have operator overloading
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Object Oriented Liberty BASIC?
« Reply #9 on: Jan 20th, 2015, 09:17am » |
|
on Jan 20th, 2015, 09:06am, bluatigro wrote:| and can be added whit a 'import' or 'include' command |
|
LBB has an 'include command. It works in a similar fashion to LB Workshop's include command, except that in LBW the included code is appended to the program, whereas in LBB it is inserted where the include statement is:
http://www.lbbooster.com/lbb.html#directives
The command is only recognised if it starts in the first column; preceding whitespace is not accepted. Also, for compatibility with LBW, 'include is ignored if it is at the very start of the program:
Code:'ensure include is not the first line
'include mylib.bas Edit: Quote:| and i like to have operator overloading |
|
Isn't 'operator overloading' useful only if the language has user-defined data types? Liberty BASIC doesn't (it has just numbers and strings).
Effectively there is already operator overloading to the extent that the + operator means different things for numbers and strings. Also, in LBB, some operators work on complete arrays:
Code: Richard.
|
|
|
|
bluatigro
Full Member
member is offline


Gender: 
Posts: 111
|
 |
Re: Object Oriented Liberty BASIC?
« Reply #10 on: Jan 20th, 2015, 11:11am » |
|
'include error ? or wat else do i wrong ? _math.bas Code:
''bluatigro 20 jan 2015 :
''_math.bas
global pi , golden.ratio
pi = atn( 1 ) * 4
golden.ratio = ( sqr( 5 ) - 1 ) / 2
global true , false
true = not( false )
end
function rad( deg )
rad = deg * pi / 180
end function
_color.bas Code:
'include _math.bas
''bluatigro 20 jan 2015 :
''_color.bas
global black$ , red$ , green$ , yellow$
global blue$ , magenta$ , cyan$ , white$
global gray$ , pink$ , purple$ , orange$
black$ = rgb$( 000 , 000 , 000 )
red$ = rgb$( 255 , 000 , 000 )
green$ = rgb$( 000 , 255 , 000 )
yellow$ = rgb$( 255 , 255 , 000 )
blue$ = rgb$( 000 , 000 , 255 )
magenta$ = rgb$( 255 , 000 , 255 )
cyan$ = rgb$( 000 , 255 , 255 )
white$ = rgb$( 255 , 255 , 255 )
gray$ = rgb$( 127 , 127 , 127 )
pink$ = rgb$( 255 , 127 , 127 )
purple$ = rgb$( 127 , 000 , 127 )
orange$ = rgb$( 255 , 127 , 000 )
end
function rgb$( r , g , b )
r = r and 255
g = g and 255
b = b and 255
rgb$ = str$( r ); " " ; g * 256 ; " " ; b * 256 ^ 2
end function
function red( clr$ )
red = val( word$( clr$ , 1 ) )
end function
function green( clr )
green = val( word$( clr$ , 2 ) )
end function
function blue( clr$ )
blue = val( word$( clr$ , 3 ) )
end function
function klmix$( kl1$ , f , kl2$ )
r1 = red( kl1$ )
g1 = green( kl1$ )
b1 = blue( kl1$ )
r2 = red( kl2$ )
g2 = green( kl2$ )
b2 = blue( kl2$ )
r = r1 + f * ( r2 - r1 )
g = g1 + f * ( g2 - g1 )
b = b1 + f * ( b2 - b1 )
klmix$ = rgb$( r , g , b )
end function
function rainbow$( deg )
rainbow$ = rgb$( sin( rad( deg ) ) * 127 + 128 _
, sin( rad( deg + 120 ) ) * 127 + 128 _
, sin( rad( deg - 120 ) ) * 127 + 128 )
end function
_sphere.bas Code:
'include _color.bas
''bluatigro 20 jan 1015
''_sphere.bas
WindowWidth = DisplayWitdh
WindowHeight = DisplayHeight
global winx , winy
winx = WindowWidth
winy = WindowHeight
global height
sub sphere h$ , x , y , z , d , clr$
if abs( height - y ) < d then
dd = sqr( d ^ 2 - ( height - y ) ^ 2 + .001 ) * 2
kl$ = mix$( clr$ , .5 - ( height - y ) / d / 2 , black$ )
#h$ "goto " ; x + winx / 2 ;" "; winy / 2 - height - z / 4
#h$ "backcolor " ; kl$
#h$ "color" ; kl$
#h$ "down"
#h$ "ellipsefilled "; dd ;" "; dd / 4
#h$ "up"
end if
end sub
main Code:
'include "_sphere.bas"
nomainwin
open "sphere-test" for graphics as #m
#m "trapclose [quit]"
for height = 0-winy/2 to winy/2
call sphere #m , 0 , 0 , 0 , 50 , red$
next height
wait
[quit]
close #m
end
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Object Oriented Liberty BASIC?
« Reply #11 on: Jan 20th, 2015, 11:24am » |
|
on Jan 20th, 2015, 11:11am, bluatigro wrote: Nothing "wrong" exactly, but you are hoping that 'include can be 'nested', i.e. that one included file can include another file, etc. Unfortunately it doesn't work like that in LBB, you can only use 'include in your 'main program':
Code:nomainwin
open "sphere-test" for graphics as #m
#m "trapclose [quit]"
for height = 0-winy/2 to winy/2
call sphere #m , 0 , 0 , 0 , 50 , red$
next height
wait
[quit]
close #m
end
'include _sphere.bas
'include _math.bas
'include _color.bas As far as I'm aware LB Workshop's include has the same limitation.
Richard
|
|
|
|
bluatigro
Full Member
member is offline


Gender: 
Posts: 111
|
 |
Re: Object Oriented Liberty BASIC?
« Reply #12 on: Jan 20th, 2015, 2:06pm » |
|
i tryed this Code:
nomainwin
open "" for graphics as #m
#m "trapclose [quit]"
#m "fill black"
for height = 0-winy/2 to winy/2
call sphere 0 , 0 , 0 , 50 , red$
next height
wait
[quit]
close #m
end
'include _math.bas
'include _color.bas
'include _sphere.bas
Code:
''bluatigro 20 jan 1015
''_sphere.bas
WindowWidth = DisplayWitdh
WindowHeight = DisplayHeight
global winx , winy
winx = WindowWidth
winy = WindowHeight
global height
sub sphere x , y , z , d , clr$
if abs( height - y ) < d then
dd = sqr( d ^ 2 - ( height - y ) ^ 2 + .001 ) * 2
kl$ = mix$( clr$ , .5 - ( height - y ) / d / 2 , black$ )
#m "goto " ; x + winx / 2 ;" "; winy / 2 - height - z / 4
#m "backcolor " ; kl$
#m "color" ; kl$
#m "down"
#m "ellipsefilled "; dd ;" "; dd / 4
#m "up"
end if
end sub
_math.bas and _color.bas are not changed
error : - where is my red sphere - the window isnt fulscreen
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Object Oriented Liberty BASIC?
« Reply #13 on: Jan 20th, 2015, 4:42pm » |
|
on Jan 20th, 2015, 2:06pm, bluatigro wrote:- where is my red sphere - the window isnt fulscreen |
|
I think your problem is that the code is now in the wrong sequence. Your 'included' file _sphere.bas contains both initialisation code which must come before the 'open for graphics' (e.g. setting WindowWidth and WindowHeight) and code which must come after the open statement (e.g. sub sphere). That can't work!
You either need to transfer the initialisation code into the 'main program', or you need to split your included file into two parts (e.g. _sphereinit.bas and _spheresub.bas) so you can include them in different places:
Code:nomainwin
'include _sphereinit.bas
open "" for graphics as #m
#m "trapclose [quit]"
#m "fill black"
for height = 0-winy/2 to winy/2
call sphere 0 , 0 , 0 , 50 , red$
next height
wait
[quit]
close #m
end
'include _spheresub.bas There's nothing 'magic' about 'include: the resulting 'merged' program must follow all the usual rules governing the order in which things are declared.
Richard.
|
|
Logged
|
|
|
|
bluatigro
Full Member
member is offline


Gender: 
Posts: 111
|
 |
Re: Object Oriented Liberty BASIC?
« Reply #14 on: Jan 23rd, 2015, 11:30am » |
|
update : - all global's are now in *_init.bas
error : - same errors
Code:
'include _fullscreen_init.bas
'include _math_init.bas
'include _color_init.bas
'include _sphere_init.bas
nomainwin
open "" for graphics as #m
#m "trapclose [quit]"
#m "fill black"
for height = 0-winy/2 to winy/2
call sphere 0 , 0 , 0 , 50 , red$
next height
wait
[quit]
close #m
end
'include _math.bas
'include _color.bas
'include _sphere.bas
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Object Oriented Liberty BASIC?
« Reply #15 on: Jan 23rd, 2015, 11:39am » |
|
on Jan 23rd, 2015, 11:30am, bluatigro wrote:all global's are now in *_init.bas same errors |
|
As documented, LBB ignores 'include directives at the very start of the program (this is to maximise compatibility with LB Workshop). If your code is exactly as you listed, that will be the explanation. Add at least one line before the first include:
Code:
' the first line must not be an include
'include _fullscreen_init.bas
'include _math_init.bas
'include _color_init.bas
'include _sphere_init.bas
nomainwin
open "" for graphics as #m
#m "trapclose [quit]"
#m "fill black"
for height = 0-winy/2 to winy/2
call sphere 0 , 0 , 0 , 50 , red$
next height
wait
[quit]
close #m
end
'include _math.bas
'include _color.bas
'include _sphere.bas Richard.
|
|
|
|
bluatigro
Full Member
member is offline


Gender: 
Posts: 111
|
 |
Re: Object Oriented Liberty BASIC?
« Reply #16 on: Jan 24th, 2015, 1:41pm » |
|
tryed Code:
''bluatigro 24 jan 2015
''sphere_test.bas
'include _fullscreen_init.bas
'include _math_init.bas
'include _color_init.bas
'include _sphere_init.bas
nomainwin
open "" for graphics as #m
#m "trapclose [quit]"
#m "fill " ; black$
for height = 0-winy/2 to winy/2
call sphere 0 , 0 , 0 , 50 , red$
next height
wait
[quit]
close #m
end
'include _math.bas
'include _color.bas
'include _sphere.bas
stil not working
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Object Oriented Liberty BASIC?
« Reply #17 on: Jan 24th, 2015, 2:28pm » |
|
on Jan 24th, 2015, 1:41pm, bluatigro wrote: This works perfectly for me:
_math_init.bas: Code:global pi , golden.ratio
pi = atn( 1 ) * 4
golden.ratio = ( sqr( 5 ) - 1 ) / 2
global true , false
true = not( false ) _color_init.bas: Code:global black$ , red$ , green$ , yellow$
global blue$ , magenta$ , cyan$ , white$
global gray$ , pink$ , purple$ , orange$
black$ = rgb$( 000 , 000 , 000 )
red$ = rgb$( 255 , 000 , 000 )
green$ = rgb$( 000 , 255 , 000 )
yellow$ = rgb$( 255 , 255 , 000 )
blue$ = rgb$( 000 , 000 , 255 )
magenta$ = rgb$( 255 , 000 , 255 )
cyan$ = rgb$( 000 , 255 , 255 )
white$ = rgb$( 255 , 255 , 255 )
gray$ = rgb$( 127 , 127 , 127 )
pink$ = rgb$( 255 , 127 , 127 )
purple$ = rgb$( 127 , 000 , 127 )
orange$ = rgb$( 255 , 127 , 000 ) _sphere_init.bas: Code:WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy
winx = WindowWidth
winy = WindowHeight
global height _math.bas: Code:function rad( deg )
rad = deg * pi / 180
end function _color.bas: Code:function rgb$( r , g , b )
r = r and 255
g = g and 255
b = b and 255
rgb$ = str$( r ); " " ; g * 256 ; " " ; b * 256 ^ 2
end function
function red( clr$ )
red = val( word$( clr$ , 1 ) )
end function
function green( clr$ )
green = val( word$( clr$ , 2 ) )
end function
function blue( clr$ )
blue = val( word$( clr$ , 3 ) )
end function
function klmix$( kl1$ , f , kl2$ )
r1 = red( kl1$ )
g1 = green( kl1$ )
b1 = blue( kl1$ )
r2 = red( kl2$ )
g2 = green( kl2$ )
b2 = blue( kl2$ )
r = r1 + f * ( r2 - r1 )
g = g1 + f * ( g2 - g1 )
b = b1 + f * ( b2 - b1 )
klmix$ = rgb$( r , g , b )
end function
function rainbow$( deg )
rainbow$ = rgb$( sin( rad( deg ) ) * 127 + 128 _
, sin( rad( deg + 120 ) ) * 127 + 128 _
, sin( rad( deg - 120 ) ) * 127 + 128 )
end function _sphere.bas: Code:sub sphere h$, x , y , z , d , clr$
if abs( height - y ) < d then
dd = sqr( d ^ 2 - ( height - y ) ^ 2 + .001 ) * 2
kl$ = klmix$( clr$ , .5 - ( height - y ) / d / 2 , black$ )
#h$ "goto " ; x + winx / 2 ;" "; winy / 2 - height - z / 4
#h$ "backcolor " ; kl$
#h$ "color " ; kl$
#h$ "down"
#h$ "ellipsefilled "; dd ;" "; dd / 4
#h$ "up"
end if
end sub Main Program: Code:''bluatigro 24 jan 2015
''sphere_test.bas
'include _math_init.bas
'include _color_init.bas
'include _sphere_init.bas
nomainwin
open "" for graphics as #m
#m "trapclose [quit]"
#m "fill " ; black$
for height = 0-winy/2 to winy/2
call sphere "#m", 0 , 0 , 0 , 50 , red$
next height
wait
[quit]
close #m
end
'include _math.bas
'include _color.bas
'include _sphere.bas
|
|
|
|
bluatigro
Full Member
member is offline


Gender: 
Posts: 111
|
 |
Re: Object Oriented Liberty BASIC?
« Reply #18 on: Jan 29th, 2015, 08:44am » |
|
update : - _sphere.bas extended whit 'egg'
error ? : - i got the same as you - but i got a white screen whit nothing
_sphere.bas Code:
''bluatigro 29 jan 1015
''_sphere.bas
sub sphere x , y , z , d , clr$
if abs( height - y ) < d then
dd = sqr( d ^ 2 - ( height - y ) ^ 2 + .001 ) * 2
kl$ = color.mix$( clr$ , .5 - ( height - y ) / d / 2 , black$ )
#m "goto " ; x + winx / 2 ; " " ; winy / 2 - height - z / 4
#m "backcolor " ; kl$
#m "color" ; kl$
#m "down"
#m "ellipsefilled "; dd ;" "; dd / 4
#m "up"
end if
end sub
sub egg x1 , y1 , z1 , d1 , x2 , y2 , z2 , d2 , dm , kl$ , no
af = sqr( ( x1 - x2 ) ^ 2 _
+ ( y1 - y2 ) ^ 2 + ( z1 - z2 ) ^ 2 + 1 )
dx = ( x2 - x1 ) / af
dy = ( y2 - y1 ) / af
dz = ( z2 - z1 ) / af
dd = ( d2 - d1 ) / af
dh = ( d1 + d2 ) / 2
if no < 2 then no = af
if no > af then no = af
for i = 0 to af step af / no
call sphere x1 + dx * i _
, y1 + dy * i , z1 + dz * i _
, d1 + dd * i + sin( i * pi / af ) _
* ( dm - dh ) , kl$
next i
end sub
|
|
Logged
|
|
|
|
bluatigro
Full Member
member is offline


Gender: 
Posts: 111
|
 |
Re: Object Oriented Liberty BASIC?
« Reply #19 on: Feb 6th, 2015, 10:17am » |
|
i tested the stuff in 1 file
i got a black screen whit nothing
Code:
''bluatigro 6 feb 2015
''sphere_test_2.bas
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy
winx = WindowWidth
winy = WindowHeight
global pi , golden.ratio
pi = atn( 1 ) * 4
golden.ratio = ( sqr( 5 ) - 1 ) / 2
global true , false
true = not( false )
global black$ , red$ , green$ , yellow$
global blue$ , magenta$ , cyan$ , white$
global gray$ , pink$ , purple$ , orange$
black$ = rgb$( 000 , 000 , 000 )
red$ = rgb$( 255 , 000 , 000 )
green$ = rgb$( 000 , 255 , 000 )
yellow$ = rgb$( 255 , 255 , 000 )
blue$ = rgb$( 000 , 000 , 255 )
magenta$ = rgb$( 255 , 000 , 255 )
cyan$ = rgb$( 000 , 255 , 255 )
white$ = rgb$( 255 , 255 , 255 )
gray$ = rgb$( 127 , 127 , 127 )
pink$ = rgb$( 255 , 127 , 127 )
purple$ = rgb$( 127 , 000 , 127 )
orange$ = rgb$( 255 , 127 , 000 )
global height
nomainwin
open "" for graphics as #m
#m "trapclose [quit]"
#m "fill " ; black$
for height = 0-winy/2 to winy/2
call sphere 0 , 0 , 0 , 50 , red$
next height
wait
[quit]
close #m
end
''math
function rad( deg )
rad = deg * pi / 180
end function
function range( l , h )
range = rnd(0) * ( h - l ) + l
end sub
function nr$( no , max )
nr$ = right$( "00000000" ; no , max )
end function
''color
function rgb$( r , g , b )
r = r and 255
g = g and 255
b = b and 255
rgb$ = str$( r ); " " ; g * 256 ; " " ; b * 256 ^ 2
end function
function color.red( clr$ )
color.red = val( word$( clr$ , 1 ) )
end function
function color.green( clr$ )
color.green = val( word$( clr$ , 2 ) )
end function
function color.blue( clr$ )
color.blue = val( word$( clr$ , 3 ) )
end function
function color.mix$( kl1$ , f , kl2$ )
r1 = color.red( kl1$ )
g1 = color.green( kl1$ )
b1 = color.blue( kl1$ )
r2 = color.red( kl2$ )
g2 = color.green( kl2$ )
b2 = color.blue( kl2$ )
r = r1 + f * ( r2 - r1 )
g = g1 + f * ( g2 - g1 )
b = b1 + f * ( b2 - b1 )
klmix$ = rgb$( r , g , b )
end function
function rainbow$( deg )
rainbow$ = rgb$( sin( rad( deg ) ) * 127 + 128 _
, sin( rad( deg + 120 ) ) * 127 + 128 _
, sin( rad( deg - 120 ) ) * 127 + 128 )
end function
''sphere
sub sphere x , y , z , d , clr$
if abs( height - y ) < d then
dd = sqr( d ^ 2 - ( height - y ) ^ 2 + .001 ) * 2
kl$ = color.mix$( clr$ , .5 - ( height - y ) / d / 2 , black$ )
#m "goto " ; x + winx / 2 ; " " ; winy / 2 - height - z / 4
#m "backcolor " ; kl$
#m "color" ; kl$
#m "down"
#m "ellipsefilled "; dd ;" "; dd / 4
#m "up"
end if
end sub
sub egg x1 , y1 , z1 , d1 , x2 , y2 , z2 , d2 , dm , kl$ , no
af = sqr( ( x1 - x2 ) ^ 2 _
+ ( y1 - y2 ) ^ 2 + ( z1 - z2 ) ^ 2 + 1 )
dx = ( x2 - x1 ) / af
dy = ( y2 - y1 ) / af
dz = ( z2 - z1 ) / af
dd = ( d2 - d1 ) / af
dh = ( d1 + d2 ) / 2
if no < 2 then no = af
if no > af then no = af
for i = 0 to af step af / no
call sphere x1 + dx * i _
, y1 + dy * i , z1 + dz * i _
, d1 + dd * i + sin( i * pi / af ) _
* ( dm - dh ) , kl$
next i
end sub
|
| « Last Edit: Feb 6th, 2015, 10:18am by bluatigro » |
Logged
|
|
|
|
|