Same block, different formats
[1/4] from: ddalley::idirect::com at: 13-Oct-2001 21:42
Hi:
I have REBOL read a directory, to get a block of file names. I want to make
two different uses of that file list.
When the block is printed to the console, the list of names is separated by
a space. The rest of the script interprets the block of names, in memory, as
having separate elements, too, so the script works.
A AA AAC AAPL ABC ABF ABGX ABI ABK ABS ABT ABX ACK ACV...
When the block is written to a file and that file is read with a text reader
or editor, though, the names are one long, continuous string. This format is
obviously useless to me.
AAAAACAAPLABCABFABGXABIABKABSABTABXACKACV...
Why, and what can I do to ensure that the written block is space separated?
The only difference is in how the block is presented.
In both cases, the block is the same block.
--
---===///||| Donald Dalley |||\\\===---
The World of AmiBroker Support
http://webhome.idirect.com/~ddalley
UIN/ICQ#: 65203020
[2/4] from: carl:cybercraft at: 14-Oct-2001 15:41
On 14-Oct-01, Donald Dalley wrote:
> Hi:
> I have REBOL read a directory, to get a block of file names. I want
<<quoted lines omitted: 11>>
> separated? The only difference is in how the block is presented. In
> both cases, the block is the same block.
Use 'save (and 'load) instead of 'write (and 'read) to preserve your
data's format...
>> write %test.txt [%aaa %bbb %ccc]
>> read %test.txt
== "aaabbbccc"
>> save %test.txt [%aaa %bbb %ccc]
>> load %test.txt
== [%aaa %bbb %ccc
]
--
Carl Read
[3/4] from: joel:neely:fedex at: 13-Oct-2001 22:11
Hi, Donald,
Donald Dalley wrote:
> I have REBOL read a directory, to get a block of file names. I want
> to make two different uses of that file list.
>
...
> When the block is written to a file and that file is read with a
> text reader or editor, though, the names are one long, continuous
<<quoted lines omitted: 3>>
> separated? The only difference is in how the block is presented.
> In both cases, the block is the same block.
This works for me.
>> foo: read %./
== [%ArchVision.doc %Combined Vision.doc %Future Vision.doc
%Combined Vision1a.doc %allstate1.xls %expen...
>> write/lines/with %tempkill.foo foo "^/"
The effect is to place each file name on a separate line, which
takes care of ambiguities if the file names contain embedded
spaces.
-jn-
--
; sub REBOL {}; sub head ($) {@_[0]}
REBOL []
# despam: func [e] [replace replace/all e ":" "." "#" "@"]
; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"}
print head reverse despam "moc:xedef#yleen:leoj" ;
[4/4] from: ddalley:idirect at: 14-Oct-2001 16:45
Hi, Carl:
On 14-Oct-01, Carl Read wrote:
> Use 'save (and 'load) instead of 'write (and 'read) to preserve your
> data's format...
<<quoted lines omitted: 5>>
> == [%aaa %bbb %ccc
> ]
Yup, that works.
I always wondered when/why I would need 'save & 'load.
Thanks for straightening me out.
--
---===///||| Donald Dalley |||\\\===---
The World of AmiBroker Support
http://webhome.idirect.com/~ddalley
UIN/ICQ#: 65203020
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted