FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Methods of a variable
Posts: 408
Joined: Sun Nov 06, 2005 03:55 PM
Methods of a variable
Posted: Sat May 21, 2016 07:23 PM

How is it possible to find all of the methods of a variable?

Local cStr := "Hello World!"
cStr:ClassName() ==>> "CHARACTER"

__objGetMethodList( cStr ) ==>> crashes and burns

How can I get a list of all of the available methods of cStr, like converting it to a number via a method of the variable?

Thanks,

Byron ...

Thanks,

Byron Hopp

Matrix Computer Services
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Methods of a variable
Posted: Sat May 21, 2016 08:29 PM

Byron,

Please run FWH\samples\classtree.prg

With that PRG you can review all the classes that are linked in your app.

Basic types are simulated, they are not real classes. You can't see them in the above example.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Methods of a variable
Posted: Sat May 21, 2016 08:32 PM
These are the basic types defined in Harbour\src\vm\classes.c

Code (fw): Select all Collapse
/*
 * Get the class name of an object
 */
const char * hb_objGetClsName( PHB_ITEM pObject )
{
   HB_TRACE( HB_TR_DEBUG, ( "hb_objGetClsName(%p)", pObject ) );

   if( HB_IS_ARRAY( pObject ) )
   {
      if( pObject->item.asArray.value->uiClass != 0 )
         return s_pClasses[ pObject->item.asArray.value->uiClass ]->szName;
      else
         return "ARRAY";
   }
   /* built in types */
   else if( HB_IS_NIL( pObject ) )
      return "NIL";

   else if( HB_IS_STRING( pObject ) )
      return "CHARACTER";

   else if( HB_IS_NUMERIC( pObject ) )
      return "NUMERIC";

   else if( HB_IS_DATE( pObject ) )
      return "DATE";

   else if( HB_IS_TIMESTAMP( pObject ) )
      return "TIMESTAMP";

   else if( HB_IS_LOGICAL( pObject ) )
      return "LOGICAL";

   else if( HB_IS_BLOCK( pObject ) )
      return "BLOCK";

   else if( HB_IS_HASH( pObject ) )
      return "HASH";

   else if( HB_IS_POINTER( pObject ) )
      return "POINTER";

   else if( HB_IS_SYMBOL( pObject ) )
      return "SYMBOL";

   else
      return "UNKNOWN";
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Methods of a variable
Posted: Sun May 22, 2016 01:08 PM

Functions like __objGetMethodList do not work with Scalar values.

You can try this:

uVar := "Hello" // Any data type
xbrowser uVar:ClassSel()

You can see all symbols understood by this Scalar Class.
Some of them would be methods you may be interested in.

Actually, to the best of my knowledge, AsString() is a method commonly available in all Scalar classes and except for Arrays and Hashes, there are no other useful methods.

Even for array or hash, I do not think using the methods may be more efficient than using native functions.

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion