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

  1. // CLIENTNAME.SCP Functions to process Client Name tokens
  2. // Copyright (c) 1999, Vector Networks Limited
  3. // All Rights Reserved
  4. //
  5. // Revision History:
  6. // 0.0 13-Jan-00 DB  - Created to test $INCLUDE functions
  7.  
  8. $INCLUDE "RINSTR.SCP"
  9.  
  10. //  Convert_Client_Params is used to convert a Control $CLIENTNAME$ token 
  11. //  format Client name and address ("NAME(ADDRESS_TRANSPORT) into the
  12. //  format returned by Lookup ("NAME|ADDRESS<TRANSPORT>").
  13.  
  14. Function Convert_Client_Params (ClientName) as String
  15. Dim Name, Address, Transport
  16. Dim LeftIndex, MidIndex, RightIndex
  17.  
  18.     //  Look for the delimiters
  19.  
  20.     LeftIndex = InStr (ClientName, "(")
  21.     MidIndex = InStr (ClientName, "_")
  22.  
  23.     // We can't use ")" as a parameter without provoking 
  24.     // a compiler error, so we use Chr (41) instead...
  25.  
  26.     RightIndex = RInStr (ClientName, Chr (41))
  27.  
  28.     //  If all of the *Index variables are greater than 0, we might have 
  29.     //  a valid ClientName to parse. Strictly speaking, we should also
  30.     //    check that they are in ascending order...
  31.  
  32.     If (MidIndex > LeftIndex) AND (RightIndex > MidIndex) then
  33.         Name = Left (ClientName, LeftIndex - 1) 
  34.         Address = Mid (ClientName, LeftIndex + 1, MidIndex - LeftIndex + 1) 
  35.         Transport = Mid (ClientName, MidIndex + 1,  RightIndex - MidIndex + 1)
  36.  
  37.         Print "    Name: ", Name
  38.         Print "    Transport: ", Transport
  39.         Print "    Address: ", Address
  40.  
  41.         // The transport format needs a little tweaking
  42.  
  43.         If Transport = "TCP/IP" Then
  44.             Transport = "TCP"
  45.         Else
  46.  
  47.             // I suspect NetBIOS adapters need a bit of fiddling too...
  48.  
  49.         Endif
  50.  
  51.         Convert_Client_Params = Name + "|>" + Address + "<" + Transport + ">")
  52.     Else
  53.         Print "Parsing failed for: ", ClientName
  54.         Print "    LeftIndex: ", LeftIndex
  55.         Print "    MidIndex: ", MidIndex
  56.         Print "    RightIndex: ", RightIndex
  57.         Convert_Client_Params = ClientName 
  58.     Endif
  59. End Function
  60.