home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1998 April A
/
Pcwk4a98.iso
/
Wtestowe
/
OnNet16
/
GENLEARN.SCR
< prev
next >
Wrap
Text File
|
1997-02-13
|
8KB
|
301 lines
<* language=slang *>
<************************************************>
<* Connect to provider, with redial/retry logic *>
<************************************************>
(define,connect,{
(poll,physical,open,1,{ <* Hangup *>
(send,(modem,hangup)(cr))
(define,junk,(receive,2000,OK))
(delete,junk)
})
(slang_init_modem) <* Init the modem *>
(define,pnum,(phone,number))
(==,(value,pnum),,{
(define,pnum,(prompt,{Please enter the phone number to dial:}))
})
(replace,pnum,(char,41)) <* Get rid of parentheses *>
(replace,pnum,(char,40))
(replace,pnum,{-}) <* Get rid of dashes *>
(define,dmsg,{NONE})
(loop,{
(trac,iz2)
(status,{Last Error:}(value,dmsg)(lf)
{Dialing...})
(define,again,n) <* Clear loop again flag *>
<* Dial *>
(send,
(modem,dial)
(==,(phone,prefix),,,{
(phone,prefix)
(loop,{(modem,pause)},2)
})
(value,pnum)
(==,(phone,ext),,,{
(loop,{(modem,pause)},2)
(phone,ext)
})
(cr)
)
<* Removed the following code following *>
<* "Empty Recv Buffer" for Cinci Bell Problem *>
<* with 3COM Impact RS232-ISDN *>
<* modem. *>
<* This loop slowed things up to *>
<* the point that a script generated *>
<* from genlearn (teach mode) would still *>
<* be waiting for the connect message *>
<* from the modem, never even looking *>
<* at carrier. *>
<* cmn at request of Mike Holland on *>
<* 6/13/96 Thursday. *>
<* Empty Recv Buffer *>
<* (define,junk,(receive,1000)) *>
<* (delete,junk) *>
<* Wait for response *>
(status,{Last Error:}(value,dmsg)(lf)
{Dialing...}(lf)
{Timeout in %d seconds}
,(/,(phone,timeout),1000))
(define,response,(receive,(phone,timeout),CONNECT,BUSY,ERROR,
{NO CARRIER},{NO DIALTONE},{NO ANSWER}))
(loop,{ <* Case *>
(has,response,CONNECT,{
(define,again,done)
(lbreak)
})
(has,response,BUSY,{
(status,{BUSY})
(define,query,(message,{The number you dialed is Busy. Would you like to try again?},YESNO,q,1,y,n))
(define,again,(value,query))
(define,dmsg,{BUSY})
(lbreak)
})
(has,response,ERROR,{
(status,{Modem Error})
(message,{Modem Error, Connection Failed},OK,e)
(lbreak)
})
(has,response,{NO CARRIER},{
(status,{NO CARRIER})
(define,query,(message,{Unable to connect to remote modem. Would you like to try again?},YESNO,q,1,y,n))
(define,again,(value,query))
(define,dmsg,{NO CARRIER})
(lbreak)
})
(has,response,{NO DIALTONE},{
(status,{NO DIALTONE})
(define,query,(message,{No Dialtone. Would you like to try again?},YESNO,q,1,y,n))
(define,again,(value,query))
(define,dmsg,{NO DIALTONE})
(lbreak)
})
(has,response,{NO ANSWER},{
(status,{NO ANSWER})
(define,query,(message,{No Answer. Would you like to try again?},YESNO,q,1,y,n))
(define,again,(value,query))
(define,dmsg,{NO ANSWER})
(lbreak)
})
<* Unknown response / TIMEOUT *>
(send,(cr))
(status,{TIMEOUT})
(define,query,(message,{TIMEOUT. Would you like to try again?},YESNO,q,1,y,n))
(pause,5000)
(trac,iz2)
(define,again,(value,query))
(define,dmsg,{TIMEOUT})
},1) <* End Case *>
<* Check for loop again *>
(==,(value,again),y,,{
(lbreak)
})
},-1)
(==,(value,again),done,,{
(sexit)
})
(delete,again,query,response,pnum)
(status,{Waiting for Physical Connection...}(lf)
{Timeout in %d seconds},(/,(phone,timeout),1000))
(poll,physical,open,(phone,timeout),{
(status,{Physical connection established})
(pause,1000)
},{
(wdial_message,{Physical layer not opened. Connection Failed!},OK,e)
(sexit)
})
})
<********************************************>
<* Wait for callback (for DEFENDER systems) *>
<********************************************>
(define,callback,{
(status,{Waiting for provider to hangup...}(lf)
{Timeout in %d seconds},(/,(phone,timeout),1000))
(poll,physical,closed,(phone,timeout),,{
(wdial_message,{The provider never hung up. Connection Failed!},OK,e)
(sexit)
})
(status,{Waiting for callback...}(lf)
{Timeout in %d seconds},24000)
(define,tmp,(receive,2400000,RING)) <* Wait for RING *>
(has,tmp,RING,,{
(wdial_message,{The provider never called back. Connection Failed!},OK,e)
(sexit)
})
(status,{Answering phone})
(send,ATA(cr)) <* Answer Modem *>
(status,{Waiting for Physical Connection...}(lf)
{Timeout in %d seconds},(/,(phone,timeout),1000))
(poll,physical,open,(phone,timeout),{
(status,{Physical connection established})
(pause,1000)
},{
(wdial_message,{Physical layer not opened. Connection Failed!},OK,e)
(sexit)
})
})
(define, abort,{
(status,{Not connected})
(message, {The other side hung up. Connection Failed!})
(exit) <* exit script if no carrier *>
})
(define, did_they_hang_up?,{
(poll, physical, open, , , {
(abort)
})
})
<*********************>
<* Ask user for help *>
<*********************>
(define, response_not_recognized, {
(status,{Waiting for user input})
(define, user_data,
(prompt,(value,input_data)
{
} {Response not recognized!
} {You must either:
} { o Run the `teach' mode script again
} {
} { o Enter a response to continue connecting.
} {
} {Type 'EXIT' to abort.}
))
(has, (value, user_data), EXIT,
{ (sexit) },
{ (send, (value, user_data) (cr)) })
})
(define,hangup,{
(changemode, raw)
(escape,cleardtr)
(poll,physical,close,2000,,{
(send,+++)
(pause,2000)
(send,ATH0(cr))
(pause,2000)
})
})
<*******************************************************>
<* Exit gracefully, ERROR *>
<*******************************************************>
(define,sexit,{
(status,{Not connected})
(exit)
})
<*******************************************************>
<* Negotiate layers etc. *>
<*******************************************************>
(define,topacket,{
<* Change to packet mode *>
(changemode,packet)
(==,(frametype),SLIP,,{
<* PPP Mode *>
<* Open LCP Layer *>
(status,{Waiting for Link Control...}(lf)
{Timeout in %d seconds},(/,(phone,timeout),1000))
(define,stoptime,(+,(trac,xcm),(phone,timeout)))
(loop, {
(did_they_hang_up?)
(poll,lcp,open,1000,{
(lbreak)
})
(compare,(trac,xcm),(value,stoptime),{
(changemode,raw)
(hangup)
(message,{Link control not established. Connection Failed!},OK,e)
(sexit)
})
},-1)
<* Open IPCP Layer *>
(status,{Waiting for Network Control...}(lf)
{Timeout in %d seconds},(/,(phone,timeout),1000))
(define,stoptime,(+,(trac,xcm),(phone,timeout)))
(loop, {
(did_they_hang_up?)
(poll,ipcp,open,1000,{
(lbreak)
})
(compare,(trac,xcm),(value,stoptime),{
(changemode,raw)
(hangup)
(message,{Network control not established. Connection Failed!},OK,e)
(sexit)
})
},-1)
})
(status,{Connected})
})
<********************************************************>
<* Check if script can run over this SLANG interpretter *>
<********************************************************>
<* (define,checkver,{
<* Version OK *>
})*>
<* Return user's password or ask for it *>
(define,pword,{
(==,(password),,{
(password,(prompt, {Please enter your password:}, *))
})
(password)
})
<* Return user's userid or ask for it *>
(define,uname,{
(==,(username),,{
(username,(prompt, {Please enter your username:}))
})
(username)
})
<*** END Genlearn Common Macros ***>
<*----------------------------------*>