LB Booster
General >> General Board >> OOP test in LBB 3.00
http://lbb.conforums.com/index.cgi?board=general&action=display&num=1435319625

OOP test in LBB 3.00
Post by bluatigro on Jun 26th, 2015, 11:53am

i tryed something

error :
- it isnt working as expexted

main : Code:
''bluatigro 26 jun 2015
''OOP test

'include _complex.bas

new q as complex 1 , 2

print q::get.r() , q::get.i()

print q::toString$()

input a$
 

_complex.bas : Code:
''bluatigro 27 jun 2015
''OOP lib : complex number

class complex

  dim mr , mi

  sub complex
    mr = 0
    mi = 0
  end sub
  sub complex a , b   
    mr = a
    mi = b
  end sub
  sub fill a , b   
    mr = a
    mi = b
  end sub

  function get.r()
    get.r = mr
  end function 

  function get.i()
    get.i = mi
  end function

  function toString$()
    toString$ = "( " + str$( this::get.r() ) _
    +  " + " + str$( this::get.i() ) + "j )"
  end function

end class  
 

Re: OOP test in LBB 3.00
Post by Richard Russell on Jun 26th, 2015, 2:59pm

on Jun 26th, 2015, 11:53am, bluatigro wrote:
it isnt working as expected

You simply need to move the 'include to the end of the program:

Code:
''bluatigro 26 jun 2015
''OOP test

new q as complex 1 , 2

print q::get.r() , q::get.i()

print q::toString$()

input a$

'include _complex.bas 

Richard.
Re: OOP test in LBB 3.00
Post by bluatigro on Jul 3rd, 2015, 12:09pm

@richard :
- i tryed : Code:
''bluatigro 26 jun 2015
''OOP test

new q as complex 1 , 2

print "r = " ; q::get.r() 
print "i = " ; q::get.i()
print q::toString$()

input a$
end

'include _complex.bas )
 


i got a 'mistake' in 'r =' line
i dont know why the ) at the end of the include is for
lbb asked for that
Re: OOP test in LBB 3.00
Post by Richard Russell on Jul 3rd, 2015, 2:45pm

on Jul 3rd, 2015, 12:09pm, bluatigro wrote:
i dont know why the ) at the end of the include is for

Delete it - that is the cause of your problem. Make sure there is a new-line (CRLF) at the end of the 'include statement; LBB doesn't like the final line of a program to be unterminated.

Richard.