| View previous topic :: View next topic |
| Author |
Message |
GeoTrail Valued Contributor


Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Sat Mar 08, 2003 3:16 am Post subject: Problem with dialog. Must click twice to close |
|
|
I'm experimenting with an email checking app here.
Anyways, I'm having some problems with the settings dialog I think.
Closing the settings dialog works fine, but when I click to close the main program using the x I have to click twice to close it.
Hope someone can help me find the problem.
Thanks in advance
| Code: | external vdsipp.dll
INIFILE OPEN, @path(%0)\pop.ini
DIALOG CREATE,Just an experiment,-1,0,327,206
REM *** Modified by Dialog Designer on 08.03.2003 - 03:55 ***
DIALOG ADD,BUTTON,CHECKMAIL,64,64,104,24,CHECKMAIL,Click to check your email.
DIALOG SHOW
rem DIALOG SELECT,0
GoSub ReadINI
:Evloop
wait event
parse "%%Event;%D",@event(D)
goto %%Event
:CHECKMAILBUTTON
INTERNET POP3,CREATE,1
INTERNET POP3,THREADS,1,OFF
INTERNET POP3,AUTHENTICATE,1,%%UserName,%%Password
INTERNET POP3,CONNECT,1,%%MailServer,110
%R = @INTERNET(POP3,RETURNCODE,1)
If @equal(%R,1)
%A = @INTERNET(POP3,MAILBOXSIZE,1)
%B = @INTERNET(POP3,MSGCOUNT,1)
If @equal(%B,0)
WARN Sorry %%YourName. No emails on the server at this time.
Else
%A = @DIV(%A,1024)
warn %%YourName, you have %B emails taking@cr()up %A kb on the %%MailServer server.
End
Else
warn Error connecting to server.@cr()Did you use the correct password?
End
rem We are finished using the connection, so now we disconnect and close it.
INTERNET POP3,DISCONNECT,1
INTERNET POP3,DESTROY,1
Goto Evloop
:EmailSettings
if @WinExists(Email account settings)
Goto Evloop
Else
DIALOG CREATE,Email account settings,-1,0,313,183,ONTOP
REM *** Modified by Dialog Designer on 08.03.2003 - 03:48 ***
DIALOG ADD,GROUP,GROUP1,8,8,296,128,POP Email settings
DIALOG ADD,TEXT,YOURNAME,40,16,,,Your name:
DIALOG ADD,EDIT,EDIT1,32,112,176,21,,Enter your first name here.
DIALOG ADD,EDIT,USERNAME,56,112,176,21,,Enter here your username to login to the email account.
DIALOG ADD,TEXT,UNAME,64,16,,,Username:
DIALOG ADD,EDIT,PASSWORD,80,112,176,21,,Enter the password used for loggin in to your mail account.
DIALOG ADD,TEXT,PASSW,88,16,,,Password:
DIALOG ADD,EDIT,SERVER,104,112,176,21,,Enter your email server here (mail.yourserver.com)
DIALOG ADD,TEXT,Serv,112,16,,,Email server:
DIALOG ADD,BUTTON,SAVE,144,56,80,32,Save
DIALOG ADD,BUTTON,CANCEL,144,192,80,32,Cancel
DIALOG SHOW
End
Goto Evloop
:ReadINI
%%UserName = @INIREAD(Pop Settings,UserName,0)
If @equal(%%UserName,0)
Goto EmailSettings
Else
%%Password = @INIREAD(Pop Settings,PassWord,0)
End
Exit
:SAVEBUTTON
%%YourName = @dlgtext(EDIT1)
%%UserName = @dlgtext(USERNAME)
%%Password = @dlgtext(PASSWORD)
%%MailServer = @dlgtext(SERVER)
INIFILE WRITE,Pop Settings,YourName,%%YourName
INIFILE WRITE,Pop Settings,UserName,%%UserName
INIFILE WRITE,Pop Settings,Password,%%Password
INIFILE WRITE,Pop Settings,MailServer,%%MailServer
goto CLOSE
:CANCELBUTTON
goto CLOSE
:CLOSE
if @greater(%D,0)
dialog select,%D
dialog close
wait event
%E = @event()
goto Evloop
end
exit |
_________________
 |
