Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Accessing a script from itself

 [1/6] from: carl:cybercraft at: 21-Dec-2004 18:08


Hi all, After a script is running, is the source stored somewhere where it can be accessed, or would you have to load it again from disk? -- Carl Read.

 [2/6] from: volker:nitsch:g:mail at: 18-Dec-2004 14:56


REBOL [content: true] alert system/script/header/content But IIRC the crs are translated, so no /binary On Sun, 19 Dec 2004 00:16:01 +1300, Carl Read <[carl--cybercraft--co--nz]> wrote:
> Hi all, > After a script is running, is the source stored somewhere where it can be accessed, or would you have to load it again from disk?
<<quoted lines omitted: 6>>
> To unsubscribe from the list, just send an email to rebol-request > at rebol.com with unsubscribe as the subject.
-- -Volker Any problem in computer science can be solved with another layer of indirection. But that usually will create another problem. David Wheeler

 [3/6] from: greggirwin:mindspring at: 18-Dec-2004 10:26


Hi Carl, CR> After a script is running, is the source stored somewhere where it CR> can be accessed, or would you have to load it again from disk? It isn't available...normally, but REBOL being what it is, a simple twist will make it available. Just define your main script as a block and DO it at the end, then that block will be available to you. my-source: [ print 'testing b: copy [] append b [1 2 3] ] do my-source -- Gregg

 [4/6] from: carl:cybercraft at: 1-Jan-2005 23:35


On Saturday, 18-December-2004 at 14:56:14 Volker wrote,
>REBOL [content: true] >alert system/script/header/content > >But IIRC the crs are translated, so no /binary
Thanks Volker. I never suspected it'd need to be flagged in the header. -- Carl Read.

 [5/6] from: antonr:lexicon at: 15-Jan-2005 20:30


If you wrote the script, or if you modify the script's header before doing it, then you can make the script content available by setting CONTENT: TRUE in the header. eg.
>> write %afile.r {rebol [content: true] print "hello" probe
system/script/header/content}
>> do %afile.r
Script: "Untitled" (none) hello {rebol [content: true] print "hello" probe system/script/header/content} == {rebol [content: true] print "hello" probe system/script/header/content} I remember there was a quine (a program which reproduces itself) which used this method. Anton.

 [6/6] from: carl:cybercraft at: 16-Jan-2005 1:29


Thanks Anton! Now can you tell me why I was wanting to do this? :-) Jeeze this list is starting to really suck... -- Carl Read. On Saturday, 15-January-2005 at 20:30:42 you wrote,

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted