Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Rebol Programming/change-dir

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

USAGE: CHANGE-DIR dir DESCRIPTION: Changes the active directory path. CHANGE-DIR is a function value. ARGUMENTS dir -- new directory path (Type: file) (SPECIAL ATTRIBUTES) catch SOURCE CODE change-dir: func [ "Changes the active directory path." [catch] dir [file!] "new directory path" /local slash full ret ][ dir: clean-path dir if (last dir) <> #"/" [append dir #"/"] if (first dir) = #"/" [ slash: next dir full: remove parse system/script/path "/" while [all [not empty? slash (first slash) = #"/" not empty? full]] [ insert slash first full remove full slash: find/tail slash "/" if (empty? full) or (empty? slash) [clear slash break] ] ] either throw-on-error [dir? dir] [ system/script/path: dir ] [ throw make error! reduce ['access 'cannot-open dir] ] system/script/path ]