alix
Junior Member
Posts: 57
|
Post by alix on Jan 22, 2008 2:46:27 GMT -5
There is a problem when you try to RUN a project that contains a WAIT. The main project does not WAIT for the called project. Here is a short exemple: Main project :
' ' MAIN PROGRAM ' run "passtest", #v render #v 'wait print print print "----> This is a message from the main program"
Called project :
' ' PASSTEST ' print "Password ?" print passwordbox #pw, "" link #action, "Submit", [ValidPasswordCheck] wait [ValidPasswordCheck] pass$= #pw CONTENTS$() print print print "---->Called program password = ";pass$ wait
As you can see the main program does not wait for the user to put a password in, it prints its message immediately. If you uncomment the 'wait, then passtest does it stuff but then, the main program cannot continue.
How can one get the main project to wait for the runned project to to conclude interaction with the user?
|
|
|
Post by carlgundel on Jan 22, 2008 8:34:09 GMT -5
There is a problem when you try to RUN a project that contains a WAIT. The main project does not WAIT for the called project. Here is a short exemple: As you can see the main program does not wait for the user to put a password in, it prints its message immediately. If you uncomment the 'wait, then passtest does it stuff but then, the main program cannot continue. How can one get the main project to wait for the runned project to to conclude interaction with the user? It's true that the RUN statement kicks off a second process for the program it runs, so you do have this race condition. We will come up with some way for the programmer to have more control over this but until then you can workaround this pretty easily by having the program that you run not do anything until you call a method on it, like so: Main project : ' ' MAIN PROGRAM ' run "passtest", #v #v go() render #v 'wait print print print "----> This is a message from the main program"
Called project : ' ' PASSTEST ' global #pw wait
function go() print "Password ?" print passwordbox #pw, "" link #action, "Submit", [ValidPasswordCheck] end function
[ValidPasswordCheck] pass$= #pw CONTENTS$() print print print "---->Called program password = ";pass$ wait
|
|
|
Post by Jerry Muelver on Jan 22, 2008 8:49:14 GMT -5
Thanks, Carl. I've been grappling with the subtleties of WAIT for some time, now. You know, it behaves rather like a Horne clause in PROLOG! My thanks also to Alix, for framing the concept so tightly.
|
|
|
Post by carlgundel on Jan 22, 2008 9:52:25 GMT -5
Thanks, Carl. I've been grappling with the subtleties of WAIT for some time, now. You know, it behaves rather like a Horne clause in PROLOG! My thanks also to Alix, for framing the concept so tightly. We definitely do need to refine this mechanism so the programmer can choose whether to fork or not. -Carl
|
|
alix
Junior Member
Posts: 57
|
Post by alix on Jan 22, 2008 10:05:32 GMT -5
I don't understand because I still get the same problem on my RB personnal server When I run the main program (your new version), and I have not entered the password yet, I get this : The main program still barges in and prints its message. I should only see the passwordbox no ? Then I enter the password, and I get this and that's right... @+
|
|
|
Post by carlgundel on Jan 22, 2008 10:45:01 GMT -5
That's what happens when I barrel ahead without reading carefully, sorry.
The program that you ran is embedded into the page. It isn't in the same thread of execution, but it is a program unto itself with its own thread. Once the program hits its wait statement control is passed back to the caller. One feature I realized was missing from RB v1.0 once it was released is a special #self or #this object that can be passed around, and this would allow you to set a callback for the main program.
Probably this best way to fix this issue at least for password control is to reverse your design. An access control program is the main program, and once you successfully enter a password then it runs your application and renders that into the page.
Make sense?
I'll post with some related ideas and details later with regards to refinements in RB that will appear with v1.0.1.
-Carl
|
|
alix
Junior Member
Posts: 57
|
Post by alix on Jan 22, 2008 11:13:08 GMT -5
Yes that makes sense and I will do it this way. As for why it should be done this way, that will take more time and pondering on my side! Thanks very much for taking the time to explain.
|
|