brewerdude
IS-IT--Management
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
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