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

  1. // LICDNLSR.SCP - Script to analyse the licence data collected by 
  2. // the LICDCOLL.SCP script.
  3. // Copyright (c) 2000, Vector Networks Limited
  4. // All Rights Reserved
  5. //
  6. // Revision History:
  7. // 5.3 2-Aug-00 AB - Created.
  8.  
  9. // Script to analyse data collected by the LIDCOLL.SCP script and
  10. // check that there are enough licences for the number of clients.
  11.  
  12. $INCLUDE "GTCTLDIR.SCP"
  13. $INCLUDE "PARSE.SCP"
  14. $INCLUDE "RINSTR.SCP"
  15.  
  16. Function Main ()
  17.     Dim Handle1, LicDataDir as String, LicenceList as List, Licence as String
  18.     Dim a as Integer, SerialNo as String, MClients as String, MaxClients
  19.     Dim Line as String, TotalLicences, TotalActClnts, TotalMaxClnts
  20.  
  21.     // Initialise the variables that count the total number 
  22.     // of Clients and maximum licences for Clients.
  23.  
  24.     TotalActClnts = 0
  25.     TotalMaxClnts = 0
  26.     TotalLicences = 0
  27.  
  28.     // Open the LICENCE.LST file and for each licence check the 
  29.     // number of clients and the maimum number of clients allowed.
  30.     // Remember the data files are stored in a subdirectory.
  31.  
  32.     LicDataDir = GetControlDir () 
  33.     LicDataDir = LicDataDir + "\LICDATA"
  34.  
  35.     Handle1 = Open (LicDataDir + "\LICENCE.LST", FILE_READ)
  36.     If Handle1 then
  37.  
  38.         // Read the contents of the LICENCE.LST file into a list.
  39.  
  40.         Do until EOF (Handle1)
  41.             Line = ReadLine (Handle1)
  42.             AddItem (LicenceList, Line)
  43.         loop
  44.  
  45.         Close (Handle1)
  46.  
  47.         For each Licence in LicenceList
  48.             TotalLicences = TotalLicences + 1
  49.  
  50.             // Examine each licence to find the serial number and
  51.             // maximum number of Clients.  Then find out from the licences
  52.             // list file how many clients are actually using the licence.
  53.  
  54.             a = InStr (Licence, "|")
  55.             SerialNo = Left (Licence, a - 1)
  56.             b = Len (Licence)
  57.             b = b - a
  58.             MClients = Right (Licence, b)
  59.             MaxClients = CInt (MClients)
  60.             LicListFl = LicDataDir + "\" + SerialNo + ".LST"
  61.             ActualClients = 0
  62.  
  63.             Print "Analysing licence: ", SerialNo
  64.  
  65.             Handle2 = Open (LicListFl, FILE_READ)
  66.             If Handle2 then
  67.                 Do until EOF (Handle2)
  68.                     ReadLine (Handle2)
  69.                     ActualClients = ActualClients + 1
  70.                 loop
  71.                 Close (Handle2)
  72.             endif
  73.  
  74.             Print "    Licensed Clients: ", MaxClients, " Actual Clients: ", ActualClients
  75.             If ActualClients <= MaxClients then
  76.                 Print "    Licence ", SerialNo, " has ", MaxClients - ActualClients, " unused licences."
  77.             Else
  78.                 Print 
  79.                 Print "WARNING: Licence ", SerialNo, " has ", ActualClients - MaxClients, " unlicensed Clients!"
  80.                 Print
  81.             Endif
  82.  
  83.             // Add the values to the counters.
  84.  
  85.             TotalMaxClnts = TotalMaxClnts + MaxClients
  86.             TotalActClnts = TotalActClnts + ActualClients
  87.         Next
  88.  
  89.         // Print the totals.  If there are more clients than there are 
  90.         // licencs for, display a warning message.
  91.  
  92.         Print ""
  93.         Print "Summary:"
  94.         Print "    Total number of licences: ", TotalLicences
  95.         Print "    Maximum licensed Clients: ", TotalMaxClnts
  96.         Print "    Actual number of Clients: ", TotalActClnts
  97.         If TotalActClnts <= TotalMaxClnts then
  98.                 Print "    You have a total of ", TotalMaxClnts - TotalActClnts, " unused licences."
  99.         Else
  100.             Print 
  101.             Print "WARNING: You have a total of ", TotalActClnts - TotalMaxClnts, " unlicensed Clients!"
  102.             Print
  103.         Endif
  104.     else 
  105.         Print "Unable to read LICENCE.LST file!"
  106.     endif
  107. End Function
  108.