|
| Back to top |
|
 |
GeoTrail Valued Contributor


Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Sat Mar 08, 2003 4:06 am Post subject: |
|
|
Kinda strange.
The program will show the settings dialog if the ini file haven't been created. If I close the settings dialog without entering anything and the I have to click twice to close the program.
But if I have entered the info in the settings dialog then the close button works. Could anyone help me please?  _________________
 |
|
| Back to top |
|
 |
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Sat Mar 08, 2003 4:28 am Post subject: |
|
|
I'm sure that if you use "STOP" instead of "EXIT" on the end of the script, it will work.
I'm not sure why yet.... |
|
| Back to top |
|
 |
GeoTrail Valued Contributor


Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Sat Mar 08, 2003 4:30 am Post subject: |
|
|
Yeah, that worked. Thanks Tommy
Now the obvious question is, WHY?
That was kinda strange. Anyways, thanks again Tommy. _________________
 |
|
| Back to top |
|
 |
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Sat Mar 08, 2003 4:31 am Post subject: |
|
|
Ok, the cause is, that you are first using GOSUB to go to ReadINI, and then inside that,
use a GOTO.
It is not allowed to use GOTO in a GOSUB, because that way the GOSUB is never left
using an EXIT command. |
|
| Back to top |
|
 |
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Sat Mar 08, 2003 4:32 am Post subject: |
|
|
What you might want to try to do, is to change "EmailSettings" into a gosub routine
as well. That way you could call it from ReadINI. |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Sat Mar 08, 2003 4:34 am Post subject: |
|
|
When it gets to the exit under the close event, it's actually exiting the ReadINI SUB. That's because you don't exit ReadINI if there is no username, you jump out of it to EmailSettings.
So, under DIALOG SHOW try this:
| Code: |
GoSub ReadINI
If @equal(%%UserName,0)
Goto EmailSettings
END
|
And change the ReadINI SUB to this:
| Code: |
:ReadINI
%%UserName = @INIREAD(Pop Settings,UserName,0)
%%Password = @INIREAD(Pop Settings,PassWord,0)
Exit
|
That should fix it for you. _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
GeoTrail Valued Contributor


Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Sat Mar 08, 2003 4:35 am Post subject: |
|
|
Aaa I see, great. And again, thanks alot Tommy.
Can't find anything about in the helpfile though  _________________
 |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Sat Mar 08, 2003 4:36 am Post subject: |
|
|
Yikes, I see Tommy got to it a few times before I did. LoL _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
GeoTrail Valued Contributor


Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Sat Mar 08, 2003 4:45 am Post subject: |
|
|
He he thanks to both of you guys.
I change the EmailSettings into a sub routine and it worked great Yiihhaaa.
While I'm here.
I've been looking at the email program Mac made. Very nice.
But I can't figure out how the program finds the id# of the mails.
What I want is to read the subject of the mail with the highest id number.
Probably isn't hard, but got really confused by the code Mac did in his program. Alittle out of my leage I guess.
I'm guessing this is where it finds the id number, but I can't figure out how that works
| Code: | if @equal(@internet(pop3,connected,1),1)
rem -- return the number of email messages on the server --
DIALOG SET, Stat, CHECKING MAIL...
%%msgcount = @internet(pop3,msgcount,1)
if @greater(%%msgcount, 0)
%%num = 1
%m = ""
REPEAT
DIALOG SET, Stat, RETRIEVING MAIL %%num...
INTERNET POP3,GETHEADER,1,%%num
rem -- Wait for "POP31ONGETHEADERDONE" event, or 3 minutes... --
WAIT EVENT,180
if @equal(@event(),"POP31ONGETHEADERDONE")
%m = %m@cr()@cr()From: @internet(pop3,from,1)@cr()Subject: @internet(pop3,subject,1)@cr()@internet(pop3,msgsize,1,%%num) bytes
%%num = @succ(%%num)
else
%%num = "ERROR"
end
UNTIL @greater(%%num, %%msgcount)@equal(%%num, "ERROR")
end
else
WARN Cannot connect to mail server...@tab()
goto DESTROY
end |
_________________
 |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|