Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dialing Directory Export 1

Status
Not open for further replies.

MyFlight

Technical User
Feb 4, 2002
193
Help,

I am writing a script file to Export Multiple Dialing Directories.
I have already figured out how to select the directories needed.

First I need to Change the Path where the File will be saved to from the ProComm Directory to:

C:\Temp Data Files\Raw Data
Here are the Fields in the Directory that I need to export to a Comma deliminated File (CSV)

Name
Area Code
Data Number
Company
User ID
Password
Miscellaneous

I know that using the dialload $DDIRFNAME will load the directory required.
However, I cannot figure out how to export the fields above to the directory specified.

Any help you can provide will be greatly appreciated.



 
You can retrieve this information using the following fetch commands:

Name - retrieved using the dialname command
Area Code - fetch dialentry areacode string
Data Number - fetch dialentry phonenumber string
Company - fetch dialentry company string
User ID - fetch userid string
Password - fetch password string
Miscellaneous - fetch misc string

Where string is replaced by a string variable that will hold the result. I'll see if I can throw together a sample script later tonight, the one I banged together isn't working quite right at the moment.
aspect@aspectscripting.com
 
KNob,

Thanks, will this work for a complete directory of over 20 entries??
 
I don't see why it shouldn't work, since this script (pasted below) will loop through all data entries in the current Connection Directory. As long as there is an entry remaining, then the script should grab the data.

The script below accesses each data entry, then retrieves the necessary information from each entry using various fetch commands. After you have received all of the information via the fetch commands, you would then have the data needed to export that particular entry to your CSV file.

proc main
integer iEntries ;Number of entries in dialing class
integer iCount ;Loop variable
string sName ;Name of Connection Directory entry
string sAreaCode
string sCompany
string sPhoneNumber
string sUserID
string sPassword
string sMisc

dialcount DATA iEntries ;Get number of data entries
for iCount = 0 upto (iEntries - 1)
dialname DATA iCount sName ;Get name of entry based on index
set dialentry access DATA sName ;Turn on dialentry for the current entry
fetch dialentry areacode sAreaCode
fetch dialentry phonenumber sPhoneNumber
fetch dialentry company sCompany
fetch userid sUserID
fetch password sPassword
fetch misc sMisc
endfor
endproc aspect@aspectscripting.com
 
ok,
Here is what I have so far. Of course it does NOT worl. Any help you can offer will be appreciated.

proc main
integer iEntries ;Number of entries in dialing class
integer iCount ;Loop variable
string sName ;Name of Connection Directory entry
string sAreaCode
string sCompany
string sPhoneNumber
string sUserID
string sPassword
string sMisc
string sDirectory = "IBM-SouthCentral-PM.DIR"
string sComma = ","
string fEnd = ".csv"
string sEntry

dialload sDirectory
strcat sDirectory fEnd
; Creates a New Text File With the Name: sDirectory Name + fEnd
fopen 2 sDirectory CREATE TEXT
pause 2
dialcount DATA iEntries ;Get number of data entries
for iCount = 0 upto (iEntries - 1)
dialname DATA iCount sName ;Get name of entry based on index
set dialentry access DATA sName ;Turn on dialentry for the current entry
pause 1
fetch dialentry areacode sAreaCode
fetch dialentry phonenumber sPhoneNumber
fetch dialentry company sCompany
fetch userid sUserID
fetch password sPassword
fetch misc sMisc
strcat sName sComma
strcat sAreaCode sComma
strcat sPhoneNumber sComma
strcat sCompany sComma
strcat sUserID sComma
strcat sPassword sComma
strcat sMisc sComma
strcat sEntry sName
strcat sEntry sAreaCode
strcat sEntry sPhoneNumber
strcat sEntry sCompany
strcat sEntry sUserID
strcat sEntry sPassword
strcat sEntry sMisc
fputs 2 sEntry
fclear 2
pause 1
endfor
fclose 2
endproc

THANKS AGAIN!
 
