[REBOL] Re: How can I do what Launch does?
From: agem:crosswinds at: 15-Apr-2001 20:28
pdp [{launch enabled:}
not equal? mold :launch mold func [] []]
pdp [{top-level:}
none? system/script/parent/parent]
see the script below (save it under its name..)
[rebol [
title: "can i launch? am i toplevel?"
file: %launchlevel1.r
]
uv: does compose [unview/all do (system/script/header/file)]
file: system/script/header/file
; file: %123
text1: copy []
&: func [s] [repend text1 ['h3 s]]
& mold now/time
pdp: func [block] [
& mold block
& mold do block
]
pdp [{launch enabled:}
not equal? mold :launch mold func [] []]
pdp [{top-level:}
none? system/script/parent/parent]
trap: func [] [
request/ok reform [
"my filename schould be" mold file ".."]
]
view/new layout append copy text1 [
across
button "test launch" [
either not exists? file [trap] [launch file]]
button "test-subscript" [if error? try [do file] [trap]]
button "close" [unview]
]
do-events
]
>In another thread, Carl S. writes:
>
>> Launch has a rule: you can only launch from the main REBOL process.
>> This prevents launch loops.
>
>That touches precisely on something I was trying to figger out the
other day.
>I've got a set of scripts (a.r, b.r, c.r). a.r uses DO to call b.r and
c.r.
>But it doesn't make sense for my intended user to in any way execute
b.r or
>c.r directly.
>
>So, if they do, I want to tell them not to, something like:
>
>if not (top-level) [throw "Please run a.r to start the application"].
>
>But I haven't found the best way of writing top-level.....
>
>-- I could use value? on a global variable. But global variables are
>generally a Bad Thing in my book, so I'd like to avoid them.
>
>-- I could scrabble round the System object for something that shows
I'm top
>level or not. But a quick look, didn't find me anything.
>
>-- I could avoid the problem by giving b.r and c.r a different suffix
(b.rll
>and c.rll?). But who knows what effect that'll have when the user
>double-clicks them?
>
>So, whatever check Launch is making, I'd like to be able to make
something
>similar.
>
>Any ideas how?
>
>Thanks,
>Colin.
>--
>To unsubscribe from this list, please send an email to
>[rebol-request--rebol--com] with "unsubscribe" in the
>subject, without the quotes.
>
volker
volker