Click to See Complete Forum and Search --> : New to OPL a couple of Questions


Kennygza
03-25-2003, 12:57 PM
Hi Guy's , i have two questions for ya, relating to OPL



1) I'm new to OPL so please excuse this question if it sounds silly .Can anyone tell be where i can find the codes for for colours, ( or just the 16 colours), & can one write them in opl by their name, as one can do in Html for instance "yellow" or "light yellow"

2) I started writing a little programe for work , but have not got too far, as when the VAT is added to the Basic Selling Price, it does not put in the Decimals, but just seems to roundthe figure off.
Also when i do manage to get the figure into decimals, how would i tell it to round the figure off to two decimal places.

Thank you
kennygza

ktkawabe
03-27-2003, 07:47 AM
Hi kennygza,

1) Please get the OPL manual (for example in PsiWin CD) or OPL SDK documentation. Then see gCOLOR, gCREATE and DEFAULTWIN.

2a) As for the figure rounded off. I guess you are actually talking about truncating (3.9 becomes 3 if truncated and 4 if rounded)?? If so, are you using integer variable (like "price%" or "price&" instead of "price") for your final price? If that's not the case, please post your code fragments.

2b) As for rounding figure to 2 decimal places, your code would become something like this:
withVAT = INT( (withVAT+0.005)*100 )/100.0

If you want to truncate rather than round you don't have to add 0.005. The idea here is not at all OPL-specific. Shift decimal point, cast to integer to round or truncate, cast to floating point and shift decimal point back to the original position.

If it's only a matter of printing, see FIX$ in the manual.

Cheers,
Keita

ktkawabe
03-27-2003, 07:56 AM
Please note that the above mentioned method of adding 0.005 for rounding doesn't work for negative value (e.g. withVAT=-20.579), though I'm quite sure you don't have to worry about negative prices.

Keita