Page 1 of 1

Using #define funtion

Posted: Mon Mar 14, 2011 9:29 am
by raymanw
Hi all,

I defined a function(?) ItemAmt in calculate.ch file. Include the file in the module I want to use the function. ie. #include "calculate.ch"

I can compile & generate an exe successfully. But when I open the form it gives me "Error BASE/1001 Undefined function: ITEMAMT".

What am I missing?

Thanks.

Re: Using #define funtion

Posted: Mon Mar 14, 2011 10:14 am
by Rathinagiri
Hi,

Can you show the exact definition part in .ch file?

Re: Using #define funtion

Posted: Mon Mar 14, 2011 9:36 pm
by mol
When you define something with #define you must remeber that all is case sensitive.
Am I wrong? :lol:

Re: Using #define funtion

Posted: Tue Mar 15, 2011 2:41 am
by raymanw
Hi Rathinagiri,

This is in my calculate.ch file:
#define ItemAmt(weight, price, length, workmanshp, amount) Iif(amount = 0, Iif(weight != 0, weight * price, 0) + Iif(length = 0, workmanshp, workmanshp * length), amount)

I call it as an item in the COLUMNFIELDS of a grid.
'ItemAmt(Iif(StkItem->orig_qty=0, StkItem->weight, StkTrans->weight), GetPurcPrice(StkTrans->g_type, StkTrans->i_type, StkTrans->item), Iif(StkItem->orig_qty=0, StkItem->length, 0), Iif(StkItem->orig_qty=0, StkItem->workmanshp, StkTrans->workmanshp), Iif(StkItem->orig_qty=0, StkItem->amount, 0))'

Hi Mol,
I do matching the case when using.

Thanks.

Re: Using #define funtion

Posted: Tue Mar 15, 2011 1:12 pm
by mol
Why don't you simply declare this function without #define ???
I can't understand reasons of this declaration.
Marek

Re: Using #define funtion

Posted: Wed Mar 16, 2011 1:32 am
by raymanw
Hi Mol,

Yes. I came to that conclusion as well. This is a piece of old Clipper code. I would still be interested to see how it should be under Harbour. But I think I should post this in the Harbour forum/group rather than under HMG's.

Thanks.