Preprocessor question

Issues and Discussions related to Harbour

Moderator: Rathinagiri

Post Reply
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Preprocessor question

Post by srvet_claudio »

Hi friends, i need your help.

With this syntax is:

Code: Select all

#xcommand MyCmd =>; 
          a:= 1;;
          b:= 2
the Harbour preprocessor generate this line of code (one line of code):

Code: Select all

a:= 1; b:= 2
My question is: what is the directive of the preprocessor that generate the previous code but in two lines different?, eg.

Code: Select all

a:= 1
b:= 2
This is very important for debug purpose.

Thanks in advance.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
EduardoLuis
Posts: 682
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina

Re: Preprocessor question

Post by EduardoLuis »

Hola Claudio:

No se si servirá, pero se me ocurre un lazo FOR - NEXT y una variable a la que pasarle referencias

alfa := 'var'
FOR i:= 1 to n
mix := '000' + ALLTRIM(STR(i)) // '000' = 1 digito mas que n
mix := RIGHT(mix,4)
alfa += mix
#xcommand MyCmd => ;
&alfa := i
next

En teoria deberían generarse tantas líneas como registros se coloquen en el lazo.

No estoy seguro pero supongo que podría funcionar.-
Un abrazo.
Eduardo
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Preprocessor question

Post by srvet_claudio »

Eduardo,
lamentablemente no funciona, porque siempre se genera el código en la misma linea del texto, yo necesito que aparezca cada sentencia en una linea diferente del texto, ej:

linea 1: a := 1
linea 2: b := 2
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Preprocessor question

Post by srvet_claudio »

Hi all,
I found a not very elegant solution but it works:

create a header file MyFile.ch:

MyFile.ch
// begin file

Func1()

// end file


define directve:
#command CallMyFunc() => #include "MyFile.ch"; Func2()


call CallMyFunc() generate the following code in two lines separated:
Func1()
Func2()
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
danielmaximiliano
Posts: 2612
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Preprocessor question

Post by danielmaximiliano »

Claudio, cuando se necesita atar con alambre se hace
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Preprocessor question

Post by srvet_claudio »

danielmaximiliano wrote:Claudio, cuando se necesita atar con alambre se hace
Mejor expresado imposible !!!
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Preprocessor question

Post by Pablo César »

srvet_claudio wrote:
danielmaximiliano wrote:Claudio, cuando se necesita atar con alambre se hace
Mejor expresado imposible !!!
+1 Cierto ! :lol:

Claudio, disculpame estuve viajando y no pude leer este mensaje antes.

Tenés otro ejemplo ?

Porque yo entiendo que cuando en xBase hay ";" sirve para mantenerse en la misma linea. Y no como ocurre en C.

Tampoco entiendo como seria empleado.
Necesitarias que se dividan en líneas cada comando ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Preprocessor question

Post by srvet_claudio »

Pablo César wrote:Tampoco entiendo como seria empleado.
Necesitarias que se dividan en líneas cada comando ?
Yes Pablo, I needed for specific case that two functions of a #command appeared in two separate lines, this is explanation I posted in HB user forum:
The problem is that with #xcommand/#xtranslate the preprocessor always generates all the code in the same line of text separated by semicolon, for example.
a; b; c; d; etc.

Consider the following example:
line text n1: a; b; c
line text n2: d

where a, b, c and d are valid functions/sentences of Harbour.

In a debug step by step, the debugger stops at the line n1, then executes all sentences of this line (a, b, c), and after executing the last sentence (c) stops in the line n2, and so I can not make an individual debug of sentences a, b and c.

For individual debug of all sentences, I need that appears in the code:

line text n1: a
line text n2: b
line text n3: c
line text n4: d

My question is, as I do for that:

#xcommand MyCmd => a; b; c

Instead of generating:

line text n1: a; b; c

generates:

line text n1: a
line text n2: b
line text n3: c
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Preprocessor question

Post by Pablo César »

Claudio,

Esto StrTran( cText, ";", Chr( 10 ) ) iria substituir el punto y coma por quiebra de linea.

Tambien estas funciones te puedan ayudar:

hb_pp_tokenAdd
hb_pp_tokenAddNext
hb_pp_tokenAddCmdSep
hb_pp_tokenSetValue
hb_pp_pragmaStream

Las vas a encontrar en ppcore.c en el src del pp del core del Harbour.
(https://github.com/harbour/core/blob/ma ... p/ppcore.c)

Asi aLine := hb_ATokens( cLine, ";" ) vas a conseguir colocar facilmente cada comando en vector y lo puedes trabajar con hb_StrShrink(aLine,1).

Por favor prefiero que me escribas en castellano porque yo no te entiendo bien y perdemos mucho tiempo.
Quien se interese por el tema y no entienda: que pregunte ! :mrgreen:
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Preprocessor question

Post by srvet_claudio »

Pablo César wrote:Claudio,

Esto StrTran( cText, ";", Chr( 10 ) ) iria substituir el punto y coma por quiebra de linea.

Tambien estas funciones te puedan ayudar:

hb_pp_tokenAdd
hb_pp_tokenAddNext
hb_pp_tokenAddCmdSep
hb_pp_tokenSetValue
hb_pp_pragmaStream

Las vas a encontrar en ppcore.c en el src del pp del core del Harbour.
(https://github.com/harbour/core/blob/ma ... p/ppcore.c)

Asi aLine := hb_ATokens( cLine, ";" ) vas a conseguir colocar facilmente cada comando en vector y lo puedes trabajar con hb_StrShrink(aLine,1).

Por favor prefiero que me escribas en castellano porque yo no te entiendo bien y perdemos mucho tiempo.

Thanks, but not work!
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
Post Reply