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

[REBOL] Re: 'do - question

From: nitsch-lists:netcologne at: 12-Nov-2001 6:46

RE: [REBOL] Re: 'do - question Hi Andreas, was in translations mood yesterday. script %launch-by-do.r below. complete (german) "ide" in "volker"-rebsite. [andreas--bolka--gmx--net] wrote:
> > 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] >
REBOL [ title: "launch-by-do" file: %launch-by-do.r purpose: { 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. } features: { * '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 appear magically. * 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. debug-in-exe: false ; set to something which forms an error, like Bo's print-error. form-error: :mold ;launch %pad.r set-launch-by-do launch [quit] ;we can launch blocks now, side-effect ;launch %pad.r ] set-launch-by-do: func [] [ if not native? :launch [ unprotect 'protect-system protect-system: does [ foreach word first system/words [ if 'rebsite-ed = word [break] if value? word [protect word] ] ] unprotect 'launch 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 [ unprotect 'quit quit: :system-quit change-dir my-dir ] sf-bak: copy system/view/screen-face/pane if any [debug-in-exe confirm reform [ "OOPS! file gets executed with 'do !" "security risk. really?" ] ] [ unprotect 'quit system-quit: :quit if thrown: catch [ unview/all quit: func [[catch]] [ unview/all throw/name 'quit 'quit ] my-dir: what-dir if error? got-error: try [ do arg none ] [ alert probe form-error disarm got-error ] none ] [ if not confirm probe reform [ "there was" mold :thrown "thrown" "continue debugging?" ] [set-back quit] ] set-back unview/all ;view/new -> no hotkeys.. needs hacking sf: system/view/screen-face sf/pane: sf-bak show sf ] ] ] ] demo