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

A bug in file port?

 [1/4] from: gmassar:dreamsoft at: 18-Sep-2000 14:18


As per Core User's Guide 2.2.0, on "Ports Access to Files" page at section "Line Access", I tried as follows:
>> fp: open/lines %file.txt >> print first fp
I wanted the gold, and I got it --
>> forall fp [if find first fp "gold" [print first fp]]
I wanted the gold, and I got it -- And somehow the gold isn't all. == false
>>
All seems going well. For my curiosity, I repeated the last statement:
>> forall fp [if find first fp "gold" [print first fp]]
== none Opps. fp must be at its tail. So, I tried:
>> tail? fp
== true
>> head fp >> head? fp
== false It puzzled me! Is it a bug or is it me? I am still relatively new to REBOL in spite of my lonnnng experience in programming. Geo Massar Veteran programmer

 [2/4] from: rebol::techscribe::com at: 18-Sep-2000 14:50


Hi Geo, you're doing great! You overlooked one little detai: replace
>> head fp
by
>>fp: head fp
The head function RETURNS the same port whose current position is at the head of the port. It does not modify the current position of its argument! Hope this helps, At 02:18 PM 9/18/00 -0700, you wrote:
>As per Core User's Guide 2.2.0, on "Ports Access to Files" page >at section "Line Access", I tried as follows:
<<quoted lines omitted: 22>>
>Geo Massar >Veteran programmer
;- Elan [ : - ) ] author of REBOL: THE OFFICIAL GUIDE REBOL Press: The Official Source for REBOL Books http://www.REBOLpress.com visit me at http://www.TechScribe.com

 [3/4] from: gmassar:dreamsoft at: 18-Sep-2000 15:21


Yep, it works! Should have read the description more closely. Thanks, Elan! Geo... PS I just got your book. It looks good at first sight. :) [rebol--techscribe--com] wrote:

 [4/4] from: rebol:techscribe at: 18-Sep-2000 16:55


Hi Geo, then I recommend you skip to Chapter 21 (page 673). It's all about ports. (Specifially page 677 bottom says: We can return fp to the head of file with the head function: fp: head fp } In case you haven't discovered it yet, I'll think you'll find the detailed review of the open function (pp. 678) quite enlightening. It reviews the port object that is returned by the open function in some detail. At 03:21 PM 9/18/00 -0700, you wrote:
>Yep, it works! Should have read the description more closely. >Thanks, Elan!
<<quoted lines omitted: 24>>
>> http://www.REBOLpress.com >> visit me at http://www.TechScribe.com
;- Elan [ : - ) ] author of REBOL: THE OFFICIAL GUIDE REBOL Press: The Official Source for REBOL Books http://www.REBOLpress.com visit me at http://www.TechScribe.com

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