Microsoft
Software
Hardware
Network
Question : I need to know if I have a fraction.
I'm running Notes Designer V7.0.3. Our tellers must balance their drawers each day. I have created a database that collects this information. When they enter the coin count I would like to alert them when they have entered an invalid number for a particular coin. For example if you enter 1.20 for Nickels, you're fine; if you enter 1.21 for Nickels you're not. I know that if I divide the entered number by the integer of that number there should be no fraction.
Here is my code:
r1:=@ThisValue;
n:=@RightBack(@ThisName;"_
");
v:=@If(n="Dollars";100;@If
(n="Halves
";50;@If(n
="Quarters
";25;@If(n
="Dimes";1
0;@If(n="N
ickels";5;
r1)))));
@If(r1="";@Return(r1);@Suc
cess);
a1:=(r1*100)/v;
o2:=@Integer(a1);
o1:=a1-o2;
@If(o1=0;r1;@Prompt([Ok];n
+" Error";"Incorrect value for "+n));
r1
------------
When I enter certain values, such as 1.20, I get my error message indication the entry is invalid when in fact it is.
The variables contain the following values (as they are presented in a @Prompt.
r1=1.20
n=Nickels
v=.05
a1=24
02=23
01=0.999999999999996
I assume this is because of some setting on the server.
What do I need to do to solve my problem?
Is there an @Command or a set of Script instructions?
Thansk in advance,
Richard
Answer : I need to know if I have a fraction.
Probably because you're truncating a1 with the call to @Integer.
Try using @Modulo to get the remainder instead of doing your own math.
@If(@Modulo(r1*100; v) != 0; @Prompt([OK]; n+" Error";"Incorrect value for "+n); "");
Random Solutions
How to mark the current line in a Excel spreadsheet?
Designing Windows 2008 Terminal Server to run under VMWare
Coldfusion case sensitivity question
Maximizer Enterprise 9.5 ODBC / Btrieve Err 11 Error
ASP.net GridView Multi Select with Ctrl
Java FTPSClient Connection timeout
Problem with Crystal Reports Numbers Format
Left and right sidebars stuck in middle of site
Something simple I can do with smtp in php.ini so all emails come to me, in a testing environment?
Do memory and binary fields slow performance?