Immediate IF() syntax error

Post Reply
User avatar
toyet
Posts: 39
Joined: Thu Apr 05, 2007 12:52 am
Location: Philippines

Immediate IF() syntax error

Post by toyet »

Any ideas why the red line below produces a syntax error at '('

nEmployeeMax := 33
nEmployeeCount := 0
nPageE := int(nEmployees/nEmployeeMax) + if(nEmployees % nEmployeeMax > 0, 1, 0 )
nPageC := 0


Fivewin 13.04 / Harbour 3.2.0 (rev 18881)

Thanks for any help.

Toyet
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Immediate IF() syntax error

Post by nageswaragunupudi »

If you are meaning "syntax error" while compiling, there is no such error. The statement is compiling fine for me.

If you are meaning runtime error ( i don't think that is what you meant) then please check nEmployees in already initialized with a numeric value.

Finally, the statement

Code: Select all

nPageE := int(nEmployees/nEmployeeMax) + if(nEmployees % nEmployeeMax > 0, 1, 0 )
can be simplified as

Code: Select all

nPageE := Ceiling(nEmployees/nEmployeeMax)
Regards

G. N. Rao.
Hyderabad, India
User avatar
toyet
Posts: 39
Joined: Thu Apr 05, 2007 12:52 am
Location: Philippines

Re: Immediate IF() syntax error

Post by toyet »

GN Rao,

I tried the Ceiling() function and it seems to go fine. Thank you for it.

Maybe the '%' operator for modulus division is the culprit for the error?

Toyet
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Immediate IF() syntax error

Post by nageswaragunupudi »

% operator works well with both Harbour and xHarbour with all recent versions I remember.
Regards

G. N. Rao.
Hyderabad, India
Post Reply