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

  1. VERSION 2.00
  2. Begin Form view_form 
  3.    BackColor       =   &H00FFFFFF&
  4.    Caption         =   "View"
  5.    ClientHeight    =   6915
  6.    ClientLeft      =   210
  7.    ClientTop       =   345
  8.    ClientWidth     =   9360
  9.    DrawMode        =   6  'Invert
  10.    FontBold        =   0   'False
  11.    FontItalic      =   0   'False
  12.    FontName        =   "Terminal"
  13.    FontSize        =   9
  14.    FontStrikethru  =   0   'False
  15.    FontUnderline   =   0   'False
  16.    Height          =   7320
  17.    Left            =   150
  18.    LinkMode        =   1  'Source
  19.    LinkTopic       =   "Form1"
  20.    ScaleHeight     =   6915
  21.    ScaleWidth      =   9360
  22.    Top             =   0
  23.    Width           =   9480
  24.    Begin Frame Frame1 
  25.       BackColor       =   &H0080FF80&
  26.       Height          =   855
  27.       Left            =   0
  28.       TabIndex        =   3
  29.       Top             =   6120
  30.       Width           =   9615
  31.       Begin CommandButton view_done 
  32.          Caption         =   "&Done"
  33.          Height          =   375
  34.          Left            =   2760
  35.          TabIndex        =   2
  36.          Top             =   240
  37.          Width           =   1095
  38.       End
  39.       Begin CommandButton view_save 
  40.          Caption         =   "&Save"
  41.          Height          =   375
  42.          Left            =   1560
  43.          TabIndex        =   1
  44.          Top             =   240
  45.          Width           =   1095
  46.       End
  47.       Begin CommandButton view_addsec 
  48.          Caption         =   "&Add Section"
  49.          Height          =   375
  50.          Left            =   240
  51.          TabIndex        =   0
  52.          Top             =   240
  53.          Width           =   1215
  54.       End
  55.    End
  56.    Begin TextBox Text1 
  57.       BackColor       =   &H00FFFFFF&
  58.       Height          =   6135
  59.       Left            =   0
  60.       MultiLine       =   -1  'True
  61.       ScrollBars      =   3  'Both
  62.       TabIndex        =   4
  63.       Text            =   "Text1"
  64.       Top             =   0
  65.       Width           =   9375
  66.    End
  67. Dim rec As String * 80
  68. Dim word(19) As String
  69. Dim recno As Integer
  70. Dim doc_lines As Integer
  71. Dim lines_per_page As Integer
  72. Dim line_size As Single
  73. Dim box_top As Single
  74. Dim box_bottom As Single
  75. Dim box_drawn As Integer
  76. Dim button_down As Integer
  77. Sub CheckNewLines (LineFrom As String, FileNum As Integer)
  78. Do Until EOF(FileNum)
  79.     char$ = Input$(1, FileNum)
  80.     If char$ <> Chr$(13) Then
  81.         If char$ <> Chr$(10) Then
  82.             LineFrom$ = LineFrom$ + char$
  83.         Else
  84.             GotFeed% = True
  85.             If EOF(FileNum) Then
  86.                 Exit Do
  87.              End If
  88.             EndLine$ = Input$(1, FileNum)
  89.             If EndLine$ = Chr$(10) Or EndLine$ = Chr$(13) Then
  90.                EndLine$ = Chr$(13) + Chr$(10)
  91.                LineFrom$ = LineFrom$ + EndLine$
  92.             ElseIf EndLine$ <> Chr$(13) Then
  93.                 EndLine$ = Chr$(13) + Chr$(10) + EndLine$
  94.                 LineFrom$ = LineFrom$ + EndLine$
  95.             End If
  96.         End If
  97.     Else
  98.         GotReturn% = True
  99.         If EOF(FileNum) Then
  100.             Exit Do
  101.             End If
  102.         char$ = Input$(1, FileNum)
  103.         If char$ = Chr$(10) Then
  104.             GotCR_LF% = True
  105.             EndLine$ = Chr$(13) + Chr$(10)
  106.         ElseIf char$ = Chr$(13) Then
  107.             EndLine$ = Chr$(13) + Chr$(10)
  108.         Else
  109.             EndLine$ = Chr$(13) + Chr$(10) + char$
  110.         End If
  111.         LineFrom$ = LineFrom$ + EndLine$
  112.         If GotCR_LF% = True Then
  113.             Exit Do
  114.         End If
  115.     End If
  116.     Loop
  117. End Sub
  118. Sub Form_Load ()
  119.      
  120.     Open "wais.$$$" For Input As 1
  121.     If LOF(1) > 60000 Then
  122.         text1.Text = "File too Large for Display - Press Save to Save it"
  123.     Else
  124.     CheckNewLines Lines$, 1
  125.     Do Until EOF(1)
  126.             Line Input #1, NextLine$
  127.             Lines$ = Lines$ + NextLine$ + Chr$(13) + Chr$(10)
  128.     Loop
  129.     text1.Text = Lines$
  130.     End If
  131.      Close (1)
  132.     z = DoEvents()
  133. End Sub
  134.                    
  135. Sub show_page ()
  136.     Dim wdno As Integer
  137.     Static init_find As Integer
  138.     Static pos As Integer
  139.     If Not init_find Then
  140.         GoSub first_find
  141.     End If
  142.     view_form.Cls
  143.     ln = -1
  144.     For X = recno To recno + lines_per_page
  145.         
  146.         If X < doc_lines Then
  147.             
  148.             Get #1, X, rec
  149.             view_form.Print " "; rec
  150.             ln = ln + 1
  151.         
  152.             If question_form.keywords.Text <> "" Then
  153.                 rec = LCase$(rec)
  154.                 For Y = 0 To wdno
  155.                     pos = 1
  156.                     While pos > 0
  157.                         pos = InStr(pos, rec, word(Y))
  158.                         If pos > 0 Then
  159.                         
  160.                             view_form.drawmode = 7
  161.                             wd_left = pos * view_form.TextWidth("A")
  162.                             wd_right = (pos + Len(word(Y))) * view_form.TextWidth("A")
  163.                             wd_top = ln * view_form.TextHeight("A")
  164.                             wd_bottom = wd_top + view_form.TextHeight("A")
  165.                             view_form.Line (wd_left, wd_top)-(wd_right, wd_bottom), &HFFFF&, BF
  166.                             view_form.drawmode = 6
  167.                             currentx = 0
  168.                             pos = pos + Len(word(Y))
  169.                         End If
  170.                     Wend
  171.                 Next Y
  172.             End If
  173.         End If
  174.     Next X
  175. Exit Sub
  176. first_find:
  177.     words$ = LCase$(question_form.keywords.Text)
  178.     c1 = 1
  179.     For wdno = 0 To 19
  180.         c2 = InStr(c1, words$, " ")
  181.         If c2 = 0 Then
  182.             word(wdno) = Left$(words$, Len(words$) - c1 + 1)
  183.             Exit For
  184.         End If
  185.         word(wdno) = Mid$(words$, c1, c2 - c1)
  186.         c1 = c2 + 1
  187.         If word(wdno) = "and" Or word(wdno) = "" Or word(wdno) = Space$(Len(word(wdno))) Then
  188.             wdno = wdno - 1
  189.         End If
  190.     Next wdno
  191.     init_find = True
  192. Return
  193. End Sub
  194. Sub view_addsec_Click ()
  195. lwidth% = text1.width / TextWidth("a")
  196.     If text1.SelLength < 1 Then
  197.         MsgBox ("You haven't selected a section to add")
  198.         Exit Sub
  199.     End If
  200.     ref = question_form.reference.listcount
  201.     title = question_form.title.listindex
  202.      l1% = text1.SelStart / lwidth%
  203.     ref_start(ref) = l1%
  204.     l2% = (text1.SelStart + text1.SelLength) / lwidth%
  205.     ref_end(ref) = l2%
  206.     ref_doc_size(ref) = title_doc_size(title)
  207.     ref_type(ref) = title_type(title)
  208.     ref_doc_bytes(ref) = title_doc_bytes(title)
  209.     ref_title$ = question_form.title.Text
  210.     ref_line$ = "[" + LTrim$(Str$(ref_start(ref))) + "," + LTrim$(Str$(ref_end(ref))) + "]" + Right$(ref_title$, Len(ref_title$) - 11)
  211.     question_form.reference.AddItem ref_line$
  212. End Sub
  213. Sub view_done_Click ()
  214.     Unload view_form
  215. End Sub
  216. Sub view_save_Click ()
  217.       Dim rec As String * 500
  218.       If InStr(title_type(title), "TEXT") Then
  219.         save_form.Show 1
  220.       ElseIf InStr(title_type(title), "WSRC") Then
  221.             new_src_form.s_add_server.Text = ""
  222.             new_src_form.s_add_port.Text = ""
  223.             new_src_form.s_add_database.Text = ""
  224.             Close (1)
  225.             Open "wais.$$$" For Input As 1
  226.             Do Until EOF(1)
  227.                 
  228.                 Line Input #1, rec
  229.                 last = 1
  230.                 If InStr(last, LCase$(Left$(rec, Len(rec))), ":ip-name") Then
  231.                     c1 = InStr(rec, Chr$(34))
  232.                     c2 = InStr(c1 + 1, rec, Chr$(34))
  233.                     last = c2 + 1
  234.                     new_src_form.s_add_server.Text = Mid$(rec, c1 + 1, c2 - c1 - 1)
  235.                 End If
  236.                 If InStr(last, LCase$(Left$(rec, Len(rec))), ":tcp-port") > 1 Then
  237.                      i = InStr(last, LCase$(Left$(rec, Len(rec))), ":tcp-port") + 9
  238.                     port$ = Str$(Val(Mid$(rec, i, Len(rec) - 10)))
  239.                     new_src_form.s_add_port.Text = Right$(port$, Len(port$) - 1)
  240.                     last = i
  241.                 End If
  242.                 If InStr(last, LCase$(Left$(rec, Len(rec))), ":database-name") > 1 Then
  243.                     c1 = InStr(last, rec, Chr$(34))
  244.                     c2 = InStr(c1 + 1, rec, Chr$(34))
  245.                     last = c2 + 1
  246.                     new_src_form.s_add_database.Text = Mid$(rec, c1 + 1, c2 - c1 - 1)
  247.                 End If
  248.         
  249.              Loop
  250.              Close (1)
  251.             new_src_form.s_add_title.Text = Right$(question_form.title.Text, Len(question_form.title.Text) - 11)
  252.             new_src_form.Show 1
  253.     End If
  254. End Sub
  255. Sub view_scroll_Change ()
  256. End Sub
  257.