Using #define funtion

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

Post Reply
raymanw
Posts: 25
Joined: Tue Mar 08, 2011 1:16 am

Using #define funtion

Post 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.
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Using #define funtion

Post by Rathinagiri »

Hi,

Can you show the exact definition part in .ch file?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3723
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Using #define funtion

Post by mol »

When you define something with #define you must remeber that all is case sensitive.
Am I wrong? :lol:
raymanw
Posts: 25
Joined: Tue Mar 08, 2011 1:16 am

Re: Using #define funtion

Post 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.
User avatar
mol
Posts: 3723
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Using #define funtion

Post by mol »

Why don't you simply declare this function without #define ???
I can't understand reasons of this declaration.
Marek
raymanw
Posts: 25
Joined: Tue Mar 08, 2011 1:16 am

Re: Using #define funtion

Post 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.
Post Reply