[REBOL] Re: Directory
Chris Siegle wrote: Why is it I cannot make a directory from an assigned variable name? testVariable: 12312323 make-dir %testVariable make-dir to-file testVariable if you want to create a Directory names 12312323 (there must be other ways though. :) ). The way you do it, REBOL doesn't recognize the word testVariable but considers the variable %testVariable of type file!. -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject.
[REBOL] Re: Directory
The answer might be make-dir to-file testVariable Steven White City of Bloomington 1800 W Old Shakopee Rd Bloomington MN 55431-3096 USA 952-563-4882 (voice) 952-563-4672 (fax) [EMAIL PROTECTED] [EMAIL PROTECTED] 01/14/04 08:44AM Why is it I cannot make a directory from an assigned variable name? testVariable: 12312323 make-dir %testVariable -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject. -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject.
[REBOL] Re: Directory
Hi, Chris, Chris Siegle wrote: Why is it I cannot make a directory from an assigned variable name? testVariable: 12312323 make-dir %testVariable The argument to MAKE-DIR should be a FILE! or URL! value, not a STRING! value. ? make-dir USAGE: MAKE-DIR path /deep DESCRIPTION: Creates the directory structure specified. MAKE-DIR is a function value. ARGUMENTS: path -- (Type: file url) REFINEMENTS: /deep (SPECIAL ATTRIBUTES) catch therefore, testVariable: 12312323 make-dir to-file testVariable should work for you (assuming you have write permissions in the current directory). -jn- -- -- Joel NeelyjoelDOTneelyATfedexDOTcom 901-263-4446 Enron Accountingg in a Nutshell: 1c=$0.01=($0.10)**2=(10c)**2=100c=$1 -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject.
[REBOL] Re: Directory
Thank you for everyone's assistance! -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Joel Neely Sent: Wednesday, January 14, 2004 10:39 AM To: [EMAIL PROTECTED] Subject: [REBOL] Re: Directory Hi, Chris, Chris Siegle wrote: Why is it I cannot make a directory from an assigned variable name? testVariable: 12312323 make-dir %testVariable The argument to MAKE-DIR should be a FILE! or URL! value, not a STRING! value. ? make-dir USAGE: MAKE-DIR path /deep DESCRIPTION: Creates the directory structure specified. MAKE-DIR is a function value. ARGUMENTS: path -- (Type: file url) REFINEMENTS: /deep (SPECIAL ATTRIBUTES) catch therefore, testVariable: 12312323 make-dir to-file testVariable should work for you (assuming you have write permissions in the current directory). -jn- -- -- Joel NeelyjoelDOTneelyATfedexDOTcom 901-263-4446 Enron Accountingg in a Nutshell: 1c=$0.01=($0.10)**2=(10c)**2=100c=$1 -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject. -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject.
[REBOL] Re: Directory
-Original Message- From: Juan-carlos MIRANDA [mailto:[EMAIL PROTECTED] make-dir %testVariable make-dir to-file testVariable also note that a word is of a file! datatype, then you can use it as the base of a path like so: root: %/c/tmp/ root/filename.txt == %/c/tmp/filename.txt -MAx -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject.
[REBOL] Re: Directory
Does the same hold true for write/binary? Example: Temp: FILENAME.TXT write/binary Temp data -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Joel Neely Sent: Wednesday, January 14, 2004 10:39 AM To: [EMAIL PROTECTED] Subject: [REBOL] Re: Directory Hi, Chris, Chris Siegle wrote: Why is it I cannot make a directory from an assigned variable name? testVariable: 12312323 make-dir %testVariable The argument to MAKE-DIR should be a FILE! or URL! value, not a STRING! value. ? make-dir USAGE: MAKE-DIR path /deep DESCRIPTION: Creates the directory structure specified. MAKE-DIR is a function value. ARGUMENTS: path -- (Type: file url) REFINEMENTS: /deep (SPECIAL ATTRIBUTES) catch therefore, testVariable: 12312323 make-dir to-file testVariable should work for you (assuming you have write permissions in the current directory). -jn- -- -- Joel NeelyjoelDOTneelyATfedexDOTcom 901-263-4446 Enron Accountingg in a Nutshell: 1c=$0.01=($0.10)**2=(10c)**2=100c=$1 -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject. -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject.
[REBOL] Re: Directory
yes all file i/o need file specifications of type file! -MAx --- You can either be part of the problem or part of the solution, but in the end, being part of the problem is much more fun. -Original Message- From: Chris Siegle [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 14, 2004 11:22 AM To: [EMAIL PROTECTED] Subject: [REBOL] Re: Directory Does the same hold true for write/binary? Example: Temp: FILENAME.TXT write/binary Temp data -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Joel Neely Sent: Wednesday, January 14, 2004 10:39 AM To: [EMAIL PROTECTED] Subject: [REBOL] Re: Directory Hi, Chris, Chris Siegle wrote: Why is it I cannot make a directory from an assigned variable name? testVariable: 12312323 make-dir %testVariable The argument to MAKE-DIR should be a FILE! or URL! value, not a STRING! value. ? make-dir USAGE: MAKE-DIR path /deep DESCRIPTION: Creates the directory structure specified. MAKE-DIR is a function value. ARGUMENTS: path -- (Type: file url) REFINEMENTS: /deep (SPECIAL ATTRIBUTES) catch therefore, testVariable: 12312323 make-dir to-file testVariable should work for you (assuming you have write permissions in the current directory). -jn- -- -- Joel NeelyjoelDOTneelyATfedexDOTcom 901-263-4446 Enron Accountingg in a Nutshell: 1c=$0.01=($0.10)**2=(10c)**2=100c=$1 -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject. -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject. -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject.
[REBOL] Re: Directory
sorry, I forgot to say that they all also support URL! Use the console's help as often as you can. its VERY usefull to know what a function needs, does and it gives you a good cue as to if this is really the function you are looking for... Really, adopting this philosophy answers a lot of questions for me. I still use help on the most basic functions time and time again, to be sure I don't miss any refinements. (sometimes those refinements aren't obvious, but once you've tried one, you generally, at least, rememeber what it does if you see it... I hadn't used all on mold so didn't get what it did). HTH! -MAx yes all file i/o need file specifications of type file! -MAx --- You can either be part of the problem or part of the solution, but in the end, being part of the problem is much more fun. -Original Message- From: Chris Siegle [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 14, 2004 11:22 AM To: [EMAIL PROTECTED] Subject: [REBOL] Re: Directory Does the same hold true for write/binary? Example: Temp: FILENAME.TXT write/binary Temp data -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Joel Neely Sent: Wednesday, January 14, 2004 10:39 AM To: [EMAIL PROTECTED] Subject: [REBOL] Re: Directory Hi, Chris, Chris Siegle wrote: Why is it I cannot make a directory from an assigned variable name? testVariable: 12312323 make-dir %testVariable The argument to MAKE-DIR should be a FILE! or URL! value, not a STRING! value. ? make-dir USAGE: MAKE-DIR path /deep DESCRIPTION: Creates the directory structure specified. MAKE-DIR is a function value. ARGUMENTS: path -- (Type: file url) REFINEMENTS: /deep (SPECIAL ATTRIBUTES) catch therefore, testVariable: 12312323 make-dir to-file testVariable should work for you (assuming you have write permissions in the current directory). -jn- -- -- Joel NeelyjoelDOTneelyATfedexDOTcom 901-263-4446 Enron Accountingg in a Nutshell: 1c=$0.01=($0.10)**2=(10c)**2=100c=$1 -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject. -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject. -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject. -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject.
[REBOL] Re: Directory
Yes, but the example you used still wouldn't work because your Temp variable holds a String! value rather than a File! value so you would still need to use TO-FILE. In most cases it would be better to just give your variable a File! value like so: Temp: %filename.txt That way you wouldn't have to convert it but if you need your variable to be a String! for some reason, just be sure to use TO-FILE like so: write/binary to-file Temp data HTH ~~Ammon ;- - Original Message - From: Chris Siegle [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, January 14, 2004 9:22 AM Subject: [REBOL] Re: Directory Does the same hold true for write/binary? Example: Temp: FILENAME.TXT write/binary Temp data -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Joel Neely Sent: Wednesday, January 14, 2004 10:39 AM To: [EMAIL PROTECTED] Subject: [REBOL] Re: Directory Hi, Chris, Chris Siegle wrote: Why is it I cannot make a directory from an assigned variable name? testVariable: 12312323 make-dir %testVariable The argument to MAKE-DIR should be a FILE! or URL! value, not a STRING! value. ? make-dir USAGE: MAKE-DIR path /deep DESCRIPTION: Creates the directory structure specified. MAKE-DIR is a function value. ARGUMENTS: path -- (Type: file url) REFINEMENTS: /deep (SPECIAL ATTRIBUTES) catch therefore, testVariable: 12312323 make-dir to-file testVariable should work for you (assuming you have write permissions in the current directory). -jn- -- -- Joel NeelyjoelDOTneelyATfedexDOTcom 901-263-4446 Enron Accountingg in a Nutshell: 1c=$0.01=($0.10)**2=(10c)**2=100c=$1 -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject. -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject. -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject.
[REBOL] Re: Directory
Hi Chris, CS Does the same hold true for write/binary? You've gotten answers to this, but I'll add that one of the great benefits of REBOL is its wide array of datatypes. Using them effectively will make a big difference in how you use REBOL--not to mention how you think and feel about it. :) help datatype! in the console will get you a list of datatypes. Look them up in the Core docs and play with them to see how they work. Then look at how the pseudo-types work (things like series! or any-block!), and how you can use type-interrogation functions (e.g. any-string?, function?) to determine type. HTH! -- Gregg -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject.
[REBOL] Re: Directory
Many thanks! -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gregg Irwin Sent: Wednesday, January 14, 2004 1:53 PM To: Chris Siegle Subject: [REBOL] Re: Directory Hi Chris, CS Does the same hold true for write/binary? You've gotten answers to this, but I'll add that one of the great benefits of REBOL is its wide array of datatypes. Using them effectively will make a big difference in how you use REBOL--not to mention how you think and feel about it. :) help datatype! in the console will get you a list of datatypes. Look them up in the Core docs and play with them to see how they work. Then look at how the pseudo-types work (things like series! or any-block!), and how you can use type-interrogation functions (e.g. any-string?, function?) to determine type. HTH! -- Gregg -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject. -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject.
[REBOL] Re: Directory tools
My scheme to include external code is as follows. In my user.r I have: lib-path: %/d/languages/rebol/libs/ I place the "library" files in the directory specified above. Then in my code I simply write: include "highfun" include "mime-types" Oh yeah, the 'include word is defined by my shell.r script which is executed frim user.r. Just FYI its definition is: include: func [some-lib][ do rejoin [lib-path some-lib ".r"] ] Poking around the code in mime-type.r I see its intent (converting a path/url to an object) but 'source-as-object is still a file! when 'read tries to use it with the /full refinement. BTW the error is generated by the file! and not the url! (ftp://). I'll play with it more as time allows because everything is alot more fully featured that the quick hacks that I wrote and I'd really like to see it all work (and be able to use it!). Yes, the first thing I did was to use the /script refinement. I also want to see my program working as it is executing, thus /verbose. - Michael Jelinek "Brett Handley" [EMAIL PROTECTED]@rebol.com on 04/12/2001 09:47:25 PM From: "Brett Handley" [EMAIL PROTECTED]@rebol.com on 04/12/2001 09:47 PM Please respond to [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] To: [EMAIL PROTECTED] cc: Subject: [REBOL] Re: Directory tools Thanks for posting file-tools.r! I have been writing bits of it for myself as I needed them, and was currently balking at writing the directory-related functions (esp copying). You're most welcome. I noticed while writing this email that I had not included the top most target-directory in the copy-directory function. I've rectified this in the version on my website found at http://www.codeconscious.com/rebol/scripts/file-tools.r Looking at the code I'm wondering if it could be made a little more explicit. I'm also not sure now if it is handling relative FTP addressing properly. So I'll have to have another look at it. If you have some ideas I'd welcome them. I needed to modify the way that external code is included to use my own scheme, no problem. Is it a generic scheme? Maybe I should add as an option to the functions? :) I added a /verbose refinement to copy-directory. I want to see what my script does to make sure it behaves itself! Another way is to use the /script refinement to see the code that is produced. However, I'm getting the following error in mime-read. What is the purpose of adding /full at the end of what should already be the full file path? Inside mime-types.r there is a function called import-location-with-mime which given a file! or url! returns an object where the components of the file! or url! are in seperate fields. The /full refinement refers to a function in this object which puts all the pieces back together again to give you the original file! or url! (hopefully). o: probe import-location-with-mime %/d/html/eq/source/book-cod/about.r make object! [ path: %/d/html/eq/source/book-cod/ name: %about extension: %.r full: func [][rejoin [path name extension]] mime-type: func [][ get-mime-for-ext extension ] ] o/full == %/d/html/eq/source/book-cod/about.r retval: copy-directory/files/verbose %/d/html/eq/source/book-cod/ ftp://user:[EMAIL PROTECTED]/source/book-cod/ Copy Dir FROM: /d/html/eq/source/book-cod/ TO: ftp://user:[EMAIL PROTECTED]/source/book-cod/ - Copy file: about.r ** Script Error: Invalid path value: full ** Where: mime-read ** Near: read source-as-object/full source-as-object should have been an object! with a field-function (method) called "full", but it appears not. Maybe my import-location-as-mime function blew up in the face of your new scheme? Brett. -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with "unsubscribe" in the subject, without the quotes. -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with "unsubscribe" in the subject, without the quotes.
[REBOL] Re: Directory tools
Brett, Thanks for posting file-tools.r! I have been writing bits of it for myself as I needed them, and was currently balking at writing the directory-related functions (esp copying). I needed to modify the way that external code is included to use my own scheme, no problem. I added a /verbose refinement to copy-directory. I want to see what my script does to make sure it behaves itself! However, I'm getting the following error in mime-read. What is the purpose of adding /full at the end of what should already be the full file path? retval: copy-directory/files/verbose %/d/html/eq/source/book-cod/ ftp://user:[EMAIL PROTECTED]/source/book-cod/ Copy Dir FROM: /d/html/eq/source/book-cod/ TO: ftp://user:[EMAIL PROTECTED]/source/book-cod/ - Copy file: about.r ** Script Error: Invalid path value: full ** Where: mime-read ** Near: read source-as-object/full - Michael Jelinek "Brett Handley" [EMAIL PROTECTED]@rebol.com on 04/11/2001 09:09:39 PM From: "Brett Handley" [EMAIL PROTECTED]@rebol.com on 04/11/2001 09:09 PM Please respond to [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] To: [EMAIL PROTECTED] cc: Subject: [REBOL] Directory tools Seeing Marcus' console tools post prompted me to post my file-tools.r script I've been working on recently. In this script I wanted some functions that would recursively work on directories whether they are file! or url!. Also in this script I played with the idea of generating script for deferred/custom actions based on reading a directory. Brett. --- browse http://www.codeconscious.com/rebol/ -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with "unsubscribe" in the subject, without the quotes. -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with "unsubscribe" in the subject, without the quotes.
[REBOL] Re: Directory tools
Thanks for posting file-tools.r! I have been writing bits of it for myself as I needed them, and was currently balking at writing the directory-related functions (esp copying). You're most welcome. I noticed while writing this email that I had not included the top most target-directory in the copy-directory function. I've rectified this in the version on my website found at http://www.codeconscious.com/rebol/scripts/file-tools.r Looking at the code I'm wondering if it could be made a little more explicit. I'm also not sure now if it is handling relative FTP addressing properly. So I'll have to have another look at it. If you have some ideas I'd welcome them. I needed to modify the way that external code is included to use my own scheme, no problem. Is it a generic scheme? Maybe I should add as an option to the functions? :) I added a /verbose refinement to copy-directory. I want to see what my script does to make sure it behaves itself! Another way is to use the /script refinement to see the code that is produced. However, I'm getting the following error in mime-read. What is the purpose of adding /full at the end of what should already be the full file path? Inside mime-types.r there is a function called import-location-with-mime which given a file! or url! returns an object where the components of the file! or url! are in seperate fields. The /full refinement refers to a function in this object which puts all the pieces back together again to give you the original file! or url! (hopefully). o: probe import-location-with-mime %/d/html/eq/source/book-cod/about.r make object! [ path: %/d/html/eq/source/book-cod/ name: %about extension: %.r full: func [][rejoin [path name extension]] mime-type: func [][ get-mime-for-ext extension ] ] o/full == %/d/html/eq/source/book-cod/about.r retval: copy-directory/files/verbose %/d/html/eq/source/book-cod/ ftp://user:[EMAIL PROTECTED]/source/book-cod/ Copy Dir FROM: /d/html/eq/source/book-cod/ TO: ftp://user:[EMAIL PROTECTED]/source/book-cod/ - Copy file: about.r ** Script Error: Invalid path value: full ** Where: mime-read ** Near: read source-as-object/full source-as-object should have been an object! with a field-function (method) called "full", but it appears not. Maybe my import-location-as-mime function blew up in the face of your new scheme? Brett. -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with "unsubscribe" in the subject, without the quotes.
[REBOL] Re: Directory tools
Geez.. I meant to attach it.. Here 'tis. - Original Message - From: "Brett Handley" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, April 12, 2001 12:09 PM Subject: [REBOL] Directory tools Seeing Marcus' console tools post prompted me to post my file-tools.r script I've been working on recently. In this script I wanted some functions that would recursively work on directories whether they are file! or url!. Also in this script I played with the idea of generating script for deferred/custom actions based on reading a directory. Brett. --- browse http://www.codeconscious.com/rebol/ -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with "unsubscribe" in the subject, without the quotes. -- Attached file included as plaintext by Listar -- -- File: file-tools.r REBOL [ Title "File Tools" Author: "Brett Handley" Purpose: "Define functions that help to manipulate files." Date: 4-Apr-2001 Comment: { Here are some File directory productivity functions. The aim is to be able to use them with urls as well. In particular: read-directory Returns a directory tree as a flat block of file!. read-directory-tree Returns a directory tree as a nested block structure. walk-dir Will walk a directory tree calling your functions as it goes. directory-script Generates a script by walking through a directory. *** Check the list of supporting scripts you need (below) *** %highfun.r is available from www.rebol.org (advanced I think) %mime-types.r is only needed if you want to use the copy-directory function it is available at www.codeconscious.com/rebol/rebol-scripts.html } ] ; ; Support scripts ; if not :use-script [use-script: :do] ; Use-script is my script manager use-script %highfun.r ; See www.rebol.org to download. use-script %mime-types.r ; See www.codeconscious.com/rebol/rebol-scripts.html ; ; Functions ; to-winfile: function [ "Create a windows file specification from the file." file-spec ][new-file][ new-file: replace/all to-string file-spec "/" "\" remove head new-file replace new-file "\" ":\" new-file ] folders: func[ series [series!]][ "Filters out the folders in a series." filter func[x][all [file? x equal? x dirize x]] series ] files: func[ series [series!]][ "Filters out the files in a series." filter func[x][all[ file? x not equal? x dirize x]] series ] assert-is-directory: func[ [catch] dir [file! url!]][ if not equal? dir dirize dir [ throw make error! "Can only accept directories." ] ] ensure-directory: function[ "Creates the directory if it does not exist." target-directory ][test-dir][ assert-is-directory target-directory if not exists? test-dir: target-directory [ make-dir/deep test-dir ] ] read-directory: function [ "Returns a directory tree as a flat block of file!." spec [file! url!] /prefix prefix-spec [file! url!] "Joins the prefix onto the spec but does not return it in the result." /include "Includes the directory you specify." ][result read-subdirectory refinements actual-spec][ actual-spec: either prefix [join prefix-spec spec][spec] either equal? spec dirize spec [ result: copy [] if include [insert tail result spec] foreach f read actual-spec [ either prefix [ insert tail result read-directory/prefix/include either equal? spec %./ [f][join spec f] prefix-spec ][ insert tail result read-directory/include either equal? spec %./ [f][join spec f] ] ] ][ result: spec ] return result ] read-directory-tree: function [ [catch] "Returns a directory tree as a nested block structure." spec [file! url!] /prefix prefix-spec [file! url!] "Joins the prefix onto the spec but does not return it in the result." /include "Includes the specification as the first directory name." /filter filter-function [any-function!] "Called for each directory and file." ][result dir-list actual-spec][ if not filter [filter-function: func[x][true]] actual-spec: either prefix [join prefix-spec spec][spec] either equal? spec dirize spec [ result: copy [] dir-list: read actual-spec foreach f dir-list [ if filter-function f [ if equal? f dirize f [insert tail result f] insert/only tail result read-directory-tree/prefix f actual-spec ] ] ][ result: spec ] if include [ result: reduce [spec result]] return result ] directory-tree-walker: context [ emit-dir-path: none emit-file-path: none path-stack: none directory-name: none file-name: none push-dir: func [dir] [