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

SKIPping in a file

 [1/5] from: g::santilli::tiscalinet::it at: 9-Jul-2001 16:04


Hello Joel! On 08-Lug-01, you wrote: JN> readtail: func [fn [file!] n [integer!] /local sz rp fi JN> mybuf] [ JN> sz: get in info? fn 'size JN> rp: sz + 1 - n JN> print [sz rp] JN> fi: open/binary/direct fn JN> fi: skip fi rp JN> mybuf: copy/part fi n JN> close fi JN> mybuf JN> ] SKIP has always been broken on /DIRECT ports AFAIK (at least, I was never able to make it work). The workaround is using COPY/PART. readtail: func [fn [file!] n [integer!]] [ fn: open/binary/direct fn copy/part fn fn/size - n first reduce [copy/part fn n close fn] ] (NOT TESTED) JN> again shows the correct size/readpoint calculations, but JN> always returns the *first* N bytes of the file, not the JN> *last* N bytes. OPEN/SKIP also seems to give problems, on files at least. (If it worked, you could have replaced your functions with READ/DIRECT/PART and READ/DIRECT/SKIP --- well, the first works anyway). JN> Am I misreading R/CUG or doing something boneheaded here? Or JN> are /SKIP and SKIP broken in View 1.2.0.4.2 ? I'd like to know, too... Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/

 [2/5] from: joel:neely:fedex at: 9-Jul-2001 14:45


Hi, Gabriele, Gabriele Santilli wrote:
> SKIP has always been broken on /DIRECT ports AFAIK (at least, I > was never able to make it work). The workaround is using
<<quoted lines omitted: 5>>
> ] > (NOT TESTED)
Well, it is now! (at least partially :) A quick check against my test files showed the expected result. Of course, it actually has to read through the part to be skipped, instead of just repositioning past it, which has a noticeable effect after a few megabytes...
> OPEN/SKIP also seems to give problems, on files at least... >
..
> I'd like to know, too... >
Thanks for the confirmation, and for the work-around! <sigh> I was really hoping you'd tell me that I hadn't read the the User Guide properly, and then send me a one-line correction to my broken script! ;-) </sigh> -jn- --------------------------------------------------------------- There are two types of science: physics and stamp collecting! -- Sir Arthur Eddington joel-dot-neely-at-fedex-dot-com

 [3/5] from: joel:neely:fedex at: 9-Jul-2001 14:59


Hi, Gabriele, Gabriele Santilli wrote:
> SKIP has always been broken on /DIRECT ports AFAIK (at least, I > was never able to make it work). The workaround is using
<<quoted lines omitted: 5>>
> ] > (NOT TESTED)
Well, it is now! (at least partially :) A quick check against my test files showed the expected result. Of course, it actually has to read through the part to be skipped, instead of just repositioning past it, which has a noticeable effect after a few megabytes...
> OPEN/SKIP also seems to give problems, on files at least... >
..
> I'd like to know, too... >
Thanks for the confirmation, and for the work-around! <sigh> I was really hoping you'd tell me that I hadn't read the the User Guide properly, and then send me a one-line correction to my broken script! ;-) </sigh> -jn- --------------------------------------------------------------- There are two types of science: physics and stamp collecting! -- Sir Arthur Eddington joel-dot-neely-at-fedex-dot-com -- --------------------------------------------------------------- There are two types of science: physics and stamp collecting! -- Sir Arthur Eddington joel-dot-neely-at-fedex-dot-com

 [4/5] from: g:santilli:tiscalinet:it at: 10-Jul-2001 18:53


Hello Joel! On 09-Lug-01, you wrote: JN> Well, it is now! (at least partially :) A quick check against ;-) JN> my test files showed the expected result. Of course, it JN> actually has to read through the part to be skipped, instead JN> of just repositioning past it, which has a noticeable effect JN> after a few megabytes... Yup... too bad... :-/ JN> <sigh> I was really hoping you'd tell me that I hadn't read JN> the the User Guide properly, and then send me a one-line JN> correction to my broken script! ;-) </sigh> I'm still hoping Holger pops here and says us "you bonehead! this is the way to do it!". ;-) Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/

 [5/5] from: joel:neely:fedex at: 8-Jul-2001 5:55


Hello, all! Since Jeff had motivated me to dig out R/CUG2.3 and read up on /DIRECT, I thought I'd take a shot at revising the "line reduction" script for Aaron to read only the amount of data necessary for the sample. (Not that I've ever been known to run an idea into the ground! ;-) In the course of playing with that idea, I ran into a puzzler that I haven't sorted out yet. Any suggestions would be most welcome! This function readhead: func [fn [file!] n [integer!] /local fi mybuf] [ fi: open/binary/direct fn mybuf: copy/part fi n close fi mybuf ] seems to do what I want -- read/return the first N bytes from FN (as a BINARY! value, of course, but that's a non-issue for the task at hand). However, *this* function readtail: func [fn [file!] n [integer!] /local sz rp fi mybuf] [ sz: get in info? fn 'size rp: sz + 1 - n print [sz rp] fi: open/binary/direct fn fi: skip fi rp mybuf: copy/part fi n close fi mybuf ] seems to perform the calculations for where to position into the file (as witnessed by the debugging output from the first three lines), but then hangs (immune to the escape key). It's burning CPU cycles furiously according to top, but at least responds to kill -15. Trying a different approach, *this* function readtailx: func [fn [file!] n [integer!] /local sz rp fi mybuf] [ sz: get in info? fn 'size rp: sz + 1 - n print [sz rp] fi: open/direct/binary/skip fn rp mybuf: copy/part fi n close fi mybuf ] again shows the correct size/readpoint calculations, but always returns the *first* N bytes of the file, not the *last* N bytes. Am I misreading R/CUG or doing something boneheaded here? Or are /SKIP and SKIP broken in View 1.2.0.4.2 ? -jn- --------------------------------------------------------------- There are two types of science: physics and stamp collecting! -- Sir Arthur Eddington joel-dot-neely-at-fedex-dot-com

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