Page 2 of 2
Re: string to parameter
Posted: Thu Oct 25, 2018 7:11 am
by PeteWG
Hi,
Try this:
Code: Select all
LOCAL aColors, cColor
// fill this hash array with all color pairs you'd possibly need)
aColors := { "WHITE"=>WHITE, "GRAY"=>GRAY, "RED"=>RED, "GREEN"=>GREEN }
cColor := "RED"
@ 84, 275 HPDFPRINT "R$ TOTAL" FONT cFonte1 size nFonte_size1 COLOR hb_HGetDef( aColors, cColor, BLACK ) CENTER
cColor := "GREEN"
@ 84, 275 HPDFPRINT "R$ TOTAL" FONT cFonte1 size nFonte_size1 COLOR hb_HGetDef( aColors, cColor, BLACK ) CENTER
it will work. (it's used in production-code for years)
regards,
Pete
Re: string to parameter
Posted: Thu Oct 25, 2018 2:02 pm
by andyglezl
Gracias Pete, es bueno saberlo para cuando tengamos la necesidad de usarlo.
--------------------------------------------------------------------
Thanks Pete, it's good to know when we need to use it.
Re: string to parameter
Posted: Sat Oct 27, 2018 4:51 am
by andyglezl
Me intrigo eso de poder convertir definiciones en variables y empeze a hacer esto...
Pero "ya me trabe" con el manejo de los arrays.
Alguien lo quiere seguir ?
----------------------------------------------------------------------------------------------------------
I am intrigued by being able to convert definitions into variables and I started doing this ...
But "I'm stuck" with the management of the arrays.
Does someone want to follow him?
Code: Select all
#include "hmg.ch"
FUNCTION Main()
DEFINE WINDOW Form_1 AT 100,500 WIDTH 500 HEIGHT 200 TITLE "TEST" MAIN ON INIT Convert( )
@ 010 , 010 LABEL Label_01 WIDTH 400 VALUE "#DEFINE 2 PUBLIC VARIABLE" FONT "Arial" SIZE 20 BOLD
END WINDOW
Form_1.Activate
RETURN
*---------------------------------*
Function Convert( )
// THIS, IS IN MI CASE !!!
cColors := Memoread("D:\AGL\HMG\3.4.4\INCLUDE\i_color.ch" )
cColors := StrTran( cColors, "{", '",{' )
cColors := StrTran( cColors, "#define ", '{"' )
cColors := StrTran( cColors, "}", '} },' )
cColors := StrTran( cColors, CHR(9), "" )
cColors := "{ " + cColors + " }"
// hb_ATokens( <cString>, [<cDelim>|<lEOL>], [<lSkipStrings>], [<lDoubleQuoteOnly>] )
aTokens := hb_ATokens( cColors ) ; msgbox( ValType( aTokens ) ) ; msgbox( aTokens )
For i1 = 1 TO LEN( aTokens )
__mvPublic( aTokens[ i1, 1 ] )
__mvPut( aTokens[ i1, 1 ], aTokens[ i1, 2 ] )
NEXT
Return .T.
*---------------------------------*
Re: string to parameter
Posted: Sat Oct 27, 2018 6:43 pm
by srvet_claudio
Try with Harbour preprocesor functions:
pPP := __pp_Init ( "C:\HMG.3.4.4\INCLUDE" , "HMG.CH" ) // Init Harbour PreProcesor
aColor := __pp_Process ( pPP, "BLACK" ) // Run Harbour PreProcesor
Re: string to parameter
Posted: Sat Oct 27, 2018 7:31 pm
by andyglezl
Entonces, volviendo al problema de jairpinho.
Lo siguiente debería de funcionarle.
-----------------------------------------------------------
Then, returning to the problem of jairpinho.
The following should work for you.
pPP := __pp_Init ( "D:\HMG\3.4.4\INCLUDE" , "HMG.CH" ) // Init Harbour PreProcesor
// aColor := __pp_Process ( pPP, oRow: fieldGet (28) )
aColor := __pp_Process ( pPP, "RED" ) // Run Harbour PreProcesor
@ 84, 275 HPDFPRINT "R$ TOTAL" FONT cFonte1 size nFonte_size1 COLOR &aColor CENTER // -> it should work
Gracias Dr. Claudio !!!
Re: string to parameter
Posted: Sun Oct 28, 2018 12:11 pm
by PeteWG
srvet_claudio wrote: ↑Sat Oct 27, 2018 6:43 pm
Try with Harbour preprocesor functions:
pPP := __pp_Init ( "C:\HMG.3.4.4\INCLUDE" , "HMG.CH" ) // Init Harbour PreProcesor
aColor := __pp_Process ( pPP, "BLACK" ) // Run Harbour PreProcesor
this is, probably, the comment of the month!
--or at least, the most intriguing hint, regarding the preprocessor
and the mystic internals of 'harbour compiler'.
thanks for posting!
regards,
Pete
Re: string to parameter
Posted: Mon Oct 29, 2018 9:21 pm
by jairpinho
Thank you guys, I'll test.
Re: string to parameter
Posted: Tue Dec 04, 2018 8:20 pm
by SALINETAS24
Hola.., has probado esto..?
Code: Select all
Local cColor := { 255, 0, 0}
@ 84, 275 HPDFPRINT "R$ TOTAL" FONT cFonte1 size nFonte_size1 COLOR cColor CENTER // -> does not work