I haven't had a chance to dig into this yet, but I am seeing something output in the csv file that looks roughly correct. Are you getting output at least?
aspect@aspectscripting.com
 
OK, I see one problem in the script. You need to clear the value of sEntry after you have saved its value to the file, otherwise you will keep appending to the value of sEntry and write incorrect data to the file. Just add the line sEntry = "" after the fputs command and see if that takes care of the problem.
aspect@aspectscripting.com
 
Knob,

Thanks that worked great. I guess it is always the Small things huh. One more question I would like the use to be able to select multiple directories from a list. got it to work however, i would like the list to be propagated from the Procomm directory not what I provide in the Script. We are adding new directory all the Time.

Any help you can offer will be greatly appreciated.
Here is what I have so far.

proc main
string szList, szItem, szNewItem
string fEnd = ".csv"
integer Event
szList = " IBM - BCRS Project.DIR, IBM-Lotus.DIR, IBM-Lotus-PM.DIR, IBM-Northern-CBX.DIR, IBM-Northern-PM.DIR, IBM-SouthCentral-CBX.DIR, IBM-SouthCentral-PM.DIR, IBMSTANDALONE.DIR, IBM-Western-CBX.DIR, IBM-Western-PM.DIR"

dialogbox 0 241 99 152 138 11 "Select The Directories you want Exported"
listbox 1 28 8 90 89 szList multiple szItem sort
pushbutton 2 54 114 40 14 "&OK" OK DEFAULT
enddialog
while 1
dlgevent 0 Event ; Get the dialog event.

switch Event ; Evaluate the event.
case 0 ; No event occurred.
endcase
case 1
endcase
case 2 ; Exit button selected
IF strsearch szItem "IBM BCRS - Project.dir"
szNewItem = "IBM-BCRS - Project.dir"
dialload szNewItem ; Load the specified directory.
strcat szNewItem fEnd
; Creates a New Text File With the Name: szitem + fEnd
fopen 1 szNewItem CREATE TEXT
pause 1
call Exportone
ENDIF
IF strsearch szItem "IBM-Lotus.DIR"
szNewItem = "IBM-Lotus.DIR"
dialload szNewItem ; Load the specified directory.
strcat szNewItem fEnd
; Creates a New Text File With the Name: szitem + fEnd
fopen 2 szNewItem CREATE TEXT
pause 1
call Exporttwo
ENDIF
IF strsearch szItem "IBM-Lotus-PM.DIR"
szNewItem = "IBM-Lotus-PM.DIR"
dialload szNewItem ; Load the specified directory.
strcat szNewItem fEnd
; Creates a New Text File With the Name: szitem + fEnd
fopen 3 szNewItem CREATE TEXT
pause 1
call Exportthree
ENDIF
IF strsearch szItem "IBM-Northern-CBX.DIR"
szNewItem = "IBM-Northern-CBX.DIR"
dialload szNewItem ; Load the specified directory.
strcat szNewItem fEnd
; Creates a New Text File With the Name: szitem + fEnd
fopen 4 szNewItem CREATE TEXT
pause 1
call Exportfour
ENDIF
IF strsearch szItem "IBM-Northern-PM.DIR"
szNewItem = "IBM-Northern-PM.DIR"
dialload szNewItem ; Load the specified directory.
strcat szNewItem fEnd
; Creates a New Text File With the Name: szitem + fEnd
fopen 5 szNewItem CREATE TEXT
pause 1
call Exportfive
ENDIF
IF strsearch szItem "IBM-SouthCentral-CBX.DIR"
szNewItem = "IBM-SouthCentral-CBX.DIR"
dialload szNewItem ; Load the specified directory.
strcat szNewItem fEnd
; Creates a New Text File With the Name: szitem + fEnd
fopen 6 szNewItem CREATE TEXT
pause 1
call Exportsix
ENDIF
IF strsearch szItem "IBM-SouthCentral-PM.DIR"
szNewItem = "IBM-SouthCentral-PM.DIR"
dialload szNewItem ; Load the specified directory.
strcat szNewItem fEnd
; Creates a New Text File With the Name: szitem + fEnd
fopen 7 szNewItem CREATE TEXT
pause 1
call Exportseven
ENDIF
IF strsearch szItem "IBMSTANDALONE.DIR"
szNewItem = "IBMSTANDALONE.DIR"
dialload szNewItem ; Load the specified directory.
strcat szNewItem fEnd
; Creates a New Text File With the Name: szitem + fEnd
fopen 8 szNewItem CREATE TEXT
pause 1
call Exporteight
ENDIF
IF strsearch szItem "IBM-Western-CBX.DIR"
szNewItem = "IBM-Western-CBX.DIR"
dialload szNewItem ; Load the specified directory.
strcat szNewItem fEnd
; Creates a New Text File With the Name: szitem + fEnd
fopen 9 szNewItem CREATE TEXT
pause 1
call ExportNine
ENDIF
IF strsearch szItem "IBM-Western-PM.DIR"
szNewItem = "IBM-Western-PM.DIR"
dialload szNewItem ; Load the specified directory.
strcat szNewItem fEnd
; Creates a New Text File With the Name: szitem + fEnd
fopen 10 szNewItem CREATE TEXT
pause 1
call ExportTen
ENDIF
exitwhile
endcase
default ; Exit case chosen.
exitwhile ; Exit the loop.
endcase
endswitch
endwhile
dlgdestroy 0 CANCEL ; Destroy the dialog box.
endproc
proc exportone
integer iEntries ;Number of entries in dialing class
integer iCount ;Loop variable
string sName ;Name of Connection Directory entry
string sAreaCode
string sCompany
string sPhoneNumber
string sUserID
string sPassword
string sMisc
string sComma = ","
string fEnd = ".csv"
string sEntry
string fName = $DDIRFNAME

