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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IMPORTING Dialing Directory 1

Status
Not open for further replies.

MyFlight

Technical User
Feb 4, 2002
193
QUESTION,

I have written a script file to import and create dialing directories. Which anyone is welcome to use.
However I am wondering if there is a way to make it more flexible.


proc main
integer iVar, iLen, iTok6, iTok7 ;Number of entries in dialing class
string sLine, sTok1, sTok2, sTok3, sTok4, sTok5
string sTok6, sTok7, sTok8, sTok9, sTok10, sTok11
string sTok12, sTok13, sTok14
string sNewSwitchDir ;Name of New Connection Directory
string sSwitchImportDir = "Switches.csv"
string sImportPath = "C:\Temp Data Files\Raw Data\"
string sNewPath = "C:\Program Files\Symantec\ProComm Plus\"
string sCapPath = "C:\Program Files\Symantec\ProComm Plus\Capture\"
string sOne = "9005 CBX's"
string sTwo = "9006 CBX's"
string sThree = "Other CBX's"

chdir sImportPath
isfile sSwitchImportDir ivar ; Verifies that File does Exist.
if SUCCESS
fopen 1 sSwitchImportDir READWRITE TEXT ; Opens Text File
pause 2
chdir sNewPath
if sdlginput "Create Directory" "Name:" sNewSwitchDir
if not nullstr sNewSwitchDir ; Make sure name isn't empty.
dialcreate sNewSwitchDir ; Create the Dialing Directory.
endif
endif
dialadd DATA GROUP sOne ;Add group called '9005 CBX's'
dialadd DATA GROUP sTwo ;Add group called '9005 CBX's'
dialadd DATA GROUP sThree ;Add group called '9005 CBX's'
while not feof 1
fgets 1 sLine
strlen sLine iLen
strtok sTok1 sLine "," 1 ;Site Name
strtok sTok2 sLine "," 1 ;State
strtok sTok3 sLine "," 1 ;Network ID Number
strtok sTok4 sLine "," 1 ;Area Code
strtok sTok5 sLine "," 1 ;Phone Number
strtok sTok6 sLine "," 1 ;Only Dial Data Number
strtok sTok7 sLine "," 1 ;Long Distance
strtok sTok8 sLine "," 1 ;CMR Number
strtok sTok9 sLine "," 1 ;Login
strtok sTok10 sLine "," 1 ;Password
strtok sTok11 sLine "," 1 ;Switch Type
strtok sTok12 sLine "," 1 ;Script File Name
strtok sTok13 sLine "," 1 ;capture File Name
; strtok sTok14 sLine "," 1 ;capture File Name
atoi sTok6 iTok6
atoi sTok7 iTok7
strcat sTok1 sTok2
strcat sTok1 sTok3
usermsg "`"%s`" FOUND." sTok1
if strfind "9005" sTok11 ;Check for target text in string.
; usermsg "Target string found in search string!"
dialadd DATA sTok1 ;Add Dial Entry
set dialentry access DATA sTok1 ;Turn on dialentry for the current entry
set dialentry areacode sTok4
set dialentry phonenumber sTok5
set dialentry dialnumberonly iTok6
set dialentry longdistance iTok7
set dialentry company sTok8
set userid sTok9
set password sTok10
set misc sTok11
set dialentry scriptfile sTok12
set dialentry scriptstart DIALED
set capture path sCapPath
set capture file sTok13
set capture autostart ON
dialinsert DATA sOne sTok1 ;Insert entry into '9005 Folder'
endif
if strfind "9006" sTok11 ;Check for target text in string.
; usermsg "Target string found in search string!"
dialadd DATA sTok1 ;Add Dial Entry
set dialentry access DATA sTok1 ;Turn on dialentry for the current entry
set dialentry areacode sTok4
set dialentry phonenumber sTok5
set dialentry dialnumberonly iTok6
set dialentry longdistance iTok7
set dialentry company sTok8
set userid sTok9
set password sTok10
set misc sTok11
set dialentry scriptfile sTok12
set dialentry scriptstart DIALED
set capture path sCapPath
set capture file sTok13
set capture autostart ON
dialinsert DATA sTwo sTok1 ;Insert entry into '9006 Folder'
endif
if strfind "Other" sTok11 ;Check for target text in string.
; usermsg "Target string found in search string!"
dialadd DATA sTok1 ;Add Dial Entry
set dialentry access DATA sTok1 ;Turn on dialentry for the current entry
set dialentry areacode sTok4
set dialentry phonenumber sTok5
set dialentry dialnumberonly iTok6
set dialentry longdistance iTok7
set dialentry company sTok8
set userid sTok9
set password sTok10
set misc sTok11
set dialentry scriptfile sTok12
set dialentry scriptstart DIALED
set capture path sCapPath
set capture file sTok13
set capture autostart ON
dialinsert DATA sThree sTok1 ;Insert entry into 'Other Folder'
endif
endwhile
dialsave ;List'group and Save the Connection Directory
fclose 1
else
usermsg "Can't Find FILE Switch.csv"
exit
endif
endproc


Currently I am using th sTok1 thru sTok15 variables and assigning them too cenrtian columns from the Switches.clv file. Is there a way I can prompt the User to input the column numbers for various data entry fields.

EXAMPLE:
+------------------------------------------------+
| PLEASE INPUT THE YOUR COLUMN NUMBERS |
| |
| Site Name: ___ |
| |
| State: ___ |
| |
| CMR: ___ |
| |
| Area Code: ___ |
| |
| Phone Number: ___ |
| |
+------------------------------------------------+

and using the column nubers entered I then import any spreadsheet no matter where the columns line up. Also this alliviates the need for the user to setup the excel spreadsheet in a certain way.

Your assisrtance in this matter will be fgreatly appreciated.


 
I think probably the easiest way to do this would be to use strextract instead of strtok. The two commands are similar, but strextract doesn't modify the original string like strtok, so you can pick and choose from the different substrings without impacting the original string (in other words, you'll always be pulling from the correct offset in the string). Once you do that, your script could have the user enter their information and then you would modify your strtok commands to look like this:

strextract sLine sTok1 "," intval-1

Note that sLine and sTok1 are flipped in this command and that the 1 from the previous command is now replaced by intval-1. For each column that you have the user specify, you'll need a corresponding integer variable, which I've called intval in the fragment above. Since ASPECT's strings are zero-based, you'll need to subtract one from the column value that the user enters to match up the data correctly.

aspect@aspectscripting.com
 
Knob,

Ok you can call me n00b but how do I assign the intval to the values entered. here is the script I have so far.


Code:
#define TRUE   1
proc main
   integer iVar, intval, iLen, iTok6, iTok7                            ;Number of entries in dialing class
   string intvala, intvalb, intvalc, intvald, intvale, intvalf
   string intvalg, intvalh, intvali, intvalj, intvalk, intvall
   string intvalm
   string sLine, sTok1, sTok2, sTok3, sTok4, sTok5
   string sTok6, sTok7, sTok8, sTok9, sTok10, sTok11
   string sTok12, sTok13, sTok14
   string sNewSwitchDir                                        ;Name of New Connection Directory
   string sSwitchImportDir = "Switches.csv"
   string sImportPath = "C:\Temp Data Files\Raw Data\"
   string sNewPath = "C:\Program Files\Symantec\ProComm Plus\"
   string sCapPath = "C:\Program Files\Symantec\ProComm Plus\Capture\"
   string sOne = "9005 CBX's"
   string sTwo = "9006 CBX's"
   string sThree = "Other CBX's"
   integer Event
   chdir sImportPath
   isfile sSwitchImportDir ivar                                ; Verifies that File does Exist.
   if SUCCESS
      fopen 1 sSwitchImportDir READWRITE TEXT                  ; Opens Text File            
      pause 2
     chdir sNewPath
     if sdlginput "Create Directory" "Name:"  sNewSwitchDir
        if not nullstr  sNewSwitchDir                          ; Make sure name isn't empty.
           dialcreate  sNewSwitchDir                           ; Create the Dialing Directory.
        endif
     endif
;editbox ID LEFT TOP WIDTH HEIGHT STRING STRLEN (Max String Length)
dialogbox 0 298 40 172 298 2 "Column Numbers" 
   editbox 1 102 2 44 12 intvala 2
   editbox 2 102 20 44 12 intvalb 2 
   editbox 3 102 42 44 12 intvalc 2 
   editbox 4 102 62 44 12 intvald 2 
   editbox 5 102 82 44 12 intvale 7 
   editbox 6 102 102 44 12 intvalf 2 
   editbox 7 102 122 44 12 intvalg 2 
   editbox 8 102 142 44 12 intvalh 2 
   editbox 9 102 162 44 12 intvali 2 
   editbox 10 102 182 44 12 intvalj 2 
   editbox 11 102 202 44 12 intvalk 2 
   editbox 12 102 222 44 12 intvall 2 
   editbox 13 102 242 44 12 intvalm 2 
   text 15 27 4 66 11 "Site Name" right 
   text 16 28 24 65 9 "State" right 
   text 17 28 44 64 9 "ID" right 
   text 18 28 64 64 9 "Area Code" right 
   text 19 28 84 64 9 "Phone Number" right 
   text 20 30 104 63 9 "Dial Data" right 
   text 21 30 124 63 9 "Dial Long Distance" right 
   text 22 26 144 66 9 "Customer Number" right 
   text 23 27 164 66 9 "Login" right 
   text 24 32 184 60 9 "Password" right 
   text 25 31 204 62 9 "Switch Type" right 
   text 26 29 224 64 9 "Script File Name" right 
   text 27 30 244 63 9 "Capture File Name" right 
   pushbutton 29 16 280 54 12 "OK" OK DEFAULT
   pushbutton 30 95 280 56 12 "Cancel" CANCEL 
enddialog 
   while TRUE
      dlgevent 0 Event
      switch Event
         case 29
            exitwhile
            ;call additional procedures here
         endcase
         case -1     
         case 30          
            exitwhile
         endcase
      endswitch
   endwhile
   dlgdestroy 0 CANCEL
     set modem connection current
     dialadd DATA GROUP sOne		                       ;Add group called '9005 CBX's'
     set modem connection current
     dialadd DATA GROUP sTwo		                       ;Add group called '9005 CBX's'
     set modem connection current
     dialadd DATA GROUP sThree		                       ;Add group called '9005 CBX's'
     while not feof 1
        fgets 1 sLine
        strlen sLine iLen
        strextract sLine sTok1 "," intval-1
        strextract sLine sTok2 "," intval-2
        strextract sLine sTok3 "," intval-3
        strextract sLine sTok4 "," intval-4
        strextract sLine sTok5 "," intval-5
        strextract sLine sTok6 "," intval-6
        strextract sLine sTok7 "," intval-7
        strextract sLine sTok8 "," intval-8
        strextract sLine sTok9 "," intval-9
        strextract sLine sTok10 "," intval-10
        strextract sLine sTok11 "," intval-11
        strextract sLine sTok12 "," intval-12
        strextract sLine sTok13 "," intval-13
        strextract sLine sTok14 "," intval-14

        atoi sTok6 iTok6
        atoi sTok7 iTok7
        strcat sTok1 sTok2
        strcat sTok1 sTok3
;        usermsg "`"%s`" FOUND." sTok1        
        if strfind "9005" sTok11                               ;Check for target text in string.
