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

[REBOL] Re: Very Useful Function : Reload the new code

From: sunandadh:aol at: 14-Mar-2002 11:04

> Is there somebody who already developed a function placed on a button for > VID that could : > 1) completely free the memory with the old code > 2) and re-load the new .r and re-open a new window
I don't know if this helps, but you could gut the code below to get the sort of effect you want. This code is my wrapper for an application. The payload -- the main application is the line Do %esinMain.r. The rest of the code simply wraps this in a Try block. If an error occurs the error recovery does one of two things: -- If the error is a specific user error it automatically restarts. The application triggers this error to force the sort of restart you want -- somewhere in the depths of the application this line triggers a restart: make error! "restart-request" --Any other error is logged and reported, and the user offered the chance to restart or quit. (Watch out for strings wrapping across lines in the cut'n'pasted code) Sunanda. --------------------------- rebol [title: "esinGo.r"] ESIN-VERSION: "00.00.03" ;; Sign-in /user identification / data integrity checks ;; ---------------------------------------------------- do %esinSign.r ;; Repeated execute application until exit ;; --------------------------------------- while [true] [ ESIN-ERROR: copy [] error? try [unset 'ESIN-ERROR] error? try [unset 'GLOBAL-ERROR-MESSAGE] ;; Run the application ;; ------------------- If error? ESIN-ERROR: try [ unview/all do %esinMain.r ;; payload!! ][ ;; report / recover from error ;; --------------------------- ESIN-ERROR-1: disarm ESIN-ERROR either all [esin-error-1/code = 800 esin-error-1/type = 'user esin-error-1/arg1 = "Restart-request" ][ ;; either/true: application wants auto restart ;; ------------------------------------------- error? try [Esinutil/Write-Log ">>>ESIN/CM Restart on application request"] ][ ;; either/false: application error ;; ------------------------------- unset 'ESIN-ERROR error? try [Esinutil/Write-Log "<<<<<<<ESIN/CM HAS CRASHED>>>>>>>>"] error? try [Esinutil/Write-Log either value? 'GLOBAL-ERROR-MESSAGE [GLOBAL-ERROR-MESSAGE] [mold ESIN-ERROR-1] ] ;;try unview/all Error-string1: copy "" Error-string2: copy "" error? try [error-string1: to-local-file DATA-DIRECTORY] if Error-string1 <> "" [ error-string2: join "Along with all the files in " data-directory ] ;; Report back to user, and offer restart or quit ;; ---------------------------------------------- view layout [ info 500x250 black font-color white font-size 15 wrap join "Oh Dear!^/^/ESIN/CM " [ESIN-VERSION " has fallen over!^/ ^/" "If you can be bothered, please make a note of " "the cryptic stuff below and send it to Sunanda at " "[xxx--xxxx--xxx]" newline newline Error-string2 newline newline "Thanks!" ] info 500x400 black font-color white font-size 12 wrap either value? 'GLOBAL-ERROR-MESSAGE [GLOBAL-ERROR-MESSAGE] [mold ESIN-ERROR-1] info 500x100 black font-color white font-size 15 wrap join "In most cases, you can clear the error and " ["keep working simply by clicking the " "Restart button below.^/" ] across button "Restart" [error? try [EsinUtil/WriteLogEntry "Restart taken..."] unview/all ] tab button "Exit" [Quit] ] ;; layout ] ;;either/false ] ;;if-error ] ;;while quit