Methods of a variable

Methods of a variable

Postby byron.hopp » Sat May 21, 2016 7: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
byron.hopp
 
Posts: 386
Joined: Sun Nov 06, 2005 3:55 pm
Location: Southern California, USA

Re: Methods of a variable

Postby Antonio Linares » Sat May 21, 2016 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Methods of a variable

Postby Antonio Linares » Sat May 21, 2016 8:32 pm

These are the basic types defined in Harbour\src\vm\classes.c

Code: Select all  Expand view  RUN
/*
 * 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Methods of a variable

Postby nageswaragunupudi » Sun May 22, 2016 1: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
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 35 guests