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

  1. // ASC.SCP - Function to convert a character into an integer
  2. // Copyright (c) 2000, Vector Networks Limited
  3. // All Rights Reserved
  4. //
  5. // Revision History:
  6. //  5.3 31-Jul-00 DB  - Created.
  7.  
  8. //  There is no Scripting function to return the integer value of a
  9. //  character. This makes (signed) comparisons impossible, and 
  10. //  hence strings cannot be sorted. The Asc () function makes up
  11. //  for this by performing the conversion the hard way...
  12.  
  13. Function Asc (Character as String) as Integer
  14. Dim Result as Integer
  15.  
  16.     Result = 0
  17.  
  18.     If IsString (Character) then
  19.         For x = 0 to 255
  20.             If Chr (x) = Character then
  21.                 Result = x
  22.                 Exit For
  23.             Endif
  24.         Next
  25.     Endif
  26.  
  27.     Asc = Result
  28. End Function
  29.