ScriptzRasDemo

From 40tude Dialog Wiki

zRasDemo.ds - Dialog demo script for include file zRas.ds

See Handle dialup connections for details.



// ===========================================================================
// zRasDemo.ds
// Dialog demo script for include file "zRas.ds"
// Version 2003-08-03 (Jürgen Haible, http://www.elbiah.de/tools/dialog/)
// ===========================================================================

Program zRasDemo;

uses Forms;

{$I zRas}

var  myProvider, myUsername, myPassword: String;
     connection: LongWord;
     dialedByScript: Boolean;

Begin

   // dial-up parameters
   myProvider := 'provider';
   myUsername := 'username';
   myPassword := 'password';

   // check, if already connected
   dialedByScript := False;
   connection := RasGetConnection();

   if connection = 0 then begin

      // no connection, so script dials up now
      dialedByScript := True;
      connection := RasDial( myProvider, myUsername, myPassword );

      if connection = 0 then begin
         Application.MessageBox( 'Dialing failed! Error: '
             + RasErrorText(RasLastError), 'Dial', 0 );
         exit;
      end;

   end;

   // transfer data
   ADo('SendAllInOutbox');
   ADo('GetNewHeadersInSubscribedGroups');
   ADo('GetNewEmailsForAllIdentities');

   // hangup, if script has dialed
   if dialedByScript then begin
      RasHangup( connection );
   end;

End.


Juergen Haible