home *** CD-ROM | disk | FTP | other *** search
/ Chip: Windows 95 / WIN95_CD.ISO / sharewar / internet / qmodem / scripts.z / MAKEGEN3.QSC < prev    next >
Encoding:
Text File  |  1995-07-20  |  9.7 KB  |  279 lines

  1. '
  2. ' This script is used to automatically create and add new dialing directory
  3. ' entry for GEnie.
  4. '
  5. '--------------------------------------------------------=[ Constants    ]=-
  6. const WS_BORDER       = 0x00800000
  7. const WS_VSCROLL      = 0x00200000
  8. const WS_TABSTOP      = 0x00010000
  9. const LB_RESETCONTENT = 0x0184
  10. const LB_GETTEXT      = 0x0189
  11. const LB_SETTABSTOPS  = 0x0192
  12. const LBS_NOTIFY      = 0x0001
  13. const LBS_SORT        = 0x0002
  14. const LBS_USETABSTOPS = 0x0080
  15. const LBS_STANDARD    = LBS_NOTIFY+WS_BORDER+WS_VSCROLL+WS_TABSTOP
  16. const CB_GETLBTEXT    = 0x0148
  17. const CB_RESETCONTENT = 0x014B
  18.  
  19. '---------------------------------------------------------------------------=[ Dialogs      ]=-
  20. dialog Generator 5, 10, 205, 240
  21.   caption "GENie Script Maker"
  22.   groupbox "User Information", -1, 10, 10, 185, 55
  23.   rtext "Your User Id", -1, 15, 25, 50, 15
  24.   userid as edittext 101, 70, 25, 95, 15
  25.   rtext "Your Password", -1, 15, 45, 50, 15
  26.   password as edittext 102, 70, 45, 95, 15
  27.   groupbox "Phone Information",-1, 10, 70, 185,75
  28.   ltext "Phone Number", -1, 15,105, 70, 15
  29.   areacode as edittext 103,100,105, 25, 15
  30.   number as edittext   104,130,105, 60, 15
  31.   ltext "Country"  ,    -1, 15,125, 40, 15
  32.   country as combobox  105, 60,125,130, 50,LBS_STANDARD+LBS_SORT
  33.   pushbutton "Search Phone Database", 112, 100, 85, 90, 15
  34.   groupbox "Connection Information",-1,10,155,185,55
  35.   ltext "Modem",        -1, 15,170, 40, 15
  36.   modem as combobox    106, 60,170,130, 50
  37.   ltext "Service",      -1, 15,190, 40, 15
  38.   service as combobox  107, 60,190,130, 50 
  39.   defpushbutton "Make Script", 114, 15, 220, 50, 14
  40.   pushbutton "Cancel", IDCANCEL, 75, 220, 50, 14
  41.   pushbutton "Help", 113, 135, 220, 50, 14
  42. end dialog
  43.  
  44. dialog phonesearch 6, 15, 310, 110  
  45.   caption "Search Phone Number List"
  46.   ltext "Area Code",-1, 15,5,40,15
  47.   scode as edittext 603,60,5,20,15
  48.   ltext "Baud Rate",-1, 85,5,40,15
  49.   srate as edittext 604,130,5,30,15
  50.   ltext "State    ",-1,165,5,40,15
  51.   sstate as edittext 605,210,5,20,15
  52.   groupbox "Phone Number       City                        State           Supported Baud Rates",-1,10,20,290,65
  53.   sresult as listbox 507,15,30,280,60,LBS_STANDARD+LBS_USETABSTOPS
  54.   pushbutton "OK",IDOK,70,90,50,15
  55.   pushbutton "Cancel",IDCANCEL,130,90,50,15
  56.   pushbutton "Search",606,190,90,50,15
  57. end dialog
  58.  
  59. dialog ServicesHelp 6, 15, 194, 119
  60.   caption "Online Services Help"
  61.   defpushbutton "OK", IDOK, 72, 97, 50, 14
  62.   groupbox "", -1, 4, 4, 185, 86
  63.   ltext "GEnie Script Generator is used to automaticallu create a script to call GENie.", -1, 10, 10, 170, 25
  64.   ltext "Fill in User Name, Password, Area Code, Number, Country Code, and Modem.", -1, 10, 35, 170, 25
  65.   ltext "The search button allows you search for numbers matching an area code.", -1, 10, 60, 170, 25
  66. end dialog
  67.                                                  
  68. '-----------------------------------------------------------------------=[ Type Declarations ]=-
  69. type tabrecord
  70.   tabs(1 to 3) as integer
  71. end type
  72.  
  73. '-----------------------------------------------------------------------=[ Declarations      ]=-
  74. declare Sub SendDlgItemMessageText lib "user32" alias "SendDlgItemMessageA" (hwnd as integer, id as integer, message as integer, wparam as integer, lparam as string)
  75. declare function SendDlgItemMessageInt  lib "user32" alias "SendDlgItemMessageA" (hwnd as integer, id as integer, message as integer, wparam as integer, lparam as long) as long
  76. declare function SendDlgItemMessageTab Lib "User32" Alias "SendDlgItemMessageA" (Hwnd as integer, Id as integer, Msg as integer, Wparam as integer, lparam as TabRecord) as integer
  77.  
  78. '-----------------------------------------------------------------------=[ Variables         ]=-
  79. dim readstring as string
  80. dim cinfo as countryinfo
  81. dim sl as Generator
  82. dim found as integer
  83. dim count as integer
  84. dim scriptname as string
  85. dim n as string
  86. dim search as phonesearch
  87. dim searchname as string
  88.  
  89. '-----------------------------------------------------------------------=[ Functions         ]=-
  90. function Generator.id(105) as integer
  91.   n = spc(255)
  92.   SendDlgItemMessageText (hwindow,105,CB_GETLBTEXT,country,n)
  93. end function
  94.  
  95. function phonesearch.id(507) as integer
  96.   n = spc(255)
  97.   SendDlgItemMessageText (hwindow,507,LB_GETTEXT,sresult,n)
  98.   dialogresult = IDOK
  99. end function
  100.  
  101. function phonesearch.id(606) as integer
  102.   dim sendmess as integer, totalfound as integer
  103.   dim sfound as boolean
  104.     
  105.   if not ((scode = "") and (srate = "") and (sstate = "")) then 
  106.     totalfound = 0
  107.     sendmess = SendDlgItemMessageInt (hwindow,507,LB_RESETCONTENT,0,0)
  108.     if exists (searchname) then
  109.       open searchname for input as #1
  110.       do while not (eof (1))
  111.         sfound = false
  112.         input #1,readstring
  113.         if (scode <> "") then
  114.           if (srate <> "") then
  115.             if (sstate <> "") then
  116.               if (left (readstring,3) = scode) and (instr (mid (readstring,38,23),srate) <> 0) and (mid (readstring,35,2) = sstate) then sfound = true
  117.             else
  118.               if (left (readstring,3) = scode) and (instr (mid (readstring,38,23),srate) <> 0) then sfound = true
  119.             end if
  120.           else
  121.             if (sstate <> "") then
  122.               if (left (readstring,3) = scode) and (mid (readstring,35,2) = sstate) then sfound = true
  123.             else
  124.               if (left (readstring,3) = scode) then sfound = true
  125.             end if
  126.           end if
  127.         else
  128.           if (srate <> "") then
  129.             if (sstate <> "") then
  130.               if (instr (mid (readstring,38,23),srate) <> 0) and (mid (readstring,35,2) = sstate) then sfound = true
  131.             else
  132.               if (instr (mid (readstring,38,23),srate) <> 0) then sfound = true
  133.             end if
  134.           else
  135.             if (sstate <> "") then
  136.               if (mid (readstring,35,2) = sstate) then sfound = true
  137.             end if
  138.           end if
  139.         end if
  140.         if sfound then
  141.           readstring = left (readstring,12)+chr(9)+mid(readstring,14,20)+chr(9)+mid(readstring,35,2)+chr(9)+mid(readstring,38,25)
  142.           addlistboxitem (hwindow,507,readstring)
  143.           totalfound = totalfound + 1
  144.           sfound = false
  145.         end if
  146.       loop
  147.       close #1
  148.     end if
  149.     if totalfound = 0 then
  150.       addlistboxitem (hwindow,507,"No Records Found Matching Search Criteria!")
  151.     end if
  152.   else
  153.     msgbox "You must select an Area Code, Baud Rate, and/or State to search"
  154.   end if    
  155.   scode = ""
  156.   srate = ""
  157.   sstate = ""
  158. end function
  159.  
  160. function GetUniqueScriptName(prefix as string) as string
  161.   dim scrname as string
  162.   scrname = ConfigScriptPath + "\" + prefix + ".QSC"
  163.   dim i as integer
  164.   i = 0
  165.   do while exists(scrname)
  166.     i = i + 1
  167.     scrname = ConfigScriptPath + "\" + prefix + str(i) + ".QSC"
  168.   loop
  169.   GetUniqueScriptName = scrname
  170. end function
  171.  
  172. function Generator.id(113) as integer
  173.   dim help as ServicesHelp
  174.   dialogbox help
  175. end function
  176.  
  177. function Generator.id(112) as integer
  178.   if sl.service = 0 then searchname = configscriptpath+"\geniereg.dat"
  179.   if sl.service = 1 then searchname = configscriptpath+"\geniespr.dat"
  180.   if dialogbox (search) = IDOK then
  181.     if n <> "" then
  182.       sl.areacode = left (n,3)
  183.       sl.number   = mid  (n,5,8)
  184.     end if
  185.   end if
  186. end function
  187.  
  188. function Generator.id(114) as integer
  189.   if userid = "" then
  190.     msgbox "You need to fill in your User ID."
  191.     exit function
  192.   end if
  193.  
  194.   if password = "" then
  195.     msgbox "You need to fill in your password."
  196.     exit function
  197.   end if
  198.  
  199.   if (number = "") or (areacode = "") then
  200.     msgbox "You need to fill in a phone number."
  201.     exit function
  202.   end if
  203.  
  204.   DialogResult = IDOK
  205. end function
  206.  
  207. '---------------------------------------------------------------------------=[ Subroutines  ]=-
  208. sub phonesearch.init
  209.   dim t as tabrecord, result1 as integer
  210.   t.tabs(1) =  60
  211.   t.tabs(2) =  120
  212.   t.tabs(3) =  140
  213.   result1 = SendDlgItemMessageTab (HWindow, 507, LB_SETTABSTOPS, 3, t)
  214. end sub
  215.  
  216. sub Generator.init
  217.   userid   = ""
  218.   password = ""
  219.   areacode = ""
  220.   number   = ""
  221.   for count = 1 to getmodemcount
  222.     addcomboboxitem (hwindow,106,getmodemname (count - 1))
  223.   next count
  224.   modem = 0
  225.   addcomboboxitem (hwindow,107,"Standard GENie Connection")
  226.   addcomboboxitem (hwindow,107,"GENie Connection Using SprintNet")
  227.   service = 0
  228.   if getfirstcountry (cinfo) then
  229.     do
  230.       readstring = pad (cinfo.name,150)+pad(str(cinfo.countryid),5)+pad(str(cinfo.countrycode),5)
  231.       addcomboboxitem (hwindow,105,readstring)
  232.     loop until not (getnextcountry (cinfo))
  233.   end if
  234. end sub
  235.  
  236. sub CreateGEnieScript
  237.   print #1, "striphibit on"
  238.   print #1, "duplex off"
  239.   print #1, "delay 2"
  240.   print #1, "send ""HHH"";"
  241.   print #1, "waitfor ""U#="""
  242.   print #1, "send lastconnectuserid + "","" + lastconnectpassword"
  243. end sub
  244.  
  245. '---------------------------------------------------------------------------=[ Main         ]=-
  246. MAIN:
  247.  
  248. if dialogbox(sl) = IDOK then
  249.   scriptname = GetUniqueScriptName("genie")
  250.   open scriptname for output as #1
  251.   CreateGEnieScript
  252.   close #1
  253.   dim entry as phoneentry
  254.   entry.name = "GEnie"
  255.   entry.areacode = sl.areacode
  256.   entry.number(1) = sl.number
  257.   entry.userid = sl.userid
  258.   entry.password = sl.password
  259.   entry.scriptfile = scriptname
  260.   entry.emulation = ansi
  261.   entry.protocol = zmodem
  262.   entry.iconrespath = "bbsicons.dll"
  263.   entry.iconresid = 3
  264.   entry.useareacountry = 1
  265.   entry.tapidevice = getmodemname (sl.modem)
  266.   entry.countryid   = val(mid(n,151,5))
  267.   entry.countrycode = val(mid(n,156,5))
  268.   if updatephoneentry (entry) then
  269.     msgbox ("GEnie Entry Modified With New Information")
  270.   else
  271.     addphoneentry (entry)
  272.     msgbox ("Phone directory entry for GEnie created.")
  273.   end if
  274. end if
  275.  
  276. catch err_fileopen
  277.   msgbox "Could not create script: " + scriptname
  278.   goto main
  279.