dialcount DATA iEntries ;Get number of data entries
for iCount = 0 upto (iEntries - 1)
dialname DATA iCount sName ;Get name of entry based on index
set dialentry access DATA sName ;Turn on dialentry for the current entry
fetch dialentry areacode sAreaCode
fetch dialentry phonenumber sPhoneNumber
fetch dialentry company sCompany
fetch userid sUserID
fetch password sPassword
fetch misc sMisc
strcat sName sComma
strcat sAreaCode sComma
strcat sPhoneNumber sComma
strcat sCompany sComma
strcat sUserID sComma
strcat sPassword sComma
strcat sMisc sComma
strcat sEntry sName
strcat sEntry sAreaCode
strcat sEntry sPhoneNumber
strcat sEntry sCompany
strcat sEntry sUserID
strcat sEntry sPassword
strcat sEntry sMisc
fputs 1 sEntry
sEntry = ""
fclear 1
endfor
fclose 1
endproc
proc exporttwo
integer iEntries ;Number of entries in dialing class
integer iCount ;Loop variable
string sName ;Name of Connection Directory entry
string sAreaCode
string sCompany
string sPhoneNumber
string sUserID
string sPassword
string sMisc
string sComma = ","
string fEnd = ".csv"
string sEntry
string fName = $DDIRFNAME

dialcount DATA iEntries ;Get number of data entries
for iCount = 0 upto (iEntries - 1)
dialname DATA iCount sName ;Get name of entry based on index
set dialentry access DATA sName ;Turn on dialentry for the current entry
fetch dialentry areacode sAreaCode
fetch dialentry phonenumber sPhoneNumber
fetch dialentry company sCompany
fetch userid sUserID
fetch password sPassword
fetch misc sMisc
strcat sName sComma
strcat sAreaCode sComma
strcat sPhoneNumber sComma
strcat sCompany sComma
strcat sUserID sComma
strcat sPassword sComma
strcat sMisc sComma
strcat sEntry sName
strcat sEntry sAreaCode
strcat sEntry sPhoneNumber
strcat sEntry sCompany
strcat sEntry sUserID
strcat sEntry sPassword
strcat sEntry sMisc
fputs 2 sEntry
sEntry = ""
fclear 2
endfor
fclose 2
endproc
proc exportthree
integer iEntries ;Number of entries in dialing class
integer iCount ;Loop variable
string sName ;Name of Connection Directory entry
string sAreaCode
string sCompany
string sPhoneNumber
string sUserID
string sPassword
string sMisc
string sComma = ","
string fEnd = ".csv"
string sEntry
string fName = $DDIRFNAME

