2010-07-03 47 views
1

讓我們考慮這個頭:如何獲得頭值時,源在內存

REBOL [ 
    Title: "Rebodex" 
    Date: 23-May-2010 
    Version: 2.1.1 
    File: %rebodex.r 
    Author: "Carl Sassenrath" 
    Modification: "Rebtut" 
    Purpose: "A simple but useful address book contact database." 
    Email: %carl--rebol--com 
    library: [ 
     level: 'intermediate 
     platform: none 
     type: 'tool 
     domain: [file-handling DB GUI] 
     tested-under: none 
     support: none 
     license: none 
     see-also: none 
    ] 
] 

如果這個腳本是從文件執行:

do %rebodex.r 

我能得到

system/script/header/title 

但是,如果源代碼存儲在源代碼中,則上面的代碼會產生錯誤。那麼我怎麼能在標題中獲得這個標題?可能嗎 ?

回答

2

如果我理解正確的問題,你必須在腳本中的變量,例如....

>> script: read rebodex.r 

....你想訪問頭。

如果這是你想要的,那麼很簡單:使用負載/頭

>> rebodex-header: load/header script 
>> print rebodex-header/title 
Rebodex