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

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

Hello again,

My first solution is to get Rob to fix 'find' so that it can
start ANYWHERE within the sequence...
  pos=find(10,'$',string)
whould start the search at position 10.

Anyway, without that here is my solution.  Note that the
offset only has to be adjusted ONE TIME only...


include get.e

with trace
trace(1)

procedure main()
  integer price, pos, os
  sequence text, t
  text="/GRVY $.75 /GRVY $.75    /this $1.20 /that $.80"
  price=0
  os=find('$', text)
  pos=os
  os+=1 --only have to adjust the 'offset' once!
  while pos do
    t=value(text[os..length(text)])
    if t[1]=GET_SUCCESS then
      price+=t[2]*100
    end if
    pos=find('$',text[os..length(text)])
    os+=pos
  end while
end procedure
main()


If you prefer you can adjust text each time to make it get
smaller and smaller as more 'prices' are found.




Take care,
Al

E boa sorte com sua programacao Euphoria!


My bumper sticker: "I brake for LED's"

 From "Black Knight":
"I can live with losing the good fight,
 but i can not live without fighting it".
"Well on second thought, maybe not."

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

Search



Quick Links

User menu

Not signed in.

Misc Menu