dialcount DATA iEntries ;Get number of data entries
for iCount = 0 upto (iEntries - 1)
dialname DATA iCount sName ;Get name of entry based on index
set dialentry access DATA sName ;Turn on dialentry for the current entry
fetch dialentry areacode sAreaCode
fetch dialentry phonenumber sPhoneNumber
fetch dialentry company sCompany
fetch userid sUserID
fetch password sPassword
fetch misc sMisc
strcat sName sComma
strcat sAreaCode sComma
strcat sPhoneNumber sComma
strcat sCompany sComma
strcat sUserID sComma
strcat sPassword sComma
strcat sMisc sComma
strcat sEntry sName
strcat sEntry sAreaCode
strcat sEntry sPhoneNumber
strcat sEntry sCompany
strcat sEntry sUserID
strcat sEntry sPassword
strcat sEntry sMisc
fputs 3 sEntry
sEntry = ""
fclear 3
endfor
fclose 3
endproc
proc exportfour
integer iEntries ;Number of entries in dialing class
integer iCount ;Loop variable
string sName ;Name of Connection Directory entry
string sAreaCode
string sCompany
string sPhoneNumber
string sUserID
string sPassword
string sMisc
string sComma = ","
string fEnd = ".csv"
string sEntry
string fName = $DDIRFNAME

dialcount DATA iEntries ;Get number of data entries
for iCount = 0 upto (iEntries - 1)
dialname DATA iCount sName ;Get name of entry based on index
set dialentry access DATA sName ;Turn on dialentry for the current entry
fetch dialentry areacode sAreaCode
fetch dialentry phonenumber sPhoneNumber
fetch dialentry company sCompany
fetch userid sUserID
fetch password sPassword
fetch misc sMisc
strcat sName sComma
strcat sAreaCode sComma
strcat sPhoneNumber sComma
strcat sCompany sComma
strcat sUserID sComma
strcat sPassword sComma
strcat sMisc sComma
strcat sEntry sName
strcat sEntry sAreaCode
strcat sEntry sPhoneNumber
strcat sEntry sCompany
strcat sEntry sUserID
strcat sEntry sPassword
strcat sEntry sMisc
fputs 4 sEntry
sEntry = ""
fclear 4
endfor
fclose 4
endproc
proc exportfive
integer iEntries ;Number of entries in dialing class
integer iCount ;Loop variable
string sName ;Name of Connection Directory entry
string sAreaCode
string sCompany
string sPhoneNumber
string sUserID
string sPassword
string sMisc
string sComma = ","
string fEnd = ".csv"
string sEntry
string fName = $DDIRFNAME

dialcount DATA iEntries ;Get number of data entries
for iCount = 0 upto (iEntries - 1)
dialname DATA iCount sName ;Get name of entry based on index
set dialentry access DATA sName ;Turn on dialentry for the current entry
fetch dialentry areacode sAreaCode
fetch dialentry phonenumber sPhoneNumber
fetch dialentry company sCompany
fetch userid sUserID
fetch password sPassword
fetch misc sMisc
strcat sName sComma
strcat sAreaCode sComma
strcat sPhoneNumber sComma
strcat sCompany sComma
strcat sUserID sComma
strcat sPassword sComma
strcat sMisc sComma
strcat sEntry sName
strcat sEntry sAreaCode
strcat sEntry sPhoneNumber
strcat sEntry sCompany
strcat sEntry sUserID
strcat sEntry sPassword
strcat sEntry sMisc
fputs 5 sEntry
sEntry = ""
fclear 5
endfor
fclose 5
endproc
proc exportsix
integer iEntries ;Number of entries in dialing class
integer iCount ;Loop variable
string sName ;Name of Connection Directory entry
string sAreaCode
string sCompany
string sPhoneNumber
string sUserID
string sPassword
string sMisc
string sComma = ","
string fEnd = ".csv"
string sEntry
string fName = $DDIRFNAME

