LB Booster
« LB Booster version 3.00 released »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:40am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1 ... 1 2 3  Notify Send Topic Print
 veryhotthread  Author  Topic: LB Booster version 3.00 released  (Read 9027 times)
bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: LB Booster version 3.00 released
« Reply #35 on: Jun 26th, 2015, 11:21am »

LBB is now starting to be a good tool

i have [ some ] ideas for inprovement

[ see REM in next listning ]

Code:
class complex
''mr and mi are private now
''shoot be a choice able for public
  dim mr , mi
''default parameters are nice to
''sub complex a = 0 , b = 0
  sub complex
    mr = 0
    mi = 0
  end sub
  sub complex a , b   
    mr = a
    mi = b
  end sub
''if mr and mi are public
''these two functions are not nesery
  function r()
    r = mr
  end function 
  function i()
    i = mi
  end function

''THIS is what i want to do :

''  function add( in as complex ) as complex
''    add = new complex this::mr + in::mr _
''    , this::mi + in::mi
''  end function

''or even better :

''  operator +=( in as complex ) as complex
''    return complex this::mr + in::mr _
''    , this::mi + in::mi
''  end operator

end class  
 

this is nice to :
Code:
dim a() = { 0,1,2,3,4,5 }
''and
dim m(,) ={{0,1},{2,3}}
 
« Last Edit: Jun 26th, 2015, 11:26am by bluatigro » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: LB Booster version 3.00 released
« Reply #36 on: Jul 6th, 2015, 06:59am »

on Jun 26th, 2015, 11:21am, bluatigro wrote:
this is nice to :
Code:
dim a() = { 0,1,2,3,4,5 }
''and
dim m(,) ={{0,1},{2,3}} 

If you don't mind using the BBC BASIC 'escape' feature you can do:

Code:
    dim a(5)
    !a() = 0,1,2,3,4,5

    dim m(1,1)
    !m() = 0,1,2,3 

Richard.
User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: LB Booster version 3.00 released
« Reply #37 on: Jul 24th, 2015, 08:53am »


it is already posible to do OOP
but it is slow Code:
''first we create some objects
obj1$ = v3d$( 1 , 2 , 3 )
obj2$ = v3d$( 4 , 5 , 6 )
''then we print them
print "vectors :"
print " a = " ; obj1$ 
print " b = " ; obj2$
''then we do some OOP math
print "adding :"
print "a + b = " ; addv3d$( obj1$ , obj2$ )
print "subtracting :"
print "a - b = " ; subv3d$( obj1$ , obj2$ )
print "lenght :
print "| a | = " ; lenghtv3d( obj1$ )
print "| b | = " ; lenghtv3d( obj2$ )

end
''special class functions
function v3d$( x , y , z )
''constructor of a v3d object$
  v3d$ = str$( x ) + " " + str$( y ) + " " + str$( z )
end function
function xv3d( a$ )
''property
  xv3d = val( word$( a$ , 1 ) )
end function
function yv3d( a$ )
''property
  yv3d = val( word$( a$ , 2 ) )
end function
function zv3d( a$ )
''property
  zv3d = val( word$( a$ , 3 ) )
end function
function addv3d$( a$ , b$ )
''first get property's
  ax = xv3d( a$ )
  ay = yv3d( a$ )
  az = zv3d( a$ )
  bx = xv3d( b$ )
  by = yv3d( b$ )
  bz = zv3d( b$ )
''use constructor to get new object$
  addv3d$ = v3d$( ax + bx , ay + by , az + bz )
end function
function subv3d$( a$ , b$ )
''first get property's
  ax = xv3d( a$ )
  ay = yv3d( a$ )
  az = zv3d( a$ )
  bx = xv3d( b$ )
  by = yv3d( b$ )
  bz = zv3d( b$ )
''use constructor to get new object$
  subv3d$ = v3d$( ax - bx , ay - by , az - bz )
end function
function lenghtv3d( a$ )
  x = val( word$( a$ , 1 ) )
  y = val( word$( a$ , 2 ) )
  z = val( word$( a$ , 3 ) )
  lenghtv3d = sqr( x ^ 2 + y ^ 2 + z ^ 2 )
