Board Logo
« What is the difference between JB and LB? »

Welcome Guest. Please Login or Register.
Sep 25th, 2017, 7:16pm


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ


« Previous Topic | Next Topic »
Pages: 1 2 3  Notify Send Topic Print
 sticky  Author  Topic: What is the difference between JB and LB?  (Read 10722 times)
bluatigro
Full Member
ImageImageImageImage


member is offline

Avatar

cxio difersas el tio respondas cxio samvaloras [ thats esperanto for : everybody is different therefore everybody is equal ]


PM

Gender: Male
Posts: 229
xx Re: What is the difference between JB and LB?
« Reply #30 on: Jul 24th, 2015, 03:44am »


you can use opengl whit LB not whit JB

i started to build a set of increasing eleborate examples

on :
www.libertybasic.conforums.com

i have the same nickname there

there are a view things i want in LB to :
- swap
- sgn
- include
- OOP

there is a way to do OOP in LB and JB
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

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

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls