Jump to content

Numeric comparison problem


ChrisJ
 Share

Recommended Posts

Hi,

I have a script which (in part) reads a file and extracts values, summing them into two variables. At the end of the run, the two total values are compared and only of they are correct is the file moved to an input folder for another system.

The code (extract) is as below.

$TktM3 = 0.0

$OrdM3 = 0.0

while 1 ' Loop thru file reading into $rec

$temp = StringMid($rec,$OrdSizeStart,$OrdSizeLen)

$OrdM3 = $OrdM3 + number(StringStripWS($temp,8))

$temp = StringMid($rec,$TktSizeStart,$TktSizeLen)

$TktM3 = $TktM3 + Number(StringStripWS($temp,8))

Wend

Wlog("Order file processing for " & $ORD_DATE & " has finished - " & $ORD_COUNT & " Orders processed (" & $OrdM3 & "M3)")

Wlog("Ticket file processing for " & $TKT_DATE & " has finished - " & $TKT_COUNT & " Tickets processed (" & $TktM3 & "M3)")

$Diff = Number(Round($ORDM3)-Round($TktM3))

If $Diff = 0 Then

SendToSAP($SAPBASE)

Else

wlog("*** Quantity imbalance (" & $Diff & ") - not moving to SAP Folder ***")

SendToSAP($XSAPBASE)

EndIf

The results are shown in this extract from the log file.

2006-11-02 01:25:00 : Order file processing for 20061101 has finished - 79 Orders processed (651.5M3)

2006-11-02 01:25:00 : Ticket file processing for 20061101 has finished - 151 Tickets processed (651.5M3)

2006-11-02 01:25:00 : *** Quantity imbalance (-1) - not moving to SAP Folder ***

You can see that the two values are at least lexically identical. Why does my script (sometimes) return a $Diff of 1 or -1?

Any help would be appreciated.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...