;           usermsg "Target string found in search string!"
           dialadd DATA sTok1                                     ;Add Dial Entry
           set dialentry access DATA sTok1                        ;Turn on dialentry for the current entry
           set dialentry areacode sTok4
           set dialentry phonenumber sTok5
           set dialentry dialnumberonly iTok6
           set dialentry longdistance iTok7
           set dialentry company sTok8
           set userid sTok9
           set password sTok10
           set misc sTok11
           set dialentry scriptfile sTok12
           set dialentry scriptstart CONNECTED
           set capture path sCapPath
           set capture file sTok13
           set capture autostart ON
           dialinsert DATA sOne sTok1                          ;Insert entry into '9005 Folder'  
        endif
        if strfind "9006" sTok11                               ;Check for target text in string.
;           usermsg "Target string found in search string!"
           dialadd DATA sTok1                                     ;Add Dial Entry
           set dialentry access DATA sTok1                        ;Turn on dialentry for the current entry
           set dialentry areacode sTok4
           set dialentry phonenumber sTok5
           set dialentry dialnumberonly iTok6
           set dialentry longdistance iTok7
           set dialentry company sTok8
           set userid sTok9
           set password sTok10
           set misc sTok11
           set dialentry scriptfile sTok12
           set dialentry scriptstart CONNECTED
           set capture path sCapPath
           set capture file sTok13
           set capture autostart ON
           dialinsert DATA sTwo sTok1                          ;Insert entry into '9006 Folder' 
        endif
        if strfind "Other" sTok11                              ;Check for target text in string.
;           usermsg "Target string found in search string!"
           dialadd DATA sTok1                                     ;Add Dial Entry
           set dialentry access DATA sTok1                        ;Turn on dialentry for the current entry
           set dialentry areacode sTok4
           set dialentry phonenumber sTok5
           set dialentry dialnumberonly iTok6
           set dialentry longdistance iTok7
           set dialentry company sTok8
           set userid sTok9
           set password sTok10
           set misc sTok11
           set dialentry scriptfile sTok12
           set dialentry scriptstart CONNECTED
           set capture path sCapPath
           set capture file sTok13
           set capture autostart ON
           dialinsert DATA sThree sTok1                        ;Insert entry into 'Other Folder'  
        endif
     endwhile
        dialsave                                               ;List'group and Save the Connection Directory
        fclose 1
   else
      usermsg "Can't Find FILE Switch.csv"
      exit
   endif
endproc


As always your assistance is greatly appreciated.
 
I haven't had a chance to dig through the whole script ("real" work and all that) but one thing you will need to do is use atoi on all of the values entered into the dialog. Also, the various strextract commands will need to be changed from intval-1 to intvala-l, etc. Actually, I guess the easiest way to do the change would be to change the current intval* variables from strings to integers and add new strval* variables to use in the dialog.


aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top