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

How to form a block containing two Rebol filenames?

 [1/7] from: psa102:toward at: 17-Aug-2004 23:20


Can someone suggest how I can convert two words containing REbol filenames to a block consisting of those two Rebol filenames? This script is this: - - - - - - - - - - - REBOL [ header omitted.... ] arguments: parse system/script/args none addressfile: to file! system/options/args/1 messagefile: to file! system/options/args/2 attachfiles: to file! system/options/args/3 message: read messagefile members: load/all addressfile attachments: load/all attachfiles firstfile: to file! first attachments nextfile: to file! second attachments print ["filenames=" mold firstfile "nextfile=" mold nextfile ] filenames: join firstfile " " filenames: join filenames nextfile to block! filenames print ["filenames=" mold filenames ] send/attach members message filenames - - - - - - - - - - - As shown by the output above, the two filenames, firstfile and nextfile are loaded correctly in to the words firstfile and nextfile. The issue is how can these two words be joined into a _block_ consisting of the two filenames. The send command requires a block of Rebol filenames as the value of the 'filenames word. Thank you. John Wirt Component: "System Port" 1.1.2.5 (30-Sep-2003/16:57:26) Script: "User Preferences" (20-May-2001/21:08:16-4:00) Script: "Send message with attachment script 10" (8-Aug-2004) filenames= %test1.txt nextfile= %test2.txt filenames= %test1.txt test2.txt ** Access Error: Cannot open /D/Rebol/test1.txt test2.txt ** Where: build-attach-body ** Near: val: read/binary file

 [2/7] from: moliad:aei:ca at: 17-Aug-2004 23:38


PSA102 wrote:
> Can someone suggest how I can convert two words containing REbol > filenames to a block consisting of those two Rebol filenames?
fileblock: reduce [ firstfile nextfile ] reduce is a very usefull in that it replaces a word by its value. Note that reduce also evaluates any code in that block so you could also have done: stringblk: reduce [ to-string firstfile to-string nextfile ] HTH -MAx

 [3/7] from: AJMartin:orcon at: 18-Aug-2004 15:31


> The issue is how can these two words be joined into a _block_ consisting
of the two filenames. Would something like this be OK?
>> FirstFile: %test1.txt
== %test1.txt
>> SecondFile: %test2.txt
== %test2.txt
>> MyBlock: reduce [FirstFile SecondFile]
== [%test1.txt %test2.txt] -- Andrew J Martin ICQ: 26227169 http://www.rebol.it/Valley/ http://valley.orcon.net.nz/ http://valley.150m.com/

 [4/7] from: moliad:aei:ca at: 17-Aug-2004 23:44


Maxim Olivier-Adlhoch wrote:
> reduce is a very usefull in that it replaces a words [ within a block ] by its value. >> help reduce
USAGE: REDUCE value DESCRIPTION: Evaluates an expression or block expressions and returns the result. REDUCE is a native value. ARGUMENTS: value -- (Type: any) HTH -MAx

 [5/7] from: psa102:toward at: 18-Aug-2004 1:06


Thank you, Maxim and A. J. The script works. Now, I need to modify it to handle a list of "n" files in the input series, attachfiles. John Wirt

 [6/7] from: greggirwin::mindspring::com at: 17-Aug-2004 23:59


Hi John, Sounds like you're making good progress! JW> attachments: load/all attachfiles JW> firstfile: to file! first attachments JW> nextfile: to file! second attachments Not knowing what some of your data files look like, here's something that took me a while to learn when I started with REBOL: exploit its datatypes and LOAD for all they're worth. In this case, that means formatting your data in attachfiles so the values are already file! values; that way you don't need to use "to file!" to coerce them. Whenever I find myself using strings and then casting values to other datatypes, I try to stop and rethink things. It's amazing what a difference this all makes in the long run. Your data becomes more descriptive, your code shrinks, and things read much more naturally. As you move to handling n files, it will be a great way to learn more about series values and functions that operate on them. Happy REBOLing! -- Gregg

 [7/7] from: SunandaDH:aol at: 18-Aug-2004 3:31


John:
> The script works. Now, I need to modify it to handle a list of "n" files in > the input series, "attachfiles."
Your original code suggests the script is invoked something like this: rebol -s myscript.r file1 file2 file3 file4 file5 ... where file3 and upwards will be the attach files. If so, your problem becomes one of running a loop from the 3rd entry of system/options/args. Something like this: attachfiles: copy [] foreach file-name next next system/options/args [ append attachfiles to-file file-name ] Sunanda