end function
''genaral class functions
''these work slow
''so i dont think of using them
''NOT TESTED JET
function setprop$( clas$ , object$ , prop$ , val$ )
  pointer = 0
  out$ = ""
  while pointer < 20 _
  and word$( clas$ , pointer ) <> prop$ 
    if word$( clas$ , pointer ) = prop$ then
      out$ = out$ + " " + val$
    else
      out$ = out$ + " " + word$( object$ , pointer )
    end if
    pointer = pointer + 1
  wend
  setprop$ = out$
end function
function getprop$( clas$ , object$ , prop$ )
  pointer = 0
  out$ = "error"
  while pointer < 20 _
  and word$( clas$ , pointer ) <> prop$ 
    if word$( clas$ , pointer ) = prop$ then
      out$ = word$( object$ , pointer )
    end if
    pointer = pointer + 1
  wend
  setprop$ = out$
end function
 
User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: LB Booster version 3.00 released
« Reply #38 on: Jul 24th, 2015, 09:24am »


update :
- i tryed my general OOP

error :
- its not wat i expected

Code:
''first we create some objects
obj1$ = v3d$( 1 , 2 , 3 )
obj2$ = v3d$( 4 , 5 , 6 )
''then we print them
print "vectors :"
print " a = " ; obj1$ 
print " b = " ; obj2$
''then we do some OOP math
print "adding :"
print "a + b = " ; addv3d$( obj1$ , obj2$ )
print "subtracting :"
print "a - b = " ; subv3d$( obj1$ , obj2$ )
print "lenght :"
print "| a | = " ; lenghtv3d( obj1$ )
print "| b | = " ; lenghtv3d( obj2$ )
clas$ = "x y z"
print "general OOP test"
print "class = " ; clas$
object$ = v3d$( 1 , 2 , 3 )
print "v3d$ = " ; object$
object$ = setprop$( clas$ , object$ , "x" , "77" )
print "v3d.x = 77 = " ; object$
property$ = getprop$( clas$ , object$ , "z" )
print "v3d.z = " ; property$ 
end
''special class functions
function v3d$( x , y , z )
''constructor of a v3d object$
  v3d$ = str$( x ) + " " + str$( y ) + " " + str$( z )
end function
function xv3d( a$ )
''property
  xv3d = val( word$( a$ , 1 ) )
end function
function yv3d( a$ )
''property
  yv3d = val( word$( a$ , 2 ) )
end function
function zv3d( a$ )
''property
  zv3d = val( word$( a$ , 3 ) )
end function
function addv3d$( a$ , b$ )
''first get property's
  ax = xv3d( a$ )
  ay = yv3d( a$ )
  az = zv3d( a$ )
  bx = xv3d( b$ )
  by = yv3d( b$ )
  bz = zv3d( b$ )
''use constructor to get new object$
  addv3d$ = v3d$( ax + bx , ay + by , az + bz )
end function
function subv3d$( a$ , b$ )
''first get property's
  ax = xv3d( a$ )
  ay = yv3d( a$ )
  az = zv3d( a$ )
  bx = xv3d( b$ )
  by = yv3d( b$ )
  bz = zv3d( b$ )
''use constructor to get new object$
  subv3d$ = v3d$( ax - bx , ay - by , az - bz )
end function
function lenghtv3d( a$ )
  x = val( word$( a$ , 1 ) )
  y = val( word$( a$ , 2 ) )
  z = val( word$( a$ , 3 ) )
  lenghtv3d = sqr( x ^ 2 + y ^ 2 + z ^ 2 )
end function
''genaral class functions
''these work slow
''so i dont think of using them
function setprop$( clas$ , object$ , prop$ , val$ )
  pointer = 0
  out$ = ""
  while pointer < 20 _
  and word$( clas$ , pointer ) <> prop$ _
  and word$( clas$ , pointer ) <> ""
    if word$( clas$ , pointer ) = prop$ then
      out$ = out$ + " " + val$
    else
      out$ = out$ + " " + word$( object$ , pointer )
    end if
    pointer = pointer + 1
  wend
  setprop$ = out$
end function
function getprop$( clas$ , object$ , prop$ )
  pointer = 0
  out$ = "error"
  while pointer < 20 _
  and word$( clas$ , pointer ) <> prop$ _
  and word$( clas$ , pointer ) <> ""
    if word$( clas$ , pointer ) = prop$ then
      out$ = word$( object$ , pointer )
    end if
    pointer = pointer + 1
  wend
  getprop$ = out$
end function
 
User IP Logged

Pages: 1 ... 1 2 3  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls