1. Re: ex.exe hangs in a while loop (final solution)
- Posted by olddog <halletts at sasktel.net> Jul 12, 2006
- 480 views
- Last edited Jul 13, 2006
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!