Author |
Topic: Object Oriented Liberty BASIC? (Read 3304 times) |
|
bluatigro
Full Member
member is offline


Gender: 
Posts: 111
|
 |
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
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
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.
|
|
|
|
bluatigro
Full Member
member is offline


Gender: 
Posts: 111
|
 |
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
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
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.
|
|
Logged
|
|
|
|
|