Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

inserting blocks in nested blocks (was making objects from block con

 [1/2] from: rotenca::telvia::it at: 27-Jun-2002 17:58


Hi,
> line: parse full ";"
first thing i can suggest: line: parse/all full ";" --- Ciao Romano

 [2/2] from: gscottjones:mchsi at: 27-Jun-2002 11:41


Hi, Thorsten, From: "Thorsten Moeller"
<snip> > So, am going to do it with blocks and nested blocks. > > I made a large container block to put all the records in. Every record > starts with an record id, followed by a nested block containing up to
several
> blocks with date-informations, followed by three other values. > sample!!
<<quoted lines omitted: 8>>
> ["20.06.2002" "15:00:00" "1,00" "98,10"] > to the nested block in the existing record and add 1,00 to the existing
1,00
> and the 98,10 to the existing 98,10. > > the final record should look like this: > "3465436" [[["1.6.2002" "20:00:00" "1,00" "98,10"]["20.06.2002" "15:00:00" > "1,00" "98,10"]] "2,00" "196,20" "3004"] > > what happend is, for some reason i cannot find out, that the added block > overrides the existing one and is inserted a second time and the values
are not
> added. > so that the result is: > "3465436" [[["20.06.2002" "15:00:00" "1,00" "98,10"]["20.06.2002"
15:00:00
> "1,00" "98,10"]] "1,00" "98,10" "3004"] > > Here is the code <snip> > > Any ideas
I had to set up a sample file inorder to work out the details, so I commented out two lines at the top that you will need and added a data block. It appears to work. It should at least provide another alternative approach. Watch for wrapped lines. Hope it helps! --Scott Jones REBOL [] ;orders: read/lines %AusgabeCSV.txt ;if exists? %allorders.txt [delete %allorders.txt] orders: [ "3465436;01.06.2002 20:00:00;1,00;98,10;3004" "3465436;20.06.2002 15:00:00;1,00;98,10;3004" ] allorders: copy [] dates: copy [] date: copy [] foreach full orders [ line: parse full ";" either a: select/skip allorders line/1 2 [ append/only a/1/1 copy/part next line 4 change a/1/2 to-string ((to-decimal a/1/2) + (to-decimal line/4)) change a/1/3 replace trim/with to-string ((to-money a/1/3) + (to-money line/5)) "$" "." "," ][ append allorders copy line/1 append/only allorders copy reduce [ reduce [(copy/part next line 4)] copy line/4 copy line/5 copy line/6] ] ] print "Finished"

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted