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

[REBOL] Re: [view] Problems with /new and not /new

From: nitsch-lists:netcologne at: 14-Aug-2004 23:54

A few words about view/ view/new and event-loop: On Samstag, 14. August 2004 01:05, Izkata wrote:
> Using view/new works just fine.. The script continues as it should.. > > But for some reason, even if I hadn't used view/new in the script yet, > using only view layout [blah blah] causes the script to continue on and not > halt. > It usually happens when I click a button in a layout that calls a function > that > opens another. (Did that make sense?)
Makes sense :) Thats because 'view checks if any windows are open. It is not meant to block, but somebody has to start the event-loop. And there is no way to check if events are running already. So by convention, if there are open windows, there is a running event-loop too. Another difference between view and view/new: view closes the current window. view/new adds another one. In combination you can make kind of "browser" where you do go to other scripts when the user presses a button: as convention each script makes a layout and ends with view my-layout now the first script runs. it sees there is no open window, so starts the event-loop (blocks). now the user presses button, we do second script. This script does its view, and now a window is open: 1) view closes the old window. Thats good. otherwise we would have lots of death, uninteresting windows some clicks later. 2) it sees a window is open, so there should be a event-loop. So it does not start a new one (means does no 'wait, 'do-events or such). 3) does not block. so the script returns. 'view was the last command, so that makes no difference. So rebol does some returns, to the button-press, then to the first event-loop. There are no more information about doing the new script on the return-stack. So you can do an unlimited amount of scripts. You can also do the same script alot of times. button-press -> change data, save data, do script again. No stack-flooding. Kind of tail-recursion. Or you can use that like a browser: a script is a "page", has some content and some links (buttons with "do other page"). The other page has some links too. All pages have a "do %main-menu.r". And you have a flexible application where you quickly can add funtions. Only problem are the jumping windows, but for a prototype ok.
> > -Izzy boy ^.^ (Thanx for any help if you understood my request)
-Volker