How to return the pre-processed version of a command?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
HGAutomator
Posts: 195
Joined: Thu Jul 16, 2020 5:42 pm
DBs Used: DBF

How to return the pre-processed version of a command?

Post by HGAutomator »

Hi,

Programmatically, how do I get back the functional (i.e. pre-processed) version of a command?

I tried using e.g.

Code: Select all

p_p := __pp_Init()

Command_s := "SET MARGIN TO"

Preprocessed_s := __pp_Process( p_p, Command_s )
, which I thought should return

Code: Select all

Set( _SET_MARGIN, 0 )
, but it just returns the original command.

Maybe I'm setting it up wrong.
User avatar
gfilatov
Posts: 1079
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: How to return the pre-processed version of a command?

Post by gfilatov »

HGAutomator wrote: Thu May 02, 2024 10:42 pm Hi,

Programmatically, how do I get back the functional (i.e. pre-processed) version of a command?
...
Maybe I'm setting it up wrong.
Hi,

Please add the following line on top of your test program:
REQUEST __pp_StdRules
You can look at the following working example:

Code: Select all

REQUEST HB_GT_WIN_DEFAULT
REQUEST __pp_StdRules

PROCEDURE Main()

   LOCAL cString

   LOCAL pPP := __pp_Init()

   CLS

   ? "Testing Harbour run-time preprocessing"
   ?

   ? cString := "@ 10, 10 SAY 'Hello!'"
   ? __pp_Process( pPP, cString )
   ?

   ? cString := "? 'Hello mom'"
   ? __pp_Process( pPP, cString )
   ?

   ? cString := "SET MARGIN TO Something"
   ? __pp_Process( pPP, cString )
   ?

   WAIT

   RETURN
Program output is below: :arrow:
capture.png
capture.png (6.87 KiB) Viewed 308 times
Hope this is helpful. :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
HGAutomator
Posts: 195
Joined: Thu Jul 16, 2020 5:42 pm
DBs Used: DBF

Re: How to return the pre-processed version of a command?

Post by HGAutomator »

That did the trick, thanks Grigory.
HGAutomator
Posts: 195
Joined: Thu Jul 16, 2020 5:42 pm
DBs Used: DBF

Re: How to return the pre-processed version of a command?

Post by HGAutomator »

Everything is working perfectly, much appreciated.

Do you know how we would preprocess non-standard custom commands defined in other .ch files?
Post Reply