home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / QBAS / VBUTIL.ZIP / FILOPEN.BAS < prev    next >
BASIC Source File  |  1992-10-18  |  2KB  |  80 lines

  1.  
  2. Sub FOpenProc ()
  3.     Dim OpenFileName As String
  4.     
  5.     OpenFileName = GetFilename("Open")
  6.     If OpenFileName <> "" Then
  7.     OpenFile (OpenFileName)
  8.     End If
  9. End Sub
  10.  
  11. Function GetFilename (DialogType As String)
  12.     FileForm.Caption = DialogType
  13.     CenterForm frmMDI, FileForm
  14.     FileForm.Show modal
  15.  
  16.     GetFilename = FileForm!txtFileName.Text
  17.  
  18. End Function
  19.  
  20. Function IsValidFilename (fname As String) As Integer
  21.     If Len(fname) < 13 Then
  22.     IsValidFilename = True
  23.     End If
  24. End Function
  25.  
  26. Sub OpenFile (filename)
  27.     Dim NL, TextIn, GetLine
  28.     Dim fIndex As Integer
  29.  
  30.     NL = Chr$(13) + Chr$(10)
  31.     
  32.     On Error Resume Next
  33.     ' open the selected file
  34.     Open filename For Input As #1
  35.     If Err Then
  36.     MsgBox "Can't open file: " + filename
  37.     Exit Sub
  38.     End If
  39.     ' change mousepointer to an hourglass
  40.     screen.MousePointer = 11
  41.     
  42.     ' change form's caption and display new text
  43.     fIndex = FindFreeIndex()
  44.     Document(fIndex).Tag = fIndex
  45.     Document(fIndex).Caption = UCase$(filename)
  46.     Document(fIndex).Text1.Text = Input$(LOF(1), 1)
  47.     FState(fIndex).Dirty = False
  48.     Document(fIndex).Show
  49.     Close #1
  50.     ' reset mouse pointer
  51.     screen.MousePointer = 0
  52. End Sub
  53.  
  54. Sub SaveFileAs (filename)
  55. On Error Resume Next
  56.     Dim Contents As String
  57.  
  58.     ' open the file
  59.     Open filename For Output As #1
  60.     ' put contents of the notepad into a variable
  61.     Contents = frmMDI.ActiveForm.Text1.Text
  62.     ' display hourglass
  63.     screen.MousePointer = 11
  64.     ' write variable contents to saved file
  65.     Print #1, Contents
  66.     Close #1
  67.     ' reset the mousepointer
  68.     screen.MousePointer = 0
  69.     ' set the Notepad's caption
  70.  
  71.     If Err Then
  72.     MsgBox Error, 48, App.Title
  73.     Else
  74.     frmMDI.ActiveForm.Caption = UCase$(filename)
  75.     ' reset the dirty flag
  76.     FState(frmMDI.ActiveForm.Tag).Dirty = False
  77.     End If
  78. End Sub
  79.  
  80.