home *** CD-ROM | disk | FTP | other *** search
- ; *
- ; * $Revision: 1.2 $
- ; * $Date: 1995/08/11 12:15:21 $
- ; *
-
-
- ; Global variables defined.
- ;
- string sPcPlusDir, sProgress1, sExportName, sTemp, sNumber
- integer iCount
-
-
- ;/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- ; * FUNCTION:
- ; * main
- ; *
- ; * DESCRIPTION:
- ; * This routine calls a few functions to obtain file names, then
- ; * writes out a simple ascii file that can be used with Hilgraeve's
- ; * convert program. The convert program reads the ascii file produced
- ; * by this script and create HA\Win session files.
- ; *
- ; * ARGUMENTS:
- ; *
- ; * RETURNS:
- ; *
- ; */
- proc main
- integer index, nDataBits, nParity, nStopBits, nLocalEcho, nFileIndex, iLoop
- string sName, sEmulation, sPCEmu
- long lRate
- string LineOut
-
- SelectDirectoryFile()
-
- if strcmp sPcPlusDir $NULLSTR
- Exit
- endif
-
- dialcount DATA iCount
- if iCount == 0
- errormsg "There are no entries in this dialing directory"
- Exit
- endif
-
- GetExportFileName()
-
- ; Open the export file
- ;
- nFileIndex = 0
- fopen nFileIndex sExportName CREATE TEXT
- if FAILURE
- strfmt sName "Can't create %s" sExportName
- errormsg sName
- Exit
- endif
-
- ; Display a dialog box to show conversion progress.
- ;
- sProgress1 = $NULLSTR
-
- dialogbox 1 26 19 200 50 3 "Progress!"
- text 1 10 10 197 27 sProgress1 LEFT
- enddialog
-
- iLoop = iCount - 1
- for index = 0 upto iLoop
-
- ; Get the name of the system based on the index.
- ;
- dialname DATA index sName
-
- ; Lock Aspect into that system. Subsequent fetch statements
- ; will work on this system.
- ;
- set dialentry access sName
-
- ; Get the phone number fields.
- ;
- ConstructDialString()
-
- ; Get port parameters.
- ;
- fetch port baudrate lRate
- fetch port databits nDataBits
- fetch port parity nParity
- fetch port stopbits nStopBits
- fetch port duplex nLocalEcho
-
- ; Determine emulation
- ;
- fetch terminal type sPCEmu
- switch sPCEmu
- case "ADDS 60"
- case "ADDS 90"
- sEmulation = "Viewpoint"
- endcase
- case "ADM 31"
- case "ADM 3a"
- case "ADM 5"
- sEmulation = "ADM3A"
- endcase
- case "ANSI BBS"
- case "IBM PC"
- sEmulation = "ANSI"
- endcase
- case "IBM 3101"
- case "IBM 3161"
- sEmulation = "IBM 3101"
- endcase
- case "IBM 3270"
- sEmulation = "IBM 3270"
- endcase
- case "TTY"
- sEmulation = "TTY"
- endcase
- case "TVI 910"
- case "TVI 912"
- case "TVI 920"
- case "TVI 922"
- case "TVI 925"
- sEmulation = "TV925"
- endcase
- case "TVI 950"
- case "TVI 955"
- sEmulation = "TV950"
- endcase
- case "VT-52"
- sEmulation = "VT52"
- endcase
- case "VT-100"
- sEmulation = "VT100"
- endcase
- case "VT-102"
- sEmulation = "VT102"
- endcase
- case "VT-220"
- sEmulation = "VT220"
- endcase
- case "VT-320"
- sEmulation = "VT320"
- endcase
- case "VIDTEX"
- sEmulation = "CompuServe"
- endcase
- default
- sEmulation = "TTY"
- endcase
- endswitch
-
- ; Remove any field delimiters from the string variables.
- ;
- strreplace sName "^" "-"
- strreplace sNumber "^" "-"
- strreplace sEmulation "^" "-"
-
- strfmt LineOut "%s^%s^%s^%ld^%d^%d^%d^%d" \
- sName sNumber sEmulation lRate nDataBits \
- nParity nStopBits nLocalEcho
-
- fputs nFileIndex Lineout
- strfmt sProgress1 "Converting entry %d of %d" index, iCount
- dlgupdate 1 1
-
- mspause(100)
-
- endfor
-
- dlgdestroy 1 OK
-
- ; Close the export file.
- ;
- fclose nFileIndex
-
- ; Tell the user what has happened.
- ;
- strfmt LineOut, \
- "Conversion of %s complete. %d entries have been exported to the file named %s. \
- You may now run Hilgraeve's Conversion program using this export file." \
- sPcPlusDir, iCount, sExportName
-
- usermsg LineOut
-
- Exit
-
- endproc
-
- ;/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- ; * FUNCTION:
- ; * SelectDirectoryFile
- ; *
- ; * DESCRIPTION:
- ; * This routine allows the user to select the Procomm for Windows
- ; * dialing directory that is to be converted.
- ; *
- ; * ARGUMENTS:
- ; *
- ; * RETURNS:
- ; *
- ; */
- proc SelectDirectoryFile
- string sTestName, sFileSpec
- integer iEvent
-
- dialogbox 2 26 19 200 90 3 "Enter file"
- text 1 10 10 197 27 "This program converts a Procomm Plus for Windows" LEFT
- text 2 10 17 197 27 "dialing directory into an export file for use with" LEFT
- text 3 10 24 197 27 "Hilgraeve's Convert program." LEFT
- text 4 10 38 197 27 "Dialing directory to be converted:" LEFT
- editbox 5 10 48 130 12 sPcPlusDir
- pushbutton 6 10 68 40 14 "OK" OK
- pushbutton 7 60 68 40 14 "Cancel" CANCEL
- pushbutton 8 150 48 40 14 "Browse"
- enddialog
-
- while 1
-
- dlgevent 2 iEvent
-
- switch iEvent
-
- case 6 ; OK pressed!
-
- ; Validate the name by checking to see if the extension
- ; is at least ".dir"
- ;
- sTestName = sPcPlusDir
- strright sTestName sPcPlusDir 4
- strlwr sTestName
-
- if not strcmp sTestname ".dir"
- errormsg "Invalid file name. Please try again."
- sPcPlusDir = $NULLSTR
- exitwhile
- else
- ; Now make sure the file exists.
- ;
- findfirst sPcPlusDir
- if FAILURE
- errormsg "Invalid file name. Please try again."
- sPcPlusDir = $NULLSTR
- else
- dialload sPcPlusDir
- endif
- exitwhile
- endif
-
- endcase
-
- case 7 ; Cancel was pressed
- sPcPlusDir = $NULLSTR
- exitwhile
- endcase
-
- case 8 ; Browse was selected
- sFileSpec = "*.dir"
- sdlgfopen "Browse" sFileSpec sPcPlusDir
- dlgupdate 2 5
- endcase
-
- endswitch
-
- endwhile
-
- dlgDestroy 2 CANCEL
-
- endproc
-
-
- ;/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- ; * FUNCTION:
- ; *
- ; * DESCRIPTION:
- ; *
- ; * ARGUMENTS:
- ; *
- ; * RETURNS:
- ; *
- ; */
- proc GetExportFileName
- integer iEvent
-
- ; Fully quallify the name and see if it exists. If it does,
- ; ask the user if it's OK to overwrite the file. If OK, continue,
- ; otherwise exit the script.
- ;
- fullpath sExportName "tohaos2.exp"
-
- if isfile sExportName
-
- strfmt sTemp "The file %s already exists." sExportName
-
- dialogbox 3 26 19 200 70 3 "File Exists!"
- text 1 10 10 197 27 sTemp LEFT
- text 2 10 24 197 27 "The file will be overwritten!" LEFT
- pushbutton 3 10 40 40 14 "OK" OK
- pushbutton 4 60 40 40 14 "Cancel" CANCEL
- enddialog
-
- while 1
-
- dlgevent 3 iEvent
-
- switch iEvent
-
- case 3
- exitwhile ; OK was pressed
- endcase
-
- case 4 ; Cancel pressed!
- dlgdestroy 3 OK
- Exit
- endcase
-
- endswitch
-
- endwhile
-
- dlgdestroy 3 OK
-
- endif
-
- return
-
- endproc
-
-
- proc ConstructDialString
-
- integer iCallType, iLen
- string sEntryNumber, sEntryCountryCode, sEntryAreaCode
-
- string sDirAreaCode, sDirCountryCode, sDirItlPrefix
- string sDirLdLineOut, sDirLdPrefix, sDirLocalLineOut
-
- fetch dialentry calltype iCallType
-
- fetch dialentry phonenumber DATA sEntryNumber EXPAND
-
- fetch dialentry countrycode sEntryCountryCode
- fetch dialentry areacode sEntryAreaCode
-
- fetch dialdir areacode sDirAreaCode
- fetch dialdir countrycode sDirCountryCode
- fetch dialdir intlprefix sDirItlPrefix
- fetch dialdir ldlineout sDirLdLineOut
- fetch dialdir ldprefix sDirLdPrefix
- fetch dialdir loclineout sDirLocalLineOut
-
- switch iCallType
-
- ; Internal
- ;
- case 0
- strfmt sNumber "%s" \
- sEntryNumber
- endcase
-
- ; Local
- ;
- case 1
- strfmt sNumber "%s%s" \
- sDirLocalLineOut \
- sEntryNumber
- endcase
-
- ; Long distance
- ;
- case 2
- strfmt sNumber "%s%s %s %s" \
- sDirLdLineOut \
- sDirLdPrefix \
- sEntryAreaCode \
- sEntryNumber
- endcase
-
- ; International
- ;
- case 3
- strfmt sNumber "%s %s %s %s %s" \
- sDirLdLineOut \
- sDirItlPrefix \
- sEntryCountryCode \
- sEntryAreaCode \
- sEntryNumber
- endcase
-
- endswitch
-
- strlen sNumber iLen
- if iLen == 0
- strcpy sNumber "*"
- endif
- endproc
-