dialcount DATA iEntries ;Get number of data entries
for iCount = 0 upto (iEntries - 1)
dialname DATA iCount sName ;Get name of entry based on index
set dialentry access DATA sName ;Turn on dialentry for the current entry
fetch dialentry areacode sAreaCode
fetch dialentry phonenumber sPhoneNumber
fetch dialentry company sCompany
fetch userid sUserID
fetch password sPassword
fetch misc sMisc
strcat sName sComma
strcat sAreaCode sComma
strcat sPhoneNumber sComma
strcat sCompany sComma
strcat sUserID sComma
strcat sPassword sComma
strcat sMisc sComma
strcat sEntry sName
strcat sEntry sAreaCode
strcat sEntry sPhoneNumber
strcat sEntry sCompany
strcat sEntry sUserID
strcat sEntry sPassword
strcat sEntry sMisc
fputs 6 sEntry
sEntry = ""
fclear 6
endfor
fclose 6
endproc
proc exportseven
integer iEntries ;Number of entries in dialing class
integer iCount ;Loop variable
string sName ;Name of Connection Directory entry
string sAreaCode
string sCompany
string sPhoneNumber
string sUserID
string sPassword
string sMisc
string sComma = ","
string fEnd = ".csv"
string sEntry
string fName = $DDIRFNAME

dialcount DATA iEntries ;Get number of data entries
for iCount = 0 upto (iEntries - 1)
dialname DATA iCount sName ;Get name of entry based on index
set dialentry access DATA sName ;Turn on dialentry for the current entry
fetch dialentry areacode sAreaCode
fetch dialentry phonenumber sPhoneNumber
fetch dialentry company sCompany
fetch userid sUserID
fetch password sPassword
fetch misc sMisc
strcat sName sComma
strcat sAreaCode sComma
strcat sPhoneNumber sComma
strcat sCompany sComma
strcat sUserID sComma
strcat sPassword sComma
strcat sMisc sComma
strcat sEntry sName
strcat sEntry sAreaCode
strcat sEntry sPhoneNumber
strcat sEntry sCompany
strcat sEntry sUserID
strcat sEntry sPassword
strcat sEntry sMisc
fputs 7 sEntry
sEntry = ""
fclear 7
endfor
fclose 7
endproc
proc exporteight
integer iEntries ;Number of entries in dialing class
integer iCount ;Loop variable
string sName ;Name of Connection Directory entry
string sAreaCode
string sCompany
string sPhoneNumber
string sUserID
string sPassword
string sMisc
string sComma = ","
string fEnd = ".csv"
string sEntry
string fName = $DDIRFNAME

dialcount DATA iEntries ;Get number of data entries
for iCount = 0 upto (iEntries - 1)
dialname DATA iCount sName ;Get name of entry based on index
set dialentry access DATA sName ;Turn on dialentry for the current entry
fetch dialentry areacode sAreaCode
fetch dialentry phonenumber sPhoneNumber
fetch dialentry company sCompany
fetch userid sUserID
fetch password sPassword
fetch misc sMisc
strcat sName sComma
strcat sAreaCode sComma
strcat sPhoneNumber sComma
strcat sCompany sComma
strcat sUserID sComma
strcat sPassword sComma
strcat sMisc sComma
strcat sEntry sName
strcat sEntry sAreaCode
strcat sEntry sPhoneNumber
strcat sEntry sCompany
strcat sEntry sUserID
strcat sEntry sPassword
strcat sEntry sMisc
fputs 8 sEntry
sEntry = ""
fclear 8
endfor
fclose 8
endproc
proc exportnine
integer iEntries ;Number of entries in dialing class
integer iCount ;Loop variable
string sName ;Name of Connection Directory entry
string sAreaCode
string sCompany
string sPhoneNumber
string sUserID
string sPassword
string sMisc
string sComma = ","
string fEnd = ".csv"
string sEntry
string fName = $DDIRFNAME

