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!

Problems with list box

Status
Not open for further replies.

brewerdude

IS-IT--Management
Sep 8, 2003
472
US
I'm trying to create a script for a Nortel PBX that will allow the user to just enter a phone extension to get a print out of the phone (normally you print the extension, get the port, the print the port). However, if an extension is on more than one phone, you'll get a list of ports that it's on. To handle that, I have the code save the list of ports to a text file, than want to use a list box in a dialog box that will let the user pick the port they want to print. The issue I'm having is my list box always comes up empty in the script that creates the text file that the list box reads. However, if I run the dialog box code just by itself, the list box works properly. Can't figure out what I'm doing wrong. Was wondering if there's some sort of refresh I need to do to have the text file read correctly. Anyway, here's the code that creates the text file to be read into the list box:

;*******************************************************************
;*** This script will ask the user for a DN to print. If there ***
;*** is only one TN, it will print right away. If there are ***
;*** multiple TN's, the user will be given a list of available ***
;*** TN's to choose from. Selecting the desired TN will print it ***
;*******************************************************************



string DN_input
string fname ;file name for dn print output capture
string pname ;path name for dn pring output capture
string filename
integer linecount
string lineinfo
string TN
string multiple_TN[10] ;used if more than one TN to print
integer TN_count
integer num
string write_name = "C:\Program Files\Symantec\Procomm Plus\Capture\write_test.txt" ;file for list box entries
string write_string
string ListItem ; Item selected from list.
integer Event ; Dialog box event.


proc main
;*******************************************************************************************
;*** Start by setting the filename and path for the capture file, delete it if it exists ***
;*******************************************************************************************

fname = "capture_dn.txt"
pname = "C:\Program Files\Symantec\Procomm Plus\Capture\"

if isfile "C:\Program Files\Symantec\Procomm Plus\Capture\capture_dn.txt"
delfile "C:\Program Files\Symantec\Procomm Plus\Capture\capture_dn.txt"
endif

set capture file fname
set capture path pname

;*******************************************************
;*** Dialog box to get input from user, and print DN ***
;*******************************************************

sdlginput "Extension" "What is the Extension:" DN_Input
strcat DN_input "^M"
clear
capture on
transmit "******^M"
transmit "LD 20^M"
capture on
waitfor "REQ:"
transmit "prt^M"
waitfor "TYPE: "
transmit "DN^M"
waitfor "CUST "
transmit "0^M"
waitfor "DN "
transmit DN_Input
waitfor "DATE "
transmit "^M"
waitfor "PAGE "
transmit "^M"
waitfor "DES "
transmit "^M"
waitfor "NACT "
transmit "^M"

capture off

;****************************************************************************
;*** copy path and file name into new variable so can read from text file ***
;****************************************************************************

strcpy filename pname
strcat filename fname

;***********************************
;*** read DN info from text file ***
;***********************************

if fopen 0 filename READ TEXT ; Open file for read only.
while not feof 0 ; Loop while not end of file.
linecount++
fgets 0 LineInfo ; Get line from file.

if strsearch LineInfo "TN"
TN_Count++
if TN_Count >= 2 ;determine if more than one TN
multiple_TN[1] = TN ;first copy the first TN info first array
substr multiple_TN[TN_Count] Lineinfo 5 12 ;and if so, put them into an array
else
substr TN Lineinfo 5 12
endif
endif


endwhile
fclose 0 ; Close file opened for read.
else
errormsg "Couldn't open file `"%s`"." Filename
endif

;************************************************************
;*** Create and write to file of all entries in the array ***
;*** so they can be read into the list box later on ***
;************************************************************
if fopen 0 write_name CREATE
for num = 1 upto TN_Count
strcpy write_string multiple_TN[num]
strcat write_string "`r`n"
fputs 0 write_string
endfor
endif

;***************************************************************
;*** Print the phone depending on the situation, if there's ***
;*** only one TN, print right away, if there's more than one ***
;*** give user list box to pick TN they want to print ***
;***************************************************************

if TN_Count < 2
transmit "^M^M"
waitfor "REQ: "
transmit "prt^M"
waitfor "TYPE: "
transmit "tn^M"
waitfor "TN "
transmit TN
transmit "^M"
waitfor "DATE "
transmit "^M"
waitfor "PAGE "
transmit "^M"
waitfor "DES "
transmit "^M"
waitfor "NACT"
transmit "^M"
else
;pause 10
;fileview write_name
;usermsg write_name
dialogbox 0 0 0 100 120 11 "TN List"
text 1 5 5 90 12 "Select the TN you wish" CENTER
text 2 5 15 90 12 "to print." CENTER
flistbox 3 25 30 50 70 write_name SINGLE ListItem
enddialog

while 1
dlgevent 0 Event ; Get the dialog event.
switch Event ; Evaluate the event.

case 0 ; No event occurred.
endcase

case 3 ; Something was chosen.
usermsg "`"%s`" selected!" ListItem ;this will eventually contain the code to print the phone
endcase
default ; Exit case chosen.
exitwhile ; Exit the loop.
endcase
endswitch
endwhile
dlgdestroy 0 CANCEL ; Destroy the dialog box.

endif

endproc

---------------------------------------------------

Here's the dialog box code by itself, largely copied directly from the ProcomPlus help files

