The MASM Forum Archive 2004 to 2012

Project Support Forums => HLA Forum => Topic started by: DarkWolf on April 12, 2008, 05:45:14 AM

Title: OO Code with 1.101
Post by: DarkWolf on April 12, 2008, 05:45:14 AM
Using v1.101 I get a warning about the use of the THIS keyword.


Compiling "strcls.hla" to "strcls.asm"
Error in file "strcls.hla" at line 24
Misuse of THIS reserved word outside class.
Near: << this >>

Error in file "strcls.hla" at line 24
syntax error, unexpected '.'.
Near: << . >>



procedure create; @nodisplay;
begin create;
push( eax );
if( esi = 0 ) then
mem.alloc( @size( strcls ));
mov( eax, esi );
endif;
mov( &strcls._VMT_, this._pVMT_ );
mov( 0, this.s );
pop( eax );
ret();
end create;


The error points to the line with "this._pVMT_"
All the examples in the HLA reference show it this way.
I am not sure how I am outside of the class.
Title: Re: OO Code with 1.101
Post by: Evenbit on April 12, 2008, 07:36:14 AM
You must pre-pend the classname to any procedure or method declaration that you wish to be associated with a particular class.

procedure strcls.create; @nodisplay;

Nathan.
Title: Re: OO Code with 1.101
Post by: Evenbit on April 12, 2008, 07:41:26 AM
NB --  This pre-pending doesn't apply to either the 'begin' or 'end' clauses of the declaration.

procedure strcls.create; @nodisplay;
begin create;
push( eax );
if( esi = 0 ) then
mem.alloc( @size( strcls ));
mov( eax, esi );
endif;
mov( &strcls._VMT_, this._pVMT_ );
mov( 0, this.s );
pop( eax );
ret();
end create;


Nathan.
Title: Re: OO Code with 1.101
Post by: DarkWolf on April 12, 2008, 10:01:37 PM
Nothing like completely missing the obvious.

I have no idea how I missed seeing that.

(is there a smiley for smacking yourself upside the head)
Title: Re: OO Code with 1.101
Post by: Sevag.K on April 13, 2008, 07:04:22 PM
(http://www.websmileys.com/sm/crazy/1261.gif)

Many more here:
http://www.websmileys.com/