Jump to content

Rebol Programming/in-dir

From Wikibooks, open books for an open world

USAGE:

[edit | edit source]
IN-DIR dir block 

DESCRIPTION:

[edit | edit source]

Evaluate a block while in a directory.

IN-DIR is a function value.

ARGUMENTS:

[edit | edit source]
  • dir -- Directory to change to (changed back after) (Type: file)
  • block -- Block to evaluate (Type: block)

(SPECIAL ATTRIBUTES)

[edit | edit source]
  • throw

SOURCE CODE

[edit | edit source]
in-dir: func [
  "Evaluate a block while in a directory." 
  [throw] 
  dir [file!] "Directory to change to (changed back after)" 
  block [block!] "Block to evaluate" 
  /local old-dir
][
  old-dir: what-dir 
  change-dir dir 
  also do block change-dir old-dir
]