Article View: news.software.readers
Article #164813[Dialog] Dialup scripting
From: Winston
Date: Sat, 02 Apr 2005 09:38
Date: Sat, 02 Apr 2005 09:38
79 lines
3478 bytes
3478 bytes
The Dialog scripting section in the wiki contains a useful script to
automate dialup connection.
It looks like this (with some small changes)
Program DialUp;
uses Forms;
{$I zRas}
var myProvider, myUsername, myPassword: String;
connection: LongWord;
dialedByScript: Boolean;
Begin
// dial-up parameters
myProvider := 'Xtra';
myUsername := 'pjd48';
myPassword := 'heref0rd';
// check, if already connected
dialedByScript := False;
connection := RasGetConnection();
if connection = 0 then begin
// no connection, so script dials up now
dialedByScript := True;
writeToLog('Connecting to ' + myProvider + '...',1);
connection := RasDial( myProvider, myUsername, myPassword );
if connection = 0 then begin
writeToLog( 'Dialing failed! Error: '
+ RasErrorText(RasLastError),1);
exit;
end
else begin
writeToLog('Connected to ' + myProvider,1);
end;
end;
// transfer data
ADo('OnlineMode');
ADo('SendAllInOutbox');
ADo('GetNewHeadersInSubscribedGroups');
ADo('GetNewEmailsForAllIdentities');
ADo('GetMarkedMessageBodies');
// hangup, if script has dialed
//Only when we have gone offline
(*
while (AChecked('OnlineMode') = true) do begin
Sleep(0);
end;
if dialedByScript then begin
writeToLog('Disconnecting from ' + myProvider,1);
RasHangup( connection );
end;
*)
End.
The commented out bit at the end is because the default of executing the
last few lines doesn't work properly (if dialedByScript...
Apparently because the commands are executed asynchronously
The waiting until OnlineMode goes off works fine in the scripting windows
but if the script is run from Dialog it makes Dialog hang
Sleep is the only thing actually available to use
Application.Processmessages which Delphi programmers would use is not
available here
In any case OnlineMode never goes off by itself
The user has to tell the application to go offline
What I need is some foolproof way of discovering that Dialog has
disconnected from the server and then being able to effect an automatic
disconnection of the connectoid. I don't see a way to do it with the built
in functions of the Pascal scripting except for that shown above - which
doesn't work
Technical Details
Message-ID:
<13a9dvy52pj4w.4dkx895vrgh0$.dlg@40tude.net>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nntp1.phx1.gblx.net!nntp.gblx.net!nntp.gblx.net!newsfeed.news2me.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!news.xtra.co.nz!53ab2750!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <13a9dvy52pj4w.4dkx895vrgh0$.dlg@40tude.net> Subject: [Dialog] Dialup scripting Date: Sat, 2 Apr 2005 21:38:08 +1200 From: Winston <winnie@privacy.nest> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nntp1.phx1.gblx.net!nntp.gblx.net!nntp.gblx.net!newsfeed.news2me.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!news.xtra.co.nz!53ab2750!not-for-mail Newsgroups: news.software.readers User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-No-Archive: Yes Lines: 79 NNTP-Posting-Host: 210.55.120.234 X-Complaints-To: abuse@xtra.co.nz X-Trace: news.xtra.co.nz 1112434543 210.55.120.234 (Sat, NNTP-Posting-Date: Sat, 02 Apr 2005 21:35:43 NZST Organization: Xtra