HandleDialupConnections

From 40tude Dialog Wiki

Handle dialup connections

zRas.ds is a library that provides functions to handle dialup connections in Dialog scripts. It is intended to be included in other scripts by the {$I ...} directive, i. e. the following way:

   Program Testscript;
   {$I zRas.ds}
   Begin
      //
   End.


Please note, that this {$I ...} directive is only available in Dialog version 2.0.5.67 and above. For older versions of Dialog, just insert the code of zRas.ds right after the initial Program line.

Users of Dialog vr. 2.0.5.1 can also download a ready-to-run example at: http://www.elbiah.de/tools/dialog/zRasXDemo.ds

Below you find a summary of the most useful functions included in zRas.ds. There is also a commented demo script zRasDemo.ds, which demonstrates its usage.

Additionally, there is another include file zRasDialer.ds, which provides a small dialog to select the connection to dial and to enter username and password for it. Script zRasDialerDemo.ds demonstrates its usage.


Summary of most useful functions


// ---------------------------------------------------------------------------
// RasGetConnection: Get current connection
//    Returns: Identifier of current connection, 0 if not connected.

function RasGetConnection: LongWord;


// ---------------------------------------------------------------------------
// RasGetConnectionName: Get name of current connection
//    Returns: Name of current connection, '' if not connected.

function RasGetConnectionName: String;


// ---------------------------------------------------------------------------
// RasAnyConnected: Check if any connection is established
//    Returns: True if connected

function RasAnyConnected(): Boolean;


// ---------------------------------------------------------------------------
// RasDial: Dial phonebook entry
//    EntryName: Name of phonebook entry to dial
//    Username: Username to login
//    Password: Password to login
//    Returns: Connection identifier on success, 0 on failure.
(*
   // Example:
   var connection: LongWord;
   Begin
      connection := RasDial( 'myProvider', 'myName', 'myPassword' );
      if connection = 0 then begin
         writeln( 'Dialing failed: ' + RasErrorText(RasLastError) );
      end else begin
         // [[transfer data here]]
         RasHangup( connection );
      end;
   End.
*)

function RasDial( EntryName, Username, Password: String ): LongWord;


// ---------------------------------------------------------------------------
// RasHangup: Hangup specific connection
//    connection: connection identifier
//    Returns: True if not connected or disconnected successfully

function RasHangup( connection: LongWord ): Boolean;


// ---------------------------------------------------------------------------
// RasHangup: Hangup all active connections
//    Returns: True if not connected or all disconnected successfully

function RasHangupAll(): Boolean;


// ---------------------------------------------------------------------------
// RasEnumEntries: Get list of available phonebook entries
//    RasList: TStringList that is filled with names
//    Returns: True if list could be filled.
(*
   // Example:
   var RasList: TStringList;
       i: Integer;
   Begin
      RasList := TStringList.Create();
      RasEnumEntries( RasList );
      for i := 0 to RasList.Count - 1 do writeln( RasList.Strings[[i]] );
      RasList.Free;
   End.
*)

function RasEnumEntries( RasList: TStringList ): Boolean;


JuergenHaible