View Full Version : Yes, No? Make up your mind!
Bruce
08-23-2004, 08:05 PM
Simple dialog with yes or no if they press yes (should be 1)... then do whatever. else get the heqq out of here. What am I doing wrong? :huh
result = Dialog.Message("Notice", "Java will now be loaded onto your system.", MB_YESNO, MB_ICONINFORMATION, MB_DEFBUTTON1);
if (result == 1) then
File.Run("AutoPlay\\Docs\\java.exe", "", "", SW_SHOWNORMAL, false);
else
Application.Exit();
end
Intrigued
08-23-2004, 08:30 PM
Application.Exit() ... seems to not like to work inside of If..thens.
One option would be to have the application minimize then change to a blank page with Application.Exit() on preload.
Corey
08-23-2004, 08:53 PM
Naw, it works fine. If you have an example where it doesn't work right, I'd be happy to fix it for you anytime. Anyhow here's an example attached Bruce. Check in the docs. Yes = 6, No = 7. Or if you don't like docs, use a Dialog.Message() action to test the value of a given in put at runtime. :yes
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
Corey
08-23-2004, 09:00 PM
Here's the same example file attachment in .apt format for users of AutoPlay Media Studio Standard Edition. :yes
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
To make it simple to read, I like to use the built in constants.
IDABORT
IDCANCEL
IDIGNORE
IDNO
IDOK
IDRETRY
IDYES
result = Dialog.Message("Notice", "Java will now be loaded onto your system.", MB_YESNO, MB_ICONINFORMATION, MB_DEFBUTTON1);
if (result == IDYES) then
File.Run("AutoPlay\\Docs\\java.exe", "", "", SW_SHOWNORMAL, false);
else
Application.Exit();
end
Corey
08-23-2004, 09:37 PM
Yes, asbolutely Worm is right. I was just trying to relate to Bruce's existing file here, but absolutely it's better to use the more readable constants as a habit. :yes
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
Bruce
08-23-2004, 10:26 PM
You guys are the bomb! Thanks! Hey Worm, Vent is waiting... he he he
Intrigued
08-23-2004, 10:41 PM
http://www.indigorose.com/forums/showthread.php?t=8151&highlight=application.exit
I was thinking of this thread when this post came up.
Sincerely,
Corey
08-23-2004, 11:03 PM
Seems like I got his project working OK... Anyhow if you ever have a file with an Application.Exit() which doesn't work, let me know and I'll see if I can shine some light on it. :)
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
Intrigued
08-23-2004, 11:24 PM
Seems like I got his project working OK... Anyhow if you ever have a file with an Application.Exit() which doesn't work, let me know and I'll see if I can shine some light on it. :)
Ah, it was a user in another post (that one I shared previously). He does seem to have found a solution, I did not catch how he handled such though.
I can't say I have had a problem with Applicaton.Exit() myself.
The offer is appreciated. At times we all need a little help. (grin)
Corey
08-23-2004, 11:28 PM
Hugh Betcha.
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
Intrigued
08-23-2004, 11:33 PM
Hugh Betcha.
Ok, I am grabbing my Klingon translator! Ha!
Oh, I take that back, Corey, when's your SQLite CD Volume 4 coming out again? (grin)
Corey
08-24-2004, 12:06 AM
I'm not sure where I'm at on the whole "video training" thing right now. So, probably not soon. Not trying to sound aloof but it's just something I guess I have to sort out for myself. I'll keep you posted. :yes
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
csd214
08-24-2004, 01:36 AM
Anyhow if you ever have a file with an Application.Exit() which doesn't work, let me know and I'll see if I can shine some light on it. :)
As a result of longedge’s post (07-26-2004) I created this test project. Application.Exit() is ignored three times.
Page1.On Preload calls Global Script with App.Exit (ignored),
returns to On Preload with App.Exit (ignored).
Continues with Page1.On Show with App.Exit (ignored)
Button.Exit = App.Exit: YEAH
The clue is the return statements.
Corey
08-24-2004, 02:14 AM
Screen res width is always less than 9999 so I don't see anything being ignored. Honestly I believe it's the script here and not the action itself. What exactly are you trying to achieve in this sample, let me know and I'll post a working example. :yes
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
csd214
08-24-2004, 05:06 AM
Screen res width is always less than 9999
Yes, of course, Corey! (I haven’t seen a screen with a width of 10000 or greater; yet...)
The intention with my project was to show that Application.Exit() didn’t work (in this project the app should ALWAYS be exited before page1 is displayed). But it works if you swap Application.Exit() with indow.Close(Application.GetWndHandle(), CLOSEWND_TERMINATE).
To avoid another misunderstanding: I don’t say that this is a bug! It’s bad scripting. (Why should I have the function to return a value when I want to exit? And I shouldn’t exit without notifying the user (in a real project)).
Recall the original post: longedge had a test of screen width 1024, and he wanted to exit if the requirement wasn’t met, but his Application.Exit() didn’t work. May be because of return statements within the function? (It's NOT en if/else problem).
Last month you said: “Yeah, if I recall this has something to do with the way scripts are parsed”. I think you are absolutely right, Corey! But you asked for “a file with an Application.Exit() which doesn't work”; you have got it.
Am I clear enough?
Intrigued
08-24-2004, 09:16 AM
I'm not sure where I'm at on the whole "video training" thing right now. So, probably not soon. Not trying to sound aloof but it's just something I guess I have to sort out for myself. I'll keep you posted. :yes
I understand. Well, I'll keep a look out for such in the future, thanks!
Sincerely,
TJ_Tigger
08-24-2004, 11:01 AM
I have had an instance where Application.Exit did not work for me in the past. What I found I was doing was I had two pieces of code and both needed to complete on that page. There were two IF statements on one page and they were not nested. In that instance the Application.Exit would not work, but as soon as I nested the two IF statements it worked great. Hope this helps.
Corey
08-24-2004, 11:31 AM
Yeah, when I was referring to the way scripts are parsed I was talking about the scenario Tigg mentions. When two pieces of code need to be completed. Because the script gets fully parsed, even past the exit statement in that case.
In the case of your example I don't see how it could test true. Or maybe I'm misreading the code. I'll try and whip up an example later today.
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
Ted Sullivan
08-24-2004, 12:27 PM
The issue may be the fact that Application.Exit does not immediately terminate the program. It simply posts a close message that will cause the application to close in the "near future". If you are currently in a block of script, the rest of the script will still execute to the end of the block before the "close message" can be handled by the main application.
csd214
08-24-2004, 12:29 PM
In the case of your example I don't see how it could test true.
(I presume your comment is meant for me).
The screen width 9999 was a joke. To do the TEST project more realistic, you can set the requirement to 1152( x 864) if you are running 1024 x 768 (like me).
As I said: This is BAD scripting (by intention). The point was to demonstrate a project were the user expected an exit through the App.Exit in the global script, and if you replaced the statement with a Window.Close(), -- then the app shuts down. (or you could remove the two returns).
You don’t have to whip up an example because of me. I’m sorry that my example was that confusing.
So if you follow it with a return, you should get more reliable results?
Application.Exit();
return;
If you are currently in a block of script, the rest of the script will still execute to the end of the block before the "close message" can be handled by the main application.
Corey
08-24-2004, 12:58 PM
I think we're all going for the same thing csd, your example was fine. :) What Ted said is actually the most eloquent explanation of what both Tig gand I were trying to say. But that being said, there's ways to arrange your script to do whatever you need I think.
In a pinch, using a flag variable and then putting your Application.Exit() action inside an if statement (which tests for that flag variable) at the end of your script is 100% reliable as far as I know. This is common for some types of scripting. So you would set a variable, i.e. EndProgram = "true" conditionally within your main script and then at the end:
if EndProgram ~= "true" then
Page.Jump("Page 2");
else
Application.Exit();
end
Or some variation on that. This is just a conceptual example, you can implement this in many different ways.
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
Corey
08-25-2004, 01:59 PM
BTW csd, here's a very small example of a resolution check exit gateway thingy:
display = System.GetDisplayInfo();
if display.Width ~= 1024 and display.Height ~= 768 then
Dialog.Message("Resolution Mismatch", "Application will now exit...");
Application.Exit();
else
Dialog.Message("Resolution Match", "Application will now continue...");
end
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
csd214
08-26-2004, 02:31 AM
A noble script, Corey, but I have been unsuccessful in telling what the intention with ExeExit.apz was.
It was *NOT* a script to demonstrate testing screen properties.
What it was:
The designer tests something and want to exit the application if some requirement is *not* met. In an if/else/end section he puts inn Application.Exit(), but it does not work!
[To have a script that *ALWAYS* should exit at run time, I set the requirement to screen width >= 10000. NOBODY has a screen with such properties.]
Then the designer replaces the App.Exit with Window.Close(). NOW THE SCRIPT WORKS!
Why:
Ted has given the answer (and that’s why a unnested if/end might not work). And in another post (Program Flow) Brett said: “A code chunck on an event will always be executed to completion even if a Page.Jump is performed. That is why the other blocks are executed.”
Then Worm comes in with his 6 character statement: return.
This is useful information! Have a look at the thread Program Flow (http://www.indigorose.com/forums/showthread.php?t=8204) where I used this feature to create an Error Log/Program Execution Log.
The global script in my demo was like this:
01 function ScreenTest()
02 -- called from Page.On Preload
03 dispResult = "OK"
04 screenres = System.GetDisplayInfo();
05 if screenres.Width < 9999 then
06 dispResult = "Has to exit";
07 answer = Dialog.Message("Screen Resolution Problem", "Width is less than 9999"..
08 "\r\n[Global Script: Next statement is Application.Exit(), but is ignored"..
09 "\r\ndue to the return statements.]", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
10 Application.Exit(); -- is ignored
11 return true;
12 end
13 return false;
14 end
The code on line 10 “did not work”.
Solutions:
i) Remove line 11. The app will be closed by the Page code On Show (due to the variable ‘dispResult’) = “The Flag Method”
ii) Line 11: Replace ‘return true;’ with ‘return;’. Worms method, the code chunck is interrupted, the Application.Exit() is executed (“in the future”).
iii) Line 10: Use Window.Close()
Do we listen at the same frequency, Corey? Is my understanding correct?
Corey
08-26-2004, 03:33 AM
OK, in that case:
display = System.GetDisplayInfo();
if display.Width ~= 1 then
Dialog.Message("Resolution Mismatch", "Application will now exit...");
Application.Exit();
else
Dialog.Message("Resolution Match", "Application will now continue...");
end
Seems to work OK here...
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
csd214
08-26-2004, 06:11 AM
Yes, you have turned the question. Your script lines are Ok by themselves, but have you put then into a function like this:
function ScreenTest()
display = System.GetDisplayInfo();
if display.Width ~= 1 then
Dialog.Message("Resolution Mismatch", "Application will now exit...");
Application.Exit();
return true;
else
Dialog.Message("Resolution Match", "Application will now continue...");
return false;
end
end
Call the function from Page.On Preload:
HasToExit = ScreenTest();
Page.On Show:
Label.SetText("labScreenRes", display.Width);
Label.SetText("labMsg", "You should never see this page");
My demo was like this. Does it still work? You should now have “the total code chunck” issue.
longedge
08-26-2004, 06:43 AM
http://www.indigorose.com/forums/showthread.php?t=8151&highlight=application.exit
I was thinking of this thread when this post came up.
Sincerely,
Just in case it's of interest I used "Window.Close(Application.GetWndHandle(), CLOSEWND_TERMINATE);" as suggested by SRJ - IIRC.
However when I did a preview and test build on my desktop PC as opposed to my laptop where I was having the problem, it worked fine. I never got round to trying to track the problem down but it was clearly specific to my laptop. I'm always more than happy if I've got a workaround up my sleeve.
csd214
08-26-2004, 09:30 AM
Just in case it's of interest I used "Window.Close(Application.GetWndHandle(), CLOSEWND_TERMINATE);" as suggested by SRJ - IIRC.
Yes, that’s the third solution:
i) Remove line 11. The app will be closed by the Page code On Show (due to the variable ‘dispResult’) = “The Flag Method”
ii) Line 11: Replace ‘return true;’ with ‘return;’. Worms method, the code chunck is interrupted, the Application.Exit() is executed (“in the future”).
iii) Line 10: Use Window.Close()
But still it is nice to *understand* why Application.Exit() sometimes “doesn’t work”.
Corey
08-26-2004, 12:48 PM
Hi. This works 100% over here:
function ScreenTest()
display = System.GetDisplayInfo();
if display.Width ~= 1 then
Dialog.Message("Resolution Mismatch", "Application will now exit...");
Application.Exit();
else
Dialog.Message("Resolution Match", "Application will now continue...");
end
end
ScreenTest();
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
csd214
08-26-2004, 04:04 PM
No, Corey! Do not put the execution statement (ScreenTest()) in the global script area. Call the function from On Preload with:
HasToExit = ScreenTest();
And the function Screentest(): Add the two lines ‘return true’ and ‘return false’.
Have a look at my original ExeExit.apz. And remember the On Show code from my previous post:
Label.SetText("labMsg", "You should never see this page");
Your simplified project will surely work (and “do the job”).
Corey
08-26-2004, 07:12 PM
Hi. Well the main thing is that it works this way. If you can post a single, simple block of code which doesn't work, I can fix it for you probably. Short of that I'm sure there are myriad ways to make it not work, but I'm just focused on the task, not the syntax, i.e. what is the goal task and how can we achieve it. Once a solution is found I tend to wander away to some other problem. :)
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.