proc main
string ListItem ; Item selected from list.
integer Event ; Dialog box event.
string write_name = "C:\Program Files\Symantec\Procomm Plus\Capture\write_test.txt"

; Display dialog box with list of items. You need
; a file called "items.lst" that contains items
; to choose from (one on a line).
fileview write_name
dialogbox 0 0 0 100 120 11 "TN List"
text 1 5 5 90 12 "Select the TN you wish" CENTER
text 2 5 15 90 12 "to print." CENTER
flistbox 5 25 30 55 70 write_name SINGLE ListItem
enddialog
while 1
dlgevent 0 Event ; Get the dialog event.
switch Event ; Evaluate the event.

case 0 ; No event occurred.
endcase
case 5 ; Something was chosen.
usermsg "`"%s`" selected!" ListItem
endcase
default ; Exit case chosen.
exitwhile ; Exit the loop.
endcase
endswitch
endwhile
dlgdestroy 0 CANCEL ; Destroy the dialog box.
endproc
 
Do you have "MARP" turned on?

If you do I have a script that will do a DNB, capture the MARP'ed TN and print that.
 
yes, marp is turned on. That'd be cool to see that, though my intent is to allow the user to pick the TN they want to print.
 
** You will need to edit info10 and info11 for YOUR correct path. **
** Copy everything below this and name it what you want to. **
** You may need to increase the txpace if it's too fast for your switch. **

string info = "DNB.txt"
string info10 = "C:\Procomm Plus\Capture\Dnb.txt"
string info11 = "C:\Procomm Plus\Capture\Dnb_1.txt"

string TN1
string TN2
string TN3
string TN4
string dn
string sLine

integer event

PROC MAIN

dialogbox 0 8 15 168 74 7 " GET TNB"
text 1 29 16 112 11 "ENTER EXTENSION NUMBER" left
editbox 2 70 25 21 11 dn
pushbutton 3 15 50 40 13 "PRINT" OK
pushbutton 5 115 50 40 13 "CANCEL" CANCEL
enddialog
while 1
dlgevent 0 event
switch event
case 0
endcase
case 3
disable dlgctrl 0 1
call PRT_DNB
endcase
case 5
disable dlgctrl 0 2
call END_0
endcase
default
endcase
endswitch
endwhile
ENDPROC

PROC PRT_DNB

SET TXPACE 15
transmit "****^M"
waitfor ">" 1
transmit "LD 20^M"
waitfor "REQ: " 1
transmit "PRT^M"
waitfor "TYPE: " 1
transmit "DNB^M"
waitfor "CUST " 1
transmit "0^M"
set capture overwrite on
set capture file info
capture on
waitfor "DN " 1
transmit DN
transmit "^M"
waitfor "DATE " 1
transmit "^M"
waitfor "PAGE " 1
transmit "^M"
waitfor "DES " 1
transmit "^M"
when target 0 "MARP" call PRT_FILE
call PRT_FILE
ENDPROC

PROC PRT_FILE
if fopen 0 info10 read text
call READ_FILEPRT
else
errormsg "Couldn't open file `"%s`"." info
call END_0
endif
ENDPROC

PROC READ_FILEPRT

waitfor "NACT " 1
transmit "END^M"
capture off

fopen 0 info10 Read Text
fopen 2 info11 Create Text
while not feof 0
fgets 0 sLine
if strfind sLine "DN "
fputs 2 sLine
endif
if strfind sLine " NAME "
fputs 2 sLine
endif
if strfind sLine " MARP"
fputs 2 sLine ; gets marped TN
fgets 0 sLine ; moves to next line
fputs 2 sLine ; gets marped set type
endif
endwhile

fopen 2 info11 Read Text
fgets 2 s0
fgets 2 s1
fgets 2 s2
fgets 2 s3
substr tn1 S3 5 3 ; loop
substr tn2 S3 9 1 ; shelf
substr tn3 S3 11 2 ; card
substr tn4 S3 14 2 ; unit
call PRT_TNB
ENDPROC


PROC PRT_TNB

SET TXPACE 15
waitfor ">" 3
transmit "LD 20^M"
waitfor "PT0000"
waitfor "REQ: "
transmit "PRT^M"
waitfor "TYPE: "
transmit "TNB^M"
waitfor "TN "
transmit TN1
transmit " "
transmit TN2
transmit " "
transmit TN3
transmit " "
transmit TN4
transmit "^M"
waitfor "DATE " 1
transmit "^M"
waitfor "PAGE " 1
transmit "^M"
waitfor "DES " 1
transmit "^M"
printcapture on
if waitfor "NACT " 8
printcapture off
else
transmit "^M"
transmit "END^M"
endif
exit
ENDPROC

PROC END_0

transmit "END^M"
delfile info10
delfile info11
exit
ENDPROC
 
By the way I made an insertion into your script which allows for the "read" to take place:
Hope this helps...please post your finished script should you complete it.

;************************************************************
;*** Create and write to file of all entries in the array ***
;*** so they can be read into the list box later on ***
;************************************************************
if fopen 0 write_name CREATE
for num = 1 upto TN_Count
strcpy write_string multiple_TN[num]
strcat write_string "`r`n"
fputs 0 write_string
endfor
FCLOSE 0
endif

;***************************************************************
;*** Print the phone depending on the situation, if there's ***
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top