home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / haotd1_1.zip / PCWEXP.WAS < prev    next >
Text File  |  1995-10-12  |  7KB  |  313 lines

  1. ; *
  2. ; *  $Revision: 1.1 $
  3. ; *  $Date: 1995/07/19 11:25:56 $
  4. ; *
  5.  
  6.  
  7. ; Global variables defined.
  8. ;
  9. string sPcPlusDir, sProgress1, sExportName, sFullName, sTemp
  10. integer itemp
  11.  
  12.  
  13. ;/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  14. ; * FUNCTION:
  15. ; *     main
  16. ; *
  17. ; * DESCRIPTION:
  18. ; *     This routine calls a few functions to obtain file names, then
  19. ; *     writes out a simple ascii file that can be used with Hilgraeve's
  20. ; *     convert program.  The convert program reads the ascii file produced
  21. ; *     by this script and create HA\Win session files.
  22. ; *
  23. ; * ARGUMENTS:
  24. ; *
  25. ; * RETURNS:
  26. ; *
  27. ; */
  28. proc main
  29.     integer index, nDataBits, nParity, nStopBits, nLocalEcho, nFileIndex
  30.     string    sName, sNumber, sEmulation, sPCEmu
  31.     long    lRate
  32.     string    LineOut
  33.  
  34.     SelectDirectoryFile()
  35.  
  36.     if strcmp sPcPlusDir $NULLSTR
  37.         Exit
  38.     endif
  39.  
  40.     if not $DIALCOUNT > 0
  41.         errormsg "There are no entries in this dialing directory"
  42.         Exit
  43.     endif
  44.  
  45.     GetExportFileName()
  46.  
  47.     ; Open the export file
  48.     ;
  49.     nFileIndex = 0
  50.     fopen nFileIndex sExportName CREATE TEXT
  51.     if not success
  52.         strfmt sName "Can't create %s" sExportName
  53.         errormsg sName
  54.         Exit
  55.     endif
  56.  
  57.     ; Display a dialog box to show conversion progress.
  58.     ;
  59.     sProgress1 = $NULLSTR
  60.  
  61.     dialogbox 26 19 200 50 15 "Progress!"
  62.         vtext 10 10 197 27 left sProgress1
  63.     enddialog
  64.  
  65.     for index = 1 upto $DIALCOUNT
  66.  
  67.         set dialdir access index
  68.  
  69.         sName = $D_NAME
  70.         sNumber = $D_NUMBER
  71.  
  72.         ;fetch terminal type sEmulation
  73.  
  74.         fetch baudrate lRate
  75.         fetch port databits nDataBits
  76.         fetch port parity nParity
  77.         fetch port stopbits nStopBits
  78.         fetch port duplex nLocalEcho
  79.  
  80.         ; Procomm bug reports 655350 when baud rate == 115200
  81.         ;
  82.         if lRate > 115200
  83.             lRate = 115200
  84.         endif
  85.  
  86.         ; Determine emulation
  87.         ;
  88.         fetch terminal type sPCEmu
  89.         switch sPCEmu
  90.             case "ADDS 60"
  91.             case "ADDS 90"
  92.                 sEmulation = "Viewpoint"
  93.             endcase
  94.             case "ADM 31"
  95.             case "ADM 3a"
  96.             case "ADM 5"
  97.                 sEmulation = "ADM3A"
  98.             endcase
  99.             case "ANSI BBS"
  100.             case "IBM PC"
  101.                 sEmulation = "ANSI"
  102.             endcase
  103.             case "IBM 3101"
  104.             case "IBM 3161"
  105.                 sEmulation = "IBM 3101"
  106.             endcase
  107.             case "IBM 3270"
  108.                 sEmulation = "IBM 3270"
  109.             endcase
  110.             case "TTY"
  111.                 sEmulation = "TTY"
  112.             endcase
  113.             case "TVI 910"
  114.             case "TVI 912"
  115.             case "TVI 920"
  116.             case "TVI 922"
  117.             case "TVI 925"
  118.                 sEmulation = "TV925"
  119.             endcase
  120.             case "TVI 950"
  121.             case "TVI 955"
  122.                 sEmulation = "TV950"
  123.             endcase
  124.             case "VT-52"
  125.                 sEmulation = "VT52"
  126.             endcase
  127.             case "VT-100"
  128.                 sEmulation = "VT100"
  129.             endcase
  130.             case "VT-102"
  131.                 sEmulation = "VT102"
  132.             endcase
  133.             case "VT-220"
  134.                 sEmulation = "VT220"
  135.             endcase
  136.             case "VT-320"
  137.                 sEmulation = "VT320"
  138.             endcase
  139.             case "VIDEX"
  140.                 sEmulation = "CompuServe"
  141.             endcase
  142.             default
  143.                 sEmulation = "TTY"
  144.             endcase
  145.         endswitch
  146.  
  147.         ; Remove any commas from the string variables.    This is the field
  148.         ; delimiter.
  149.         ;
  150.         strreplace sName "^" "-"
  151.         strreplace sNumber "^" "-"
  152.         strreplace sEmulation "^" "-"
  153.  
  154.         strfmt LineOut "%s^%s^%s^%ld^%d^%d^%d^%d"  \
  155.                         sName sNumber sEmulation lRate nDataBits \
  156.                         nParity nStopBits, nLocalEcho
  157.  
  158.         fputs nFileIndex Lineout
  159.         strfmt sProgress1 "Converting entry %d of %d" index, $DIALCOUNT
  160.         updatedlg 64
  161.  
  162.     endfor
  163.  
  164.     destroydlg
  165.  
  166.     ; Close the export file.
  167.     ;
  168.     fclose nFileIndex
  169.     fullpath sExportName, sFullName
  170.  
  171.     ; Tell the user what has happened.
  172.     ;
  173.     ;strfmt LineOut, "Conversion of %s complete.  %d entries have been exported to the file named %s" \
  174.      ;                 sPcPlusDir, $DIALCOUNT, sFullName
  175.  
  176. strfmt LineOut, \
  177. "Conversion of %s complete.  %d entries have been exported to the file named %s.  \
  178. You may now run Hilgraeve's Conversion program using this export file." \
  179. sPcPlusDir, $DIALCOUNT, sFullName
  180.  
  181.  
  182.     usermsg LineOut
  183.  
  184.     Exit
  185.  
  186. endproc
  187.  
  188. ;/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  189. ; * FUNCTION:
  190. ; *     SelectDirectoryFile
  191. ; *
  192. ; * DESCRIPTION:
  193. ; *     This routine allows the user to select the Procomm for Windows
  194. ; *     dialing directory that is to be converted.
  195. ; *
  196. ; * ARGUMENTS:
  197. ; *
  198. ; * RETURNS:
  199. ; *
  200. ; */
  201. proc SelectDirectoryFile
  202.     string    sTestName
  203.     long    lFileSIze
  204.  
  205.     dialogbox 26 19 200 90 15 "Enter file"
  206.         text 10 10 197 27 left "This program converts a Procomm Plus for Windows"
  207.         text 10 17 197 27  left "dialing directory into an export file for use with"
  208.         text 10 24 197 27  left "Hilgraeve's Convert program."
  209.         text 10 38 197 27  left "Dialing directory to be converted:"
  210.         editbox 10 48 130 12 sPcPlusDir
  211.         pushbutton 10 68 40 14 "OK" NORMAL
  212.         pushbutton 60 68 40 14 "Cancel" CANCEL
  213.         pushbutton 150 48 40 14 "Browse" NORMAL
  214.     enddialog
  215.  
  216.     itemp = $dialog
  217.  
  218.     while 1
  219.         if itemp == 10              ; OK pressed!
  220.  
  221.             ; Validate the    name by checking to see if the extension
  222.             ; is at least ".dir"
  223.             ;
  224.             sTestName = sPcPlusDir
  225.             strright sTestName sPcPlusDir 4
  226.             strlwr sTestName
  227.  
  228.             if not strcmp sTestname ".dir"
  229.                 errormsg "Invalid file name.  Please try again."
  230.             else
  231.                 ; Now name sure the file exists.
  232.                 ;
  233.                 getfsize sPcPlusDir lFileSize
  234.                 if not success
  235.                     errormsg "Invalid file name.  Please try again."
  236.                 else
  237.                     dialload sPcPlusDir
  238.                 endif
  239.                 exitwhile
  240.             endif
  241.  
  242.         endif
  243.  
  244.         if itemp == 1              ; Cancel pressed!
  245.             exitwhile
  246.         endif
  247.  
  248.         if itemp == 11              ; Browse
  249.             dir "*.dir" sPcPlusDir
  250.             updatedlg 128
  251.         endif
  252.  
  253.         itemp = $dialog
  254.     endwhile
  255.  
  256.     destroydlg
  257.  
  258. endproc
  259.  
  260.  
  261. ;/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  262. ; * FUNCTION:
  263. ; *
  264. ; * DESCRIPTION:
  265. ; *
  266. ; * ARGUMENTS:
  267. ; *
  268. ; * RETURNS:
  269. ; *
  270. ; */
  271. proc GetExportFileName
  272.     long lFileSize
  273.     string sName
  274.  
  275.     ; Fully quallify the name and see if it exists.  If it does,
  276.     ; ask the user if it's OK to overwrite the file.  If OK, continue,
  277.     ; otherwise exit the script.
  278.     ;
  279.     sName = "tohaos2.exp"
  280.     fullpath sName sExportName
  281.     getfsize sExportName lFileSize
  282.     if success
  283.  
  284.         strfmt sTemp "The file %s already exists." sExportName
  285.  
  286.         dialogbox 26 19 200 70 15 "File Exists!"
  287.             vtext 10 10 197 27 left sTemp
  288.             text 10 24 197 27  left "The file will be overwritten!"
  289.             pushbutton 10 40 40 14 "OK" NORMAL
  290.             pushbutton 60 40 40 14 "Cancel" CANCEL
  291.         enddialog
  292.  
  293.         itemp = $dialog
  294.  
  295.         while 1
  296.             if itemp == 10              ; OK pressed!
  297.                 exitwhile
  298.             endif
  299.  
  300.             if itemp == 1              ; Cancel pressed!
  301.                 destroydlg
  302.                 Exit
  303.             endif
  304.  
  305.             itemp = $dialog
  306.         endwhile
  307.  
  308.         destroydlg
  309.  
  310.     endif
  311.  
  312. endproc
  313.