LB Booster
« Object Oriented Liberty BASIC? »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 04:53am



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 2 3  Notify Send Topic Print
 veryhotthread  Author  Topic: Object Oriented Liberty BASIC?  (Read 3304 times)
bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: Object Oriented Liberty BASIC?
« Reply #28 on: Feb 28th, 2015, 3:06pm »

i tryed this Code:
''bluatigro 14 feb 2015
''mod-test.bas

'include t3d.bas

print "now in mod test bas"
new a as t3d 1 , 2 , 3
print a::toStr$()
 

Code:
''bluatigro 14 feb 2015
''t3d.bas

new p as t3d 255 , 3 , 6
new p1 as t3d 4 , 4 , 4
print p::toStr$()
print p1::toStr$()
''next line goes also wrong whit "!" in front
''p = p::add( p1 )
print p::toStr$()
discard p 
discard p1
end
class t3d
  dim a , b , c
  sub t3d
    a = 0
    b = 0
    c = 0
  end sub
  sub t3d x , y , z
    a = x
    b = y
    c = z
  end sub
  function x
    x = a
  end function
  function y
    y = b
  end function  
  function z
    z = c
  end function
! FUNCTION add( d AS t3d ) AS t3d
    new q as t3d a + d::x() , b + d::y() , c + d::z()
    add = q
    discard q
  end function
  function toStr$()
''this is now right
    toStr$ = "( " + str$( this::x() ) _
          + " , " + str$( this::y() ) _
          + " , " + str$( this::z() ) + " )"
  end function
end class

''t3d.bas
 


error :
- t3d.bas output corect
- mod test.bas only t3d.bas output
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Object Oriented Liberty BASIC?
« Reply #29 on: Feb 28th, 2015, 3:29pm »

on Feb 28th, 2015, 3:06pm, bluatigro wrote:
- t3d.bas output corect
- mod test.bas only t3d.bas output

t3d.bas includes an END statement (and other code which must come after the main program) so, of course, anything following the 'include t3d.bas will not be executed:

Code:
    print "This is executed"     ' this is in the included file
    end                          ' this is in the included file
    print "This isn't executed"  ' this is in the base program 

Sometimes I think the 'include directive has been misunderstood. It quite literally 'includes' the specified file at that point in the program; nothing 'clever' or 'magic' happens!

Richard.
« Last Edit: Feb 28th, 2015, 3:32pm by Richard Russell » User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: Object Oriented Liberty BASIC?
« Reply #30 on: Mar 1st, 2015, 08:47am »

i tryed Code:
''bluatigro 14 feb 2015
''mod-test.bas

print "now in mod test"
new a as t3d 1 , 2 , 3
print a::toStr$()

end
'include t3d.bas
 

Code:
''bluatigro 14 feb 2015
''t3d.bas

class t3d
  dim a , b , c
  sub t3d
    a = 0
    b = 0
    c = 0
  end sub
  sub t3d x , y , z
    a = x
    b = y
    c = z
  end sub
  function x
    x = a
  end function
  function y
    y = b
  end function  
  function z
    z = c
  end function
! FUNCTION add( d AS t3d ) AS t3d
    new q as t3d a + d::x() , b + d::y() , c + d::z()
    add = q
    discard q
  end function
  function toStr$()
''this is now right
    toStr$ = "( " + str$( this::x() ) _
          + " , " + str$( this::y() ) _
          + " , " + str$( this::z() ) + " )"
  end function
end class

''t3d.bas
 


i got a 'mistake' in the include line
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Object Oriented Liberty BASIC?
« Reply #31 on: Mar 1st, 2015, 09:06am »

on Mar 1st, 2015, 08:47am, bluatigro wrote:
i got a 'mistake' in the include line

Presumably it's this line:

Code:
! FUNCTION add( d AS t3d ) AS t3d 

That starts with an exclamation mark, so LBB will assume it is BBC BASIC code and bypass the translator, but it's not BBC BASIC code (it's not LBB code either)!

As I've said before do not put code in an included file until it is thoroughly debugged! Because neither the debugger nor the run-time error reporting can tell you in which line an error occurs - they will both simply indicate the 'include line - it makes debugging included code very difficult.

First test it 'inline' as a conventional program, and only when you are very confident the module does what you want and is completely bug-free put it in a separate file. If it does subsequently fail, despite your care, put it back 'inline' to fix the problem.

Richard.
User IP Logged

Pages: 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