Preprocessor question

This forum is for general support of Xbase++
Post Reply
Message
Author
Andy Edward
Posts: 103
Joined: Fri Sep 17, 2010 2:58 am

Preprocessor question

#1 Post by Andy Edward »

Hi everyone,

I need to change numerous code which have a pattern like this:

Code: Select all

TOTAL=CASH->(TODAY+YESTERDAY+TOMORROW)


Into

Code: Select all

TOTAL=oDataSetCASH:FieldGet('TODAY') + oDataSetCASH:FieldGet('YESTERDAY') + oDataSetCASH:FieldGet('TOMORROW')
I've put in the search and replacement rule in my .CH like this:

Code: Select all

#xtranslate =<table>->(<field>[+<fieldsN>]) => =oDataSet<table>:FieldGet(#<field>)[ + oDataSet<table>:FieldGet(#<fieldsN>) ]
But the resulting .ppo come out like this :

Code: Select all

TOTAL=oDataSetCASH:FieldGet('TODAY') + oDataSet CASH:FieldGet('YESTERDAY') + oDataSet CASH:FieldGet('TOMORROW')
Notice the space after oDataset on the second and third iteration.

Can anyone shed a light on why is there a space between oDataset and CASH?

Regards,

Andy

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Preprocessor question

#2 Post by rdonnay »

I have seen this problem before, but I don't recall how I resolved it, or if I ever did.
The eXpress train is coming - and it has more cars.

Andy Edward
Posts: 103
Joined: Fri Sep 17, 2010 2:58 am

Re: Preprocessor question

#3 Post by Andy Edward »

Hi,

I managed to get it to work with a work around. Not a very elegant solution, but at least it will work for now.

In the .CH file put this

Code: Select all

#xtranslate =<table>->(<field>[+<fieldsN>]) => =KEYWORD <table>:FieldGet(#<field>)[ +  KEYWORD <table>:FieldGet(#<fieldsN>) ]
and right after that, put in

Code: Select all

#xtranslate KEYWORD <table> => oDataSet<table>
Of course, KEYWORD can be changed to anything that is more distinct.

If anyone have a better solution, I would love to hear it.

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Preprocessor question

#4 Post by rdonnay »

That's brilliant.

I worked on it for awhile last night with no success.
The eXpress train is coming - and it has more cars.

Andy Edward
Posts: 103
Joined: Fri Sep 17, 2010 2:58 am

Re: Preprocessor question

#5 Post by Andy Edward »

Hi everyone,

I need advice on a particular code that I need to change using the pre processor

For example:

.PRG looks like this

Code: Select all

IF &xALIAS->PERIOD#MPERIOD2 .OR. &xALIAS->STATUS='C' .OR. &xALIAS->TRCDE#'0' 
ENDIF 

IF xARRAY[xP,aORDQTY]=INVENTORY->QOH+xARRAY[xP,oORDQTY] .AND. xARRAY[xP,aORDQTY] # 0
endif
.CH looks like this

Code: Select all

#xtranslate IF <table>-><field>#<something> =>                                  ;
            IF <table>:FieldGet(#<field>) \# <something> 
#xtranslate .OR. <table>-><field>=<something> =>                                ;
            .OR. <table>:FieldGet(#<field>)=<something> 
#xtranslate .OR. <table>-><field> \# <something> =>                             ;
            .OR. <table>:FieldGet(#<field>) \# <something> 
#xtranslate .AND. <table>-><field>=<something> .OR. =>                               ;
            .AND. <table>:FieldGet(#<field>)=<something> .OR. 
the resulting .ppo look like this

Code: Select all

IF &xALIAS:FieldGet("PERIOD") # MPERIOD2 .OR. &xALIAS:FieldGet("STATUS='C' .OR. &xALIAS->TRCDE") # '0'   
ENDIF 

IF xARRAY[xP,aORDQTY]=INVENTORY:FieldGet("QOH+xARRAY[xP,oORDQTY] .AND. xARRAY[xP,aORDQTY]") # 0
ENDIF 
BUT what I need is like this

Code: Select all

IF &xALIAS:FieldGet("PERIOD") # MPERIOD2 .OR. &xALIAS:FieldGet("STATUS")='C' .OR. &xALIAS:FieldGet("TRCDE") # '0'   
ENDIF 

IF xARRAY[xP,aORDQTY]=INVENTORY:FieldGet("QOH") +xARRAY[xP,oORDQTY] .AND. xARRAY[xP,aORDQTY] # 0
ENDIF
I need some pointers about using pre-processor for this kind of replacement.

As the number of code that need to be changed is quite a lot (4-5 months worth of work if to change manually), am I approaching this issue the right way (by using pre-processor)?

OR

Is it possible to create a generic translate command that can handle any number .AND., .OR., and arithmatic operators?

Say I have a

Code: Select all

IF A->B + C -A->D * E=<memvariable> .AND. A->F > 0
that needs to be translated into

Code: Select all

IF A:FieldGet('B') + C - A:FieldGet('D') * E=<memvariable> .AND. A:FieldGet('F') > 0
, Is it possible to create just one line of #translate to handle it?

Any pointers on how I can approach this issue, will be greatly appreciated.

Best Regards,

Andy Edward Gunawan

Post Reply