Re: ex.exe hangs in a while loop (final solution)

new topic     » topic index » view thread      » older message » newer message

Oops again! Minor correction to my "fixed" logic:

incude get.e
procedure main()
  integer crsr, price, offset
  sequence text, t
  text = "/GRVY $.75 /GRVY $.75"
  price = 0
  offset = 0
  crsr = find('$', text)
  while crsr do
    t = value(text[crsr+offset+1..$])
    if t[1] = GET_SUCCESS then
      price += floor(t[2]*100) -- ensure truncating to an integer
    end if
  offset = crsr
  crsr = find('$', text[offset+1..$])
  end while
end procedure


 From what I can tell, this is pretty much the same as Al Getz's solution,
except from what it appears, the 2nd value() will try to evaluate starting
at the $, so I think the os+=1 actually needs to go inside the loop at the
top. Yes? No? (But using "pos" now makes more sense as a variable name than
"crsr", eh?)

BTW, the "/GRVY" means add gravy to the order at $.75 per. It's part of a
little restaurant POS I put together for my father-in-law's fish&chip place.
(Great fish.) I use integers for handling the money to avoid rounding errors.

Thanks again everybody!

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu