跳轉到內容

Rebol 程式設計/in-dir

來自華夏公益教科書
IN-DIR dir block 

在某個目錄中執行程式碼塊。

IN-DIR 是一個函式值。

  • dir -- 要更改到的目錄(之後會更改回來)(型別:檔案)
  • block -- 要執行的程式碼塊(型別:程式碼塊)

(特殊屬性)

[編輯 | 編輯原始碼]
  • 丟擲

原始碼

[編輯 | 編輯原始碼]
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
]
華夏公益教科書