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!

using WHEN to call a proc 1

Status
Not open for further replies.

brewerdude

IS-IT--Management
Sep 8, 2003
472
US
I'm trying to write a script that will interface with our Nortel PBX so that when I check the status of a phone, if I get a certain response, I want to perform an action on the phone. My quandy is that I'm using the WHEN command to call a procedure, but according to the help files, I can't pass a parameter to the sub-proc. How can I get around this?

Here's my (intended but non-compiling) code:

;***********************************
;****** Open file from drive *******
;***********************************
proc main

string FileSpec
string Fname
string LineBuffer
string lineinfo

transmit "****"
transmit "^M"
transmit "LD 20^M"
pause 1


FileSpec = "c:\*.*" ; Set spec to all files in "c:\".
dir FileSpec Fname ; Display dir and get file name.
if SUCCESS ; See if a file was chosen.

endif


if fopen 0 Fname READ TEXT ; Open file for read only.

while not feof 0 ; Loop while not end of file.
fgets 0 LineBuffer
lineinfo = LineBuffer

if strcmp lineinfo ""
exitwhile
endif
;usermsg lineinfo
strcat lineinfo "^M"
transmit "^M"
waitfor "REQ: "
transmit "STAT "
transmit lineinfo
pause 1
when TARGET 0 "DSBL" call resetphone with lineinfo



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


endproc


proc resetphone
param string lineinfo
transmit "^M"
waitfor "REQ: "
transmit "ENLU"
transmit lineinfo
pause 1

endproc
 
One workaround would be to make lineinfo a global string by declaring it above proc main, and then that value would be available in any other procedure in your script (including the one called by the when target command).


 
clean script, looks for disu and enables the down tn's, what are you using for the file, in the get file line?

john poole
bellsouth business
columbia,sc
 
It's a text file that consists of all the TN's of our conference room phones. They often get tossed around, so we'll run this every morning as a proactive measure.




The fixed script looks like this:

;***********************************
;****** Open file from drive *******
;***********************************

string lineinfo

proc main
string FileSpec
string Fname
string LineBuffer


transmit "****"
transmit "^M"
transmit "LD 20^M"
pause 1


FileSpec = "c:\*.*" ; Set spec to all files in "c:\".
dir FileSpec Fname ; Display dir and get file name.
if SUCCESS ; See if a file was chosen.

endif


if fopen 0 Fname READ TEXT ; Open file for read only.

while not feof 0 ; Loop while not end of file.
fgets 0 LineBuffer
lineinfo = LineBuffer

if strcmp lineinfo ""
exitwhile
endif
;usermsg lineinfo
strcat lineinfo "^M"
transmit "^M"
waitfor "REQ: "
transmit "STAT "
transmit lineinfo
pause 1
when TARGET 0 "DSBL" call resetphone



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


endproc


proc resetphone

transmit "^M"
waitfor "REQ: "
transmit "ENLU "
transmit lineinfo
pause 1

endproc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top