Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Strange behavior with double variables
#1
Hi, what happens in this macro? It shows 'Amount=0.06' and the data type is double, so I don't understand what is going on.

Any help, please?


Macro WhatHappens
Code:
Copy      Help
str List

List=
;*** FirstLine ***
;John: sells
;Tony: sells
;Mike: pays1 $0.02
;Rose: sells
;Alex: sells
;Mary: pays1 $0.01
;Doug: sells2
;*** LastLine ***

int FirstLine LastLine

FirstLine=0
LastLine=8

double Amount

Amount=0.03

Calculate FirstLine LastLine List Amount
;Amount=0.06

out
out "Amount: %.5G" Amount

if Amount=0.06;; <<<<<<<<<< ERROR <<<<<<<<<<
,out "OK"
else out "ERROR!"

Function Calculate
Code:
Copy      Help
function int'FirstLine int'LastLine str'List double&Amount

int i pos offset
double paid AmountAux
str a s sline

AmountAux=Amount

for i FirstLine LastLine
,sline.getl(List i)
,pos=findrx(sline " pays1 | notinterested | outofservice " 0 0 a)
,if pos<>-1
,,s.left(sline pos-1)
,,sel a
,,,case " pays1 "         : offset=8
,,,case " notinterested " : offset=7
,,,case " outofservice "  : offset=5
,,s.get(sline pos+offset)
,,if s="0.02"
,,,paid=0.02
,,if s="0.01"
,,,paid=0.01
,,AmountAux+paid

Amount=AmountAux


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)