home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / wwais103 / question.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-08  |  13.7 KB  |  456 lines

  1. VERSION 2.00
  2. Begin Form question_form 
  3.    BackColor       =   &H00808080&
  4.    Caption         =   "WAIS Query"
  5.    ClientHeight    =   5535
  6.    ClientLeft      =   -90
  7.    ClientTop       =   1470
  8.    ClientWidth     =   9540
  9.    Height          =   5940
  10.    Icon            =   QUESTION.FRX:0000
  11.    Left            =   -150
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form1"
  14.    ScaleHeight     =   5535
  15.    ScaleWidth      =   9540
  16.    Top             =   1125
  17.    Width           =   9660
  18.    WindowState     =   1  'Minimized
  19.    Begin CommandButton view 
  20.       Caption         =   "&View"
  21.       Height          =   375
  22.       Left            =   120
  23.       TabIndex        =   10
  24.       Top             =   2790
  25.       Width           =   735
  26.    End
  27.    Begin ListBox title 
  28.       BackColor       =   &H00FFFFC0&
  29.       FontBold        =   0   'False
  30.       FontItalic      =   0   'False
  31.       FontName        =   "Terminal"
  32.       FontSize        =   9
  33.       FontStrikethru  =   0   'False
  34.       FontUnderline   =   0   'False
  35.       Height          =   3990
  36.       Left            =   1200
  37.       TabIndex        =   9
  38.       TabStop         =   0   'False
  39.       Top             =   2430
  40.       Width           =   8295
  41.    End
  42.    Begin CommandButton done 
  43.       Caption         =   "Done"
  44.       Height          =   375
  45.       Left            =   8760
  46.       TabIndex        =   12
  47.       Top             =   1800
  48.       Width           =   735
  49.    End
  50.    Begin CommandButton Command6 
  51.       Caption         =   "&Setup"
  52.       Height          =   375
  53.       Left            =   7920
  54.       TabIndex        =   11
  55.       Top             =   1800
  56.       Width           =   735
  57.    End
  58.    Begin CommandButton Command1 
  59.       Caption         =   "Help"
  60.       Height          =   375
  61.       Left            =   6960
  62.       TabIndex        =   21
  63.       Top             =   1800
  64.       Width           =   855
  65.    End
  66.    Begin CommandButton del_doc 
  67.       Caption         =   "&Delete Doc"
  68.       Height          =   375
  69.       Left            =   5160
  70.       TabIndex        =   8
  71.       Top             =   1800
  72.       Width           =   1215
  73.    End
  74.    Begin CommandButton add_doc 
  75.       Caption         =   "&Add Doc"
  76.       Height          =   375
  77.       Left            =   3840
  78.       TabIndex        =   7
  79.       Top             =   1800
  80.       Width           =   1215
  81.    End
  82.    Begin CommandButton del_source 
  83.       Caption         =   "Delete Source"
  84.       Height          =   375
  85.       Left            =   1680
  86.       TabIndex        =   5
  87.       Top             =   1800
  88.       Width           =   1455
  89.    End
  90.    Begin CommandButton add_source 
  91.       Caption         =   "Add Source"
  92.       Height          =   375
  93.       Left            =   120
  94.       TabIndex        =   4
  95.       Top             =   1800
  96.       Width           =   1455
  97.    End
  98.    Begin ListBox reference 
  99.       BackColor       =   &H00C0FFC0&
  100.       FontBold        =   0   'False
  101.       FontItalic      =   0   'False
  102.       FontName        =   "Terminal"
  103.       FontSize        =   9
  104.       FontStrikethru  =   0   'False
  105.       FontUnderline   =   0   'False
  106.       Height          =   750
  107.       Left            =   3840
  108.       TabIndex        =   6
  109.       TabStop         =   0   'False
  110.       Top             =   900
  111.       Width           =   5655
  112.    End
  113.    Begin ListBox source_list 
  114.       BackColor       =   &H00FFC0FF&
  115.       FontBold        =   0   'False
  116.       FontItalic      =   0   'False
  117.       FontName        =   "Terminal"
  118.       FontSize        =   9
  119.       FontStrikethru  =   0   'False
  120.       FontUnderline   =   0   'False
  121.       Height          =   750
  122.       Left            =   120
  123.       TabIndex        =   3
  124.       TabStop         =   0   'False
  125.       Top             =   900
  126.       Width           =   3615
  127.    End
  128.    Begin CommandButton search 
  129.       Caption         =   "&Search"
  130.       Height          =   375
  131.       Left            =   8640
  132.       TabIndex        =   2
  133.       Top             =   360
  134.       Width           =   855
  135.    End
  136.    Begin TextBox keywords 
  137.       BackColor       =   &H00FFC0C0&
  138.       FontBold        =   0   'False
  139.       FontItalic      =   0   'False
  140.       FontName        =   "Terminal"
  141.       FontSize        =   9
  142.       FontStrikethru  =   0   'False
  143.       FontUnderline   =   0   'False
  144.       Height          =   315
  145.       Left            =   120
  146.       TabIndex        =   1
  147.       Top             =   360
  148.       Width           =   8295
  149.    End
  150.    Begin Label stat_line 
  151.       BackColor       =   &H00C0E0FF&
  152.       BorderStyle     =   1  'Fixed Single
  153.       FontBold        =   0   'False
  154.       FontItalic      =   0   'False
  155.       FontName        =   "Terminal"
  156.       FontSize        =   9
  157.       FontStrikethru  =   0   'False
  158.       FontUnderline   =   0   'False
  159.       Height          =   285
  160.       Left            =   840
  161.       TabIndex        =   16
  162.       Top             =   6480
  163.       Width           =   8655
  164.    End
  165.    Begin Label Label6 
  166.       BackColor       =   &H00808080&
  167.       Caption         =   "Status:"
  168.       Height          =   195
  169.       Left            =   120
  170.       TabIndex        =   17
  171.       Top             =   6480
  172.       Width           =   615
  173.    End
  174.    Begin Label Label8 
  175.       BackColor       =   &H00808080&
  176.       Caption         =   "Title"
  177.       Height          =   195
  178.       Left            =   2640
  179.       TabIndex        =   20
  180.       Top             =   2250
  181.       Width           =   495
  182.    End
  183.    Begin Label Label7 
  184.       BackColor       =   &H00808080&
  185.       Caption         =   "Size"
  186.       Height          =   195
  187.       Left            =   2040
  188.       TabIndex        =   19
  189.       Top             =   2250
  190.       Width           =   495
  191.    End
  192.    Begin Label Label5 
  193.       BackColor       =   &H00808080&
  194.       Caption         =   "Score"
  195.       Height          =   195
  196.       Left            =   1200
  197.       TabIndex        =   18
  198.       Top             =   2250
  199.       Width           =   615
  200.    End
  201.    Begin Label Label4 
  202.       BackColor       =   &H00808080&
  203.       Caption         =   "Resulting Documents"
  204.       Height          =   375
  205.       Left            =   120
  206.       TabIndex        =   15
  207.       Top             =   2250
  208.       Width           =   975
  209.    End
  210.    Begin Label Label2 
  211.       BackColor       =   &H00808080&
  212.       Caption         =   "Similar to:"
  213.       Height          =   165
  214.       Left            =   3840
  215.       TabIndex        =   13
  216.       Top             =   720
  217.       Width           =   975
  218.    End
  219.    Begin Label Label3 
  220.       BackColor       =   &H00808080&
  221.       Caption         =   "In sources:"
  222.       Height          =   165
  223.       Left            =   120
  224.       TabIndex        =   14
  225.       Top             =   720
  226.       Width           =   1575
  227.    End
  228.    Begin Label Label1 
  229.       BackColor       =   &H00808080&
  230.       Caption         =   "Tell me about:"
  231.       Height          =   165
  232.       Left            =   120
  233.       TabIndex        =   0
  234.       Top             =   90
  235.       Width           =   1455
  236.    End
  237. Sub add_doc_Click ()
  238.     If title.listindex = -1 Then
  239.         MsgBox ("Please highlight a reference for comparison")
  240.         Exit Sub
  241.     End If
  242.     ref_doc_size(reference.listcount) = title_doc_size(title.listindex)
  243.     ref_doc_bytes(reference.listcount) = title_doc_bytes(title.listindex)
  244.     ref_type(reference.listcount) = title_type(title.listindex)
  245.     ref_start(reference.listcount) = -1
  246.     ref_end(reference.listcount) = -1
  247.     reference.AddItem Right$(title.text, Len(title.text) - 11)
  248. End Sub
  249. Sub add_source_Click ()
  250.     mousepointer = HOURGLASS
  251.     sources_form.Show
  252.     mousepointer = DEFAULT
  253. End Sub
  254.         
  255. Sub Command1_Click ()
  256. Open "wais.hlp" For Input As 4
  257.     Do Until EOF(4)
  258.         Line Input #4, lines$
  259.         res$ = res$ + lines$ + Chr$(13) + Chr$(10)
  260.     Loop
  261.     Form3.Text1.text = res$
  262.     Form3.Show
  263.     Close (4)
  264. End Sub
  265. Sub Command6_Click ()
  266. Form1.Show 1
  267. End Sub
  268. Sub del_doc_Click ()
  269.     Dim x As Integer
  270.     If reference.listindex > -1 Then
  271.         
  272.         For x = reference.listindex To reference.listcount
  273.             ref_doc_size(x) = ref_doc_size(x + 1)
  274.             ref_doc_bytes(x) = ref_doc_bytes(x + 1)
  275.         Next x
  276.         
  277.         reference.RemoveItem reference.listindex
  278.     Else
  279.         MsgBox ("You haven't selected a reference to delete")
  280.     End If
  281. End Sub
  282. Sub del_source_Click ()
  283.     Dim x As Integer
  284.     If source_list.listindex > -1 Then
  285.         
  286.         For x = source_list.listindex To source_list.listcount
  287.             src_port(x) = src_port(x + 1)
  288.             src_service(x) = src_service(x + 1)
  289.             src_database(x) = src_database(x + 1)
  290.         Next x
  291.         
  292.         source_list.RemoveItem source_list.listindex
  293.     Else
  294.         MsgBox ("You haven't selected a source to delete")
  295.     End If
  296. End Sub
  297. Sub Done_Click ()
  298.     If sources_loaded Then
  299.          Close
  300.         Open "wais.src" For Output As 3
  301.         src = sources_form.s_source_list.listcount - 1
  302.         For x = 0 To src
  303.             slist$ = s_database(x) + Str$(s_port(x)) + " " + s_service(x) + " " + sources_form.s_source_list.list(x)
  304.             Print #3, slist$
  305.         Next x
  306.         
  307.         Close (3)
  308.     End If
  309.     Kill "wais.$$$"
  310.     End
  311. End Sub
  312. Sub Form_Load ()
  313.     Open "wais.$$$" For Output As 1
  314.     Close (1)
  315.     max_docs% = 100
  316.     windowstate = 2
  317.     mousepointer = DEFAULT
  318.     Form1.Text2.text = "100"
  319. End Sub
  320. Sub map_Click ()
  321.     mousepointer = HOURGLASS
  322.     mousepointer = DEFAULT
  323. End Sub
  324. Sub search_Click ()
  325.     Dim func As Integer
  326.     Dim stat As Integer
  327.     Dim docno As Integer
  328.     Dim refno As Integer
  329.     Dim tot_ref As Integer
  330.     Dim headline As DOC
  331.     Dim refid As REF
  332.     If source_list.listcount = 0 Then
  333.         MsgBox ("You must select at least one source")
  334.         Exit Sub
  335.     End If
  336.     mousepointer = HOURGLASS
  337.     tot_ref = reference.listcount
  338.       
  339.     If tot_ref > 0 Then
  340.         
  341.         For refno = 0 To tot_ref - 1
  342.             refid.ch_start = ref_start(refno) - 1
  343.             refid.ch_end = ref_end(refno)
  344.             refid.doc_size = ref_doc_size(refno)
  345.             refid.type = ref_type(refno)
  346.             refid.doc_bytes = ref_doc_bytes(refno)
  347.             stat = reference_titles(refno, tot_ref, refid)
  348.         Next refno
  349.     End If
  350.     func = 0
  351.     For x = 0 To source_list.listcount - 1
  352.         
  353.         If x > 0 Then
  354.             func = 1
  355.         End If
  356.         If x = source_list.listcount - 1 Then
  357.             func = 2
  358.         End If
  359.         
  360.         kw$ = keywords.text
  361.         If Len(kw$) = 0 Then
  362.             kw$ = " "
  363.         End If
  364.         stat_line.caption = " Connecting to service " + src_service(x) + ", database " + src_database(x)
  365.         
  366.         z = DoEvents()
  367.         stat = query_titles(func, tot_ref, src_service(x), src_database(x), kw$, src_port(x))
  368.         test_for_error stat, 0
  369.     Next x
  370.     If title.listcount > 0 Then
  371.         For x = 0 To title.listcount - 1
  372.             title.RemoveItem 0
  373.         Next x
  374.     End If
  375.     stat = 0
  376.     docno = 0
  377.     While stat = 0 And docno < max_docs
  378.         
  379.         stat = get_titles(docno, headline)
  380.         
  381.         test_for_error stat, docno
  382.         If stat = 0 Or stat = 1 Then
  383.             title_doc_size(docno) = headline.doc_size
  384.             title_doc_bytes(docno) = Left$(headline.doc_bytes, headline.doc_size)
  385.             title_type(docno) = headline.type
  386.             
  387.             tscore$ = Format$(headline.score, "###0")
  388.             tscore$ = Space$(4 - Len(tscore$)) + tscore$
  389.             tlength$ = Format$(headline.length / 1000, "###.0K")
  390.             tlength$ = Space$(7 - Len(tlength$)) + tlength$
  391.             msg$ = tscore$ + tlength$ + " " + RTrim$(headline.title)
  392.             title.AddItem msg$
  393.             docno = docno + 1
  394.         End If
  395.     Wend
  396.     mousepointer = DEFAULT
  397. End Sub
  398. Sub test_for_error (stat As Integer, docno As Integer)
  399.         
  400.     Select Case stat
  401.       Case 0
  402.         Exit Sub
  403.       Case 1
  404.         stat_line.caption = " Found" + Str$(docno + 1) + " references"
  405.       Case 2
  406.         stat_line.caption = " Error 2"
  407.       Case 3
  408.         stat_line.caption = " Error 3"
  409.       Case 4
  410.         stat_line.caption = " Error 4"
  411.       Case 5
  412.         stat_line.caption = " Error 5"
  413.       Case 6
  414.         stat_line.caption = " Premature end of text"
  415.         stat = 0
  416.       Case 7
  417.         stat_line.caption = " Error 7"
  418.       Case 8
  419.         stat_line.caption = " No matching references found"
  420.       Case Else
  421.         stat_line.caption = " Unknown error" + Str$(stat)
  422.     End Select
  423.     z = DoEvents()
  424. End Sub
  425. Sub title_DblClick ()
  426.     Dim docno As Integer
  427.     Dim doc_lines As Integer
  428.     Dim stat As Integer
  429.     Dim rec As String * 80
  430.     mousepointer = HOURGLASS
  431.     stat_line.caption = " Getting document from server..."
  432.     docno = title.listindex
  433.     stat = get_document(docno, title_type(docno))
  434.     test_for_error stat, docno
  435.     If stat = 0 Then
  436.             If InStr(title_type(docno), "GIF") Then
  437.                 i = Shell("wingif.exe wais.$$$", 1)
  438.             ElseIf InStr(title_type(docno), "TEXT") Then
  439.                  view_form.Show 1
  440.             ElseIf InStr(title_type(docno), "WSRC") Then
  441.                   view_form.Show 1
  442.             Else
  443.                 save_form.Show 1
  444.             End If
  445.     End If
  446.     stat_line.caption = ""
  447.     mousepointer = DEFAULT
  448. End Sub
  449. Sub view_Click ()
  450.     If title.listindex = -1 Then
  451.         MsgBox ("Please select a title to view")
  452.         Exit Sub
  453.     End If
  454.     title_DblClick
  455. End Sub
  456.