[REBOL] Re: 'do - question
From: nitsch-lists:netcologne at: 12-Nov-2001 6:46
RE: [REBOL] Re: 'do - question
was in translations mood yesterday.
script %launch-by-do.r below.
complete (german) "ide" in "volker"-rebsite.
> Thanks Volker, Thanks Andrew!
> Sunday, November 11, 2001, 5:55:38 AM, nitsch-lists wrote:
> > carl suggested something like
> >>> catch/name[throw/name "goodbye" 'quit] 'quit
> > == "goodbye"
> > real-quit: :quit
> > quit: [throw/name 'quit]
> > catch/name[unview/all do your-file] 'quit]
> That's exactly with what I've come up yesterday night. As I know that
> the script I call does not use any unnamed catch, it does work fine ;)
> > you should also catch errors, reset directory and figure out if you
> > need some unview/all to stop event-loop.
> > i have an extended version for that in my ide, runs some unprepared
> > foreign scripts well. but german yet..
> hmm, german would be no problem, as this is my native language ;)
> Best regards,
> Andreas mailto:[andreas--bolka--gmx--net]
if one wants to start other scripts while launch disabled,
this script may help.
it starts them with do, but sets some stuff
so when script terminate the launcher continues.
mostly it patches quit.
be carefull because these scripts run with launchers security-settings.
* 'quit is "redirected" to throw/name 'quit 'quit,
so the usual quit-button returns.
except there is an unnamed catch around..
* uses some unview/all
view behaves differently if there is a window open.
with no window open it blocks with do-events,
with some it continues.
scripts which rely on blocking should be started without windows open..
* saves and resets directory
* has special protect-system.
protects only up to a specified word.
replace 'rebsite-ed there with the first word you define,
that and everything loaded later will not be protected.
allows for test scripts with protect-system twice in the same exe.
* saves and restores system/view/screen-face/pane,
after closing all windows and doing the script the old windows
* has some requesters: informs about termination by
error, quit or throw. search for 'alert and 'confirm to change them.
;do/args %build-pack.r 'test
demo: does [
; set to true if to disable "trusted?"-question.
; set to something which forms an error, like Bo's print-error.
launch [quit] ;we can launch blocks now, side-effect
set-launch-by-do: func  [
if not native? :launch [
protect-system: does [
foreach word first system/words [
if 'rebsite-ed = word [break]
if value? word [protect word]
launch: func [arg /secure-cmd
/local got-error thrown system-worte debug-quit
sf sf-bak system-quit my-dir set-back
set-back: does [
sf-bak: copy system/view/screen-face/pane
if any [debug-in-exe confirm reform [
"OOPS! file gets executed with 'do !"
"security risk. really?"
if thrown: catch [
quit: func [[catch]] [
throw/name 'quit 'quit
if error? got-error: try [
do arg none
alert probe form-error disarm got-error
if not confirm probe reform [
"there was" mold :thrown "thrown"
] [set-back quit]
;view/new -> no hotkeys.. needs hacking