dialcount DATA iEntries ;Get number of data entries
for iCount = 0 upto (iEntries - 1)
dialname DATA iCount sName ;Get name of entry based on index
set dialentry access DATA sName ;Turn on dialentry for the current entry
fetch dialentry areacode sAreaCode
fetch dialentry phonenumber sPhoneNumber
fetch dialentry company sCompany
fetch userid sUserID
fetch password sPassword
fetch misc sMisc
strcat sName sComma
strcat sAreaCode sComma
strcat sPhoneNumber sComma
strcat sCompany sComma
strcat sUserID sComma
strcat sPassword sComma
strcat sMisc sComma
strcat sEntry sName
strcat sEntry sAreaCode
strcat sEntry sPhoneNumber
strcat sEntry sCompany
strcat sEntry sUserID
strcat sEntry sPassword
strcat sEntry sMisc
fputs 9 sEntry
sEntry = ""
fclear 9
endfor
fclose 9
endproc
proc exportten
integer iEntries ;Number of entries in dialing class
integer iCount ;Loop variable
string sName ;Name of Connection Directory entry
string sAreaCode
string sCompany
string sPhoneNumber
string sUserID
string sPassword
string sMisc
string sComma = ","
string fEnd = ".csv"
string sEntry
string fName = $DDIRFNAME

dialcount DATA iEntries ;Get number of data entries
for iCount = 0 upto (iEntries - 1)
dialname DATA iCount sName ;Get name of entry based on index
set dialentry access DATA sName ;Turn on dialentry for the current entry
fetch dialentry areacode sAreaCode
fetch dialentry phonenumber sPhoneNumber
fetch dialentry company sCompany
fetch userid sUserID
fetch password sPassword
fetch misc sMisc
strcat sName sComma
strcat sAreaCode sComma
strcat sPhoneNumber sComma
strcat sCompany sComma
strcat sUserID sComma
strcat sPassword sComma
strcat sMisc sComma
strcat sEntry sName
strcat sEntry sAreaCode
strcat sEntry sPhoneNumber
strcat sEntry sCompany
strcat sEntry sUserID
strcat sEntry sPassword
strcat sEntry sMisc
fputs 10 sEntry
sEntry = ""
fclear 10
endfor
fclose 10
endproc

A LITTLE LONG, but since I am new to this I could not find an eaiser way.
 
The script below shows how to find the name of all the .DIR files in your Procomm directory, then appends them all into one string variable. Just place the commands in the script at the beginning of your script just before the dialogbox command and you should be good to go. One thing to keep in mind is that ASPECT string are limited to 255 characters, so you may reach a limit on just how many .DIR files can be listed in szList.

proc main
string sPath = $PWLOCALPATH
string szList = ""

strcat sPath "\*.DIR"
if findfirst sPath
szList = $FILENAME
while findnext
strcat szList ","
strcat szList $FILENAME
endwhile
endif
endproc

I took a quick look at the rest of your script and I think you can condense the various export procedures that are called into one. Create one procedure, such as export, that is then called by all if commands under the case statement. Change all file descriptor for the fopen, fclose, and fclear commands to the same number. Since you are only operating on one file at a time, you can reuse the file descriptor. Doing this will let you shrink your script by a considerable amount.
aspect@aspectscripting.com
 
Knob,

Thanks again, I will look at condesing this tonight, I appreciate all of your assistance. I will let you know how everything works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top