home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / pibterm / pibt41e3.zip / NAMEDIAL.SCR < prev    next >
Text File  |  1988-02-26  |  5KB  |  105 lines

  1. **************************************************************************
  2. *                                                                        *
  3. *    This script demonstrates how to write a "dial by name" command.     *
  4. *    You can attach this script to a definable key using <ALT>K          *
  5. *    by entering this as the definition of that key:                     *
  6. *                                                                        *
  7. *         @G@/NAMEDIAL^M/                                                *
  8. *                                                                        *
  9. *    This allows you to dial systems by name rather than entry number    *
  10. *    simply hitting the defined key.                                     *
  11. *                                                                        *
  12. **************************************************************************
  13. *
  14. *                                  Holds name of system to dial
  15.  Declare Name String
  16. *                                  Holds one directory entry
  17.  Declare DirEnt String
  18. *                                  Number of dialing directory entries
  19.  Declare NEntries Integer
  20. *                                  Number of dialing directory entries (string)
  21.  Declare SEntries String
  22. *                                  Current entry number
  23.  Declare IEntry   Integer
  24. *                                  Flag telling if we find emtry
  25.  Declare Found    Integer
  26. *                                  Issue prompt for name of system to dial
  27. *                                  and read name.
  28. *
  29.  Writeln " "
  30.  Input   "System to dial? " Name
  31.  Writeln " "
  32. *
  33. *                                  If name is null, exit this script.
  34. *
  35.  If ( LENGTH( Name ) = 0 ) Then
  36.     Exit
  37.  Endif
  38. *                                  Convert name to upper case
  39.  Set Name = UpperCase( Name )
  40. *                                  Get number of dialing directory entries
  41.  GetParam 'DS'  SEntries
  42. *                                  Convert from string to integer for looping
  43.  Set NEntries = Number( SEntries )
  44. *                                  Make sure we have some entries, else quit.
  45. *
  46.  If ( NEntries < 1 ) Then
  47.     Exit
  48.  Endif
  49. *                                  Found = 0 means no entry found yet.
  50.  Set Found = 0
  51. *                                  IEntry starts out pointing to first
  52. *                                  entry in dialing directory.
  53.  Set IEntry = 1
  54. *                                  Scan dialing entries and look for match.
  55. *
  56.  Repeat
  57. *                                  --- Get next dialing entry using
  58. *                                      "DialEntry" function.
  59. *
  60. *                                      Strip off stuff after name/number using
  61. *                                      the "Substr" function and convert the
  62. *                                      name/number to uppercase using the
  63. *                                      "UpperCase" function.
  64. *
  65.     Set DirEnt = UpperCase( Substr( DialEntry( IEntry ), 1, 40 ) )
  66. *
  67. *                                  --- Search for the desired name using the
  68. *                                      "Index" function.  If the search string
  69. *                                      is found in the current entry, then
  70. *                                      set Found to 1 so that the search loop
  71. *                                      will terminate.  If the name isn't found
  72. *                                      in the current entry, then increment
  73. *                                      "IEntry" to point to the next dialing
  74. *                                      directory entry.
  75. *
  76.     If ( Index( Name , DirEnt ) > 0 ) Then
  77.        Set Found = 1
  78.     Else
  79.        Set IEntry = IEntry + 1
  80.     Endif
  81. *
  82.  Until ( ( Found = 1 ) OR ( IEntry > NEntries ) )
  83. *
  84. *                                  If entry not found, issue message and
  85. *                                  exit script.
  86. *
  87.  If ( Found = 0 ) THEN
  88.     Writeln "Name not found."
  89.     Writeln " "
  90.     Exit
  91.  Endif
  92. *                                  If entry found, dial it.   Note that
  93. *                                  dialing command wants the entry number
  94. *                                  as a string, so we must convert it to
  95. *                                  a string for use with the dialing command.
  96. *
  97. *                                  Note that you can do fancier processing
  98. *                                  at this point, like adding prefix/postfix
  99. *                                  codes, or checking for long distance
  100. *                                  area codes, and so on.  Just modify the
  101. *                                  value of  Name  to match your requirements.
  102.  Set    Name = STRING( IEntry )
  103. *
  104.  Dial   Name
  105. *