xHarbour Reference Documentation > Statement Reference xHarbour Developers Network  

INLINE METHOD

Declares and implements an inline method that spans across multiple lines.

Syntax

INLINE METHOD <MethodName>( [<params,...>] )
  <.. program code ..>
ENDMETHOD

Arguments

<MethodName>
This is the symbolic name of the method to implement. It must begin with a letter or underscore followed by digits, letters or underscores. The symbolic name can contain up to 63 characters.
<params,...>
This is a acomma separated list of formal parameters accepted by the method.
ENDMETHOD
This ends the implementation of an INLINE METHOD that spans across multiple lines.

Description

Methods are declared within the class declaration. When a method is also implemented between CLASS and ENDCLASS, it is called an INLINE method. The INLINE METHOD declaration declares an inline method whose implementation spans across multiple lines. The end of this implementation must be indicated with the ENDMETHOD statement.

INLINE METHOD exists for compatibility reasons. It is recommended to declare a method with METHOD (declaration) and implement it separately with METHOD (implementation).

Note:  if a method can be implemeted with one line of code, the INLINE option of the METHOD (declaration) can be used.

Info

See also:CLASS, METHOD (declaration), METHOD (implementation)
Category: Class declaration , Declaration , xHarbour extensions
Header:hbclass.ch
Source:vm\classes.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example implements a class whose methods are entirely implemented
// INLINE. Objects of the class extract subsequent lines of an ASCII text
// until no more text lines are available.

   #include "hbclass.ch"

   PROCEDURE Main
      LOCAL obj := LineParser():new( Memoread( "Test.prg" ) )

      DO WHILE .NOT. obj:eof()
         ? obj:line
         obj:nextLine()
      ENDDO
   RETURN


   CLASS LineParser
      PROTECTED:
      DATA text

      INLINE METHOD extract
         LOCAL i := At( Chr(13)+Chr(10), ::text )

         IF i == 0
            ::line := ::text
            ::text := ""
         ELSE
            ::line := SubStr( ::text, 1, i-1 )
            ::text := SubStr( ::text, i+2    )
         ENDIF

         RETURN self
      ENDMETHOD


      EXPORTED:
      DATA line  INIT  ""  READONLY

      METHOD init( cText ) INLINE ( ::text := cText, ::extract(), self )
      METHOD eof           INLINE ( Len( ::text + ::line ) == 0 )

      INLINE METHOD nextLine
         ::extract()
         RETURN ::line
      ENDMETHOD

   ENDCLASS

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe