/* Sample script for implementing basic Telnet functions in AdeptXBBS */

arg line

Call AdeptInitRexx

if (line = 0) Then  /* Telnet Script won't work in local mode */
Do
  Call AdeptCLS line
  Call AdeptCurPos line,12,1
  Call AdeptPrint line, "Sorry Telnet only avaliable on nodes > 0\r\n"
  Call AdeptPrint line, "{PB"
  Exit
End


Call AdeptCLS line
Call AdeptLocation line, "Telnet"
/*Call AdeptSayGen line, "Telnet"*/

Call AdeptPrint line, "Some Popular AdeptXBBS Systems\r\n\r\n"
Call AdeptPrint line, "1> lakebbs.cn-newc.com.au - LakeBBs Australia         \r\n"
address.1 = "lakebbs.cn-newc.com.au"
port.1 = 23

Call AdeptPrint line, "2> summitcnty.com         - Summit Central BBS Colorado USA         \r\n"
address.2 = "summitcnty.com"
port.2 = 23

Call AdeptPrint line, "3> snoval.com             - SnoValley Shareware Exchange Washington USA\r\n"
address.3 = "snoval.com"
port.3 = 23
Call AdeptPrint line, "4>                        - Multi User Dungeon System  \r\n"
address.4 = "207.0.255.254"
port.4 = 3333

Call AdeptPrint line, "5> Juge.Com               - CommPort OS/2          \r\n"
address.5 = "juge.com"
port.5 = 23

Call AdeptPrint line, "6> Gwinn.Com              - The SIO Support BBS                     \r\n"
address.6 = "gwinn.com"
port.6 = 23

Call AdeptPrint line, "7> bbs.isonline.com       - A Quickbbs BBS                          \r\n"
address.7 = "bbs.isonline.com"
port.7 = 23

Call AdeptPrint line, "8> USER DEFINED\r\n\r\n"

Choice = AdeptInput(line,,80,,,"Telnet to: ",,,)

if (choice = 8) Then
  Do
    Address.8 = AdeptInput(line,,80,,,"[0m[K\r\n[KTelnet to address: ",,,)
    if(Address.8 = '') then exit
    Port.8 = AdeptInput(line,,12,,,"\r\nPort[Enter for Default]: ",,,)
    if(Port.8 = '') then Port.8 = 23
  End

if (choice = '') then exit
if (choice > 8 | choice < 1) then exit

/* tid = AdeptStartRexxThread('LineTimer.Srx',line) */


Call AdeptPrint line, "\r\nTrying"
Do 3
  Call AdeptPrint line,"{PA."
  Call AdeptSleep line,128
End

Call AdeptPrint line, "{PA" || Address.Choice || " on port "||Port.Choice

Call AdeptLocation line, Address.Choice
Call AdeptSayGen line, "Telnet: " || Address.Choice

Call AdeptLog line,1,"Telnet: " || Address.Choice
Call AdeptLog line,1,"Port: " || Port.Choice

Call AdeptPrintL line,"\r\n\r\n\r\nUser is currently in a telnet session to: "||Address.Choice||":"||Port.Choice

rc = AdeptRawOpenSocket(ISTELNETCLIENT, Address.Choice, Port.Choice, 'Port')
if rc = 65558 then do
/* rc = AdeptKillRexxThread(tid) */
exit
end

if((port<>0) & (rc=0))then
  rc = AdeptRawComLink(line, Port)
/*if rc = 65558 then do*/
  rc = AdeptRawClose(Port)
/* rc = AdeptKillRexxThread(tid) */
  exit
  end
else
do
  Call AdeptPrint line,"\r\nError: Could not connect to host.\r\n\r\n"
  Call AdeptPrint line,"{PB"
/* rc = AdeptKillRexxThread(tid) */
  exit
end

