home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Demo / PCDUO / data1.cab / Script_Samples / GTREMOTE.scp < prev    next >
Encoding:
Text File  |  2003-11-28  |  2.2 KB  |  75 lines

  1. // GTREMOTE.SCP - Sample Script which reads from REMOTE.NSM
  2. // Copyright (c) 2001-2002, Vector Networks Limited
  3. // All Rights Reserved
  4. //
  5. // Revision History:
  6. // 7.0 20-Mar-02 DB  - Separated from GRPFLUPD.SCP.
  7.  
  8. // GetRemote is used to retrieve full details of a Remote Network from the 
  9. // Known Networks file, REMOTE.NSM, returning the results in a string. 
  10. // There are no built-in functions to do this directly. 
  11. //
  12. // The REMOTE.NSM file is in the following format:-
  13. // Name|Description|Number|Transport
  14.  
  15. Function GetRemote (Network as String, Profile as String) as String
  16.   Dim RemoteName as String, RemoteFile as String, Line as String
  17.   Dim Handle, Lines, Tokens, SplitLine as List, NetworkDetails as String
  18.   Dim CurrentGroup as String, ClientCount
  19.  
  20.   //  Initialise counter variables
  21.  
  22.   Lines = 0
  23.  
  24.   If  Len (Network) > 0 Then
  25.     Print "Searching for Remote Network : ", Network
  26.   
  27.     //  Now, we look it up in the GROUP.NSM file.
  28.  
  29.     RemoteFile = GetControlFile ("REMOTE.NSM", Profile)
  30.  
  31.     If (FileExists (RemoteFile)) Then
  32.       Handle = Open (RemoteFile, FILE_READ)
  33.  
  34.       If Handle !=0 Then
  35.         Print "Reading file " + RemoteFile + "..."
  36.         Print "File handle: ", Handle
  37.  
  38.         Lines = 0
  39.  
  40.         Do Until EOF (Handle)
  41.           Line = ReadLine (Handle)
  42.           Lines = Lines + 1
  43.           Print "Line ", Lines, " <", Line, ">"
  44.  
  45.           If Trim (Line) != "" Then
  46.             SplitLine = TokenList (Line, "|")
  47.             If Items (SplitLine) > 3 Then
  48.               RemoteName = GetItem (SplitLine, 1)
  49.               If (RemoteName = Network) Then
  50.                 NetworkDetails = Line
  51.                 Exit Do
  52.               Endif
  53.             Endif
  54.           Else
  55.             Print "Skipping blank line"
  56.           Endif
  57.         Loop
  58.  
  59.         Print "Summary"
  60.         Print Lines, " lines processed"
  61.         Close (Handle)
  62.       Endif
  63.     Else
  64.       Print "ERROR: Unable to open Remote file : ", RemoteFile
  65.     Endif
  66.   Else
  67.     //  No Remote Network name provided
  68.   Endif
  69.  
  70.   If (NetworkDetails != "") Then
  71.     Print "Network : ", Network, " Details : ", NetworkDetails
  72.   Endif
  73.   GetRemote = NetworkDetails
  74. End Function
  75.