Page 1 of 1

Xbase++ VAR2CHAR()

Posted: Wed Oct 23, 2019 9:08 pm
by AUGE_OHR
hi,

Xbase++ have VAR2CHAR() to convert any Type to String.
does harbour / HMG have something like this :?:

Code: Select all

   PROCEDURE Main 
      LOCAL aArray  := { 1, "A" } 
      LOCAL bBlock  := {|x| x + 1 } 
      LOCAL cString := "Hello World" 
      LOCAL dDate   := Date() 
      LOCAL lOk     := .T. 
      LOCAL nNumber := 123.456 
      LOCAL oGet    := Get():new()  // Object
      LOCAL uNil    := NIL 
 
      ? Var2Char( aArray  )   // Ergebnis: {         1, A} 
      ? Var2Char( bBlock  )   // Ergebnis: {|x| x + 1 } 
      ? Var2Char( cString )   // Ergebnis: Hello World 
      ? Var2Char( dDate   )   // Ergebnis: 20000426 
      ? Var2Char( lOk     )   // Ergebnis: T 
      ? Var2Char( nNumber )   // Ergebnis: 123.456 
      ? Var2Char( oGet    )   // Ergebnis: Get -> ClassName of Object
      ? Var2Char( uNil    )   // Ergebnis: NIL 

   RETURN 

Re: Xbase++ VAR2CHAR()

Posted: Wed Oct 23, 2019 9:17 pm
by AUGE_OHR
hi,

just found hb_ValToStr()

Code: Select all

Set( _SET_DATEFORMAT, "yyyy-mm-dd" )
? hb_ValToStr( 4 ) == "         4"
? hb_ValToStr( 4.0 / 2 ) == "         2.00"
? hb_ValToStr( "String" ) == "String"
? hb_ValToStr( 0d20010101 ) == "2001-01-01"
? hb_ValToStr( NIL ) == "NIL"
? hb_ValToStr( .F. ) == ".F."
? hb_ValToStr( .T. ) == ".T."
it have almost what i need.

missing :

Code: Select all

? hb_ValToStr(Array) 
? hb_ValToStr(oGet)   // -> Object ClassName
is there a harbour / HMG workaround :?:

Re: Xbase++ VAR2CHAR()

Posted: Thu Oct 24, 2019 6:48 am
by edk
Try: hb_valToExp( xVal )

Re: Xbase++ VAR2CHAR()

Posted: Thu Oct 24, 2019 9:12 am
by dragancesu
Xbase++ != Harbour

Harbour Reference Guide
https://harbour.github.io/doc/harbour.html#version

If something not found than create your procedure/function for substitute

Re: Xbase++ VAR2CHAR()

Posted: Thu Oct 24, 2019 9:45 am
by Anand
dragancesu wrote: Thu Oct 24, 2019 9:12 am Xbase++ != Harbour
Yes and I think, Jimmy knows it.
He is actually trying to find out if similar already exist, so that he does not have to create it.

Edward has suggest some in earlier reply, so there exist some functions in Harbour which gives result as required, albeit in different name.

And yes, creating the missing required ones is the last resort, I agree.

Regards,

Anand

Re: Xbase++ VAR2CHAR()

Posted: Thu Oct 24, 2019 9:22 pm
by AUGE_OHR
hi,

i try to create a #Include file for my Xbase++ Source to use it which harbour

Code: Select all

#xtranslate Var2Bin                         =>  HB_Serialize
#xtranslate Bin2Var                         =>  HB_DeSerialize
#xtranslate VAR2CHAR                        =>  hb_valToExp

#xtranslate BAND                            =>  hb_BitAnd
#xtranslate BOr                             =>  hb_BitOr
#xtranslate BXOr                            =>  hb_BitOr
#xtranslate BNot                            =>  hb_BitNot
this work as long Syntax is same.

my Problem is that i don't know where to search
now i got a Link to https://github.com/Petewg/harbour-core/wiki

Question : is there a help file which i can use Offline :?: