Xbase++ VAR2CHAR()

Discuss anything else that does not suite other forums.

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Xbase++ VAR2CHAR()

Post 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 
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Xbase++ VAR2CHAR()

Post 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 :?:
have fun
Jimmy
edk
Posts: 999
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Xbase++ VAR2CHAR()

Post by edk »

Try: hb_valToExp( xVal )
User avatar
dragancesu
Posts: 931
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: Xbase++ VAR2CHAR()

Post 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
User avatar
Anand
Posts: 596
Joined: Tue May 24, 2016 4:36 pm
DBs Used: DBF

Re: Xbase++ VAR2CHAR()

Post 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
Regards,

Anand

Image
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Xbase++ VAR2CHAR()

Post 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 :?:
have fun
Jimmy
Post Reply