home *** CD-ROM | disk | FTP | other *** search
/ CICA 1994 September / CICA_Shareware_for_Windows_Walnut_Creek_September_1994.iso / win3 / winsock / gcp_24.exe / FILOPEN.BA_ / FILOPEN.BA
Text File  |  1994-03-06  |  8KB  |  131 lines

  1. Declare Function WritePrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lplFileName As String) As Integer
  2. Declare Function GetPrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
  3. Declare Function GetPrivateProfileInt Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Integer, ByVal lpFileName As String) As Integer
  4.  
  5. Function GetFilename (Prompt As String, Default As String)
  6.     CenterForm frmMDI, ConnectDlg
  7.     ConnectDlg.Caption = Prompt
  8.     ConnectDlg.Text1 = Default
  9.     ConnectDlg.Text1.SelStart = 0
  10.     ConnectDlg.Text1.SelLength = Len(ConnectDlg.Text1)
  11.     'ConnectDlg.Text1.SetFocus
  12.     ConnectDlg.Show Modal
  13.     GetFilename = ConnectDlg.Text1
  14. End Function
  15.  
  16. Sub LoadConfig (SessionName As String)
  17.     ' query user for configuration name
  18.     Dim Tmp As String * 80
  19.     If (SessionName <> "") Then
  20.     FIndex = FindFreeIndex()
  21.     FState(FIndex).Session = SessionName
  22.     Document(FIndex).Tag = FIndex
  23.     Document(FIndex).WindowState = 0
  24.     Document(FIndex).Caption = SessionName & " - loading..."
  25.     Document(FIndex).VT1.BackColor = GetPrivateProfileInt(SessionName, "BackColor", frmMDI.ActiveForm.VT1.BackColor, IniFile)
  26.     Document(FIndex).VT1.BoldColor = GetPrivateProfileInt(SessionName, "BoldColor", frmMDI.ActiveForm.VT1.BoldColor, IniFile)
  27.     Document(FIndex).VT1.CharSet = GetPrivateProfileInt(SessionName, "CharSet", frmMDI.ActiveForm.VT1.CharSet, IniFile)
  28.     Document(FIndex).VT1.Columns = GetPrivateProfileInt(SessionName, "Columns", frmMDI.ActiveForm.VT1.Columns, IniFile)
  29.     Document(FIndex).VT1.CursorKeys = GetPrivateProfileInt(SessionName, "CursorKeys", frmMDI.ActiveForm.VT1.CursorKeys, IniFile)
  30.     Document(FIndex).VT1.EditKeys = GetPrivateProfileInt(SessionName, "EditKeys", frmMDI.ActiveForm.VT1.EditKeys, IniFile)
  31.     Document(FIndex).VT1.Emulate = GetPrivateProfileInt(SessionName, "Emulate", frmMDI.ActiveForm.VT1.Emulate, IniFile)
  32.     Document(FIndex).VT1.ForeColor = GetPrivateProfileInt(SessionName, "ForeColor", frmMDI.ActiveForm.VT1.ForeColor, IniFile)
  33.     
  34.     'put into form load
  35.     'Document(FIndex).Left = GetPrivateProfileInt(SessionName, "Left", frmMDI.ActiveForm.Left, IniFile)
  36.     'Document(FIndex).Height = GetPrivateProfileInt(SessionName, "Height", frmMDI.ActiveForm.Height, IniFile)
  37.     'Document(FIndex).Top = GetPrivateProfileInt(SessionName, "Top", frmMDI.ActiveForm.Top, IniFile)
  38.     'Document(FIndex).Width = GetPrivateProfileInt(SessionName, "Width", frmMDI.ActiveForm.Width, IniFile)
  39.     
  40.     Document(FIndex).VT1.Keypad = GetPrivateProfileInt(SessionName, "Keypad", frmMDI.ActiveForm.VT1.Keypad, IniFile)
  41.     Document(FIndex).VT1.LocalEcho = GetPrivateProfileInt(SessionName, "LocalEcho", frmMDI.ActiveForm.VT1.LocalEcho, IniFile)
  42.     Document(FIndex).VT1.SevenBitControls = GetPrivateProfileInt(SessionName, "SevenBitControls", frmMDI.ActiveForm.VT1.SevenBitControls, IniFile)
  43.     suc = GetPrivateProfileString(SessionName, "UsernamePrompt", "ogin:", Tmp, 80, IniFile)
  44.     Document(FIndex).VT1.UsernamePrompt = Tmp
  45.     suc = GetPrivateProfileString(SessionName, "PasswordPrompt", "assword:", Tmp, 80, IniFile)
  46.     Document(FIndex).VT1.PasswordPrompt = Tmp
  47.     'Document(FIndex).VT1.PrintMode = GetPrivateProfileInt(SessionName, "PrintMode", frmMDI.ActiveForm.VT1.PrintMode, IniFile)
  48.     suc = GetPrivateProfileString(SessionName, "RemoteAddress", SessionName, Tmp, 80, IniFile)
  49.     Document(FIndex).VT1.RemoteAddress = Tmp
  50.     Document(FIndex).VT1.RemotePort = GetPrivateProfileInt(SessionName, "RemotePort", frmMDI.ActiveForm.VT1.RemotePort, IniFile)
  51.     Document(FIndex).VT1.TermType = GetPrivateProfileInt(SessionName, "TermType", frmMDI.ActiveForm.VT1.TermType, IniFile)
  52.     'Com stuff
  53.     suc = GetPrivateProfileString(SessionName, "CommSettings", frmMDI.ActiveForm.VT1.CommSettings, Tmp, 80, IniFile)
  54.     Document(FIndex).VT1.CommSettings = Tmp
  55.     Document(FIndex).VT1.FlowControl = GetPrivateProfileInt(SessionName, "FlowControl", frmMDI.ActiveForm.VT1.FlowControl, IniFile)
  56.     Document(FIndex).VT1.Protocol = GetPrivateProfileInt(SessionName, "Protocol", frmMDI.ActiveForm.VT1.Protocol, IniFile)
  57.     i = 0
  58.     Do While i < 256
  59.         suc = GetPrivateProfileString(SessionName, "KeyMap(" + Str$(i) + ")", frmMDI.ActiveForm.VT1.KeyMap(i), Tmp, 80, IniFile)
  60.         If suc Then
  61.         frmMDI.ActiveForm.VT1.KeyMap(i) = Tmp
  62.         End If
  63.         i = i + 1
  64.     Loop
  65.     'Else
  66.     'MsgBox "Session configuration not found...using defaults"
  67.     End If
  68.  
  69.     ' set the Notepad's Session name
  70.     Document(FIndex).Caption = SessionName & " - initialized"
  71.     ' reset the dirty flag
  72.     FState(FIndex).Dirty = False
  73. End Sub
  74.  
  75. Sub SaveFileAs (SessionName As String)
  76. On Error Resume Next
  77.     Dim Tmp As String
  78.     ' save SessionName for next opening of a session
  79.     suc = WritePrivateProfileString(AppName, "LastSessionName", SessionName, IniFile)
  80.     Tmp = frmMDI.ActiveForm.VT1.RemoteAddress
  81.     suc = WritePrivateProfileString(AppName, "LastRemoteAddress", Tmp, IniFile)
  82.     ' save configuration
  83.     suc = WritePrivateProfileString(SessionName, "BackColor", Str$(frmMDI.ActiveForm.VT1.BackColor), IniFile)
  84.     suc = WritePrivateProfileString(SessionName, "BoldColor", Str$(frmMDI.ActiveForm.VT1.BoldColor), IniFile)
  85.     suc = WritePrivateProfileString(SessionName, "CharSet", Str$(frmMDI.ActiveForm.VT1.CharSet), IniFile)
  86.     suc = WritePrivateProfileString(SessionName, "Columns", Str$(frmMDI.ActiveForm.VT1.Columns), IniFile)
  87.     suc = WritePrivateProfileString(SessionName, "CursorKeys", Str$(frmMDI.ActiveForm.VT1.CursorKeys), IniFile)
  88.     suc = WritePrivateProfileString(SessionName, "EditKeys", Str$(frmMDI.ActiveForm.VT1.EditKeys), IniFile)
  89.     suc = WritePrivateProfileString(SessionName, "Emulate", Str$(frmMDI.ActiveForm.VT1.Emulate), IniFile)
  90.     suc = WritePrivateProfileString(SessionName, "ForeColor", Str$(frmMDI.ActiveForm.VT1.ForeColor), IniFile)
  91.     suc = WritePrivateProfileString(SessionName, "Height", Str$(frmMDI.ActiveForm.Height), IniFile)
  92.     suc = WritePrivateProfileString(SessionName, "Keypad", Str$(frmMDI.ActiveForm.VT1.Keypad), IniFile)
  93.     suc = WritePrivateProfileString(SessionName, "Left", Str$(frmMDI.ActiveForm.Left), IniFile)
  94.     suc = WritePrivateProfileString(SessionName, "LocalEcho", Str$(frmMDI.ActiveForm.VT1.LocalEcho), IniFile)
  95.     suc = WritePrivateProfileString(SessionName, "SevenBitControls", Str$(frmMDI.ActiveForm.VT1.SevenBitControls), IniFile)
  96.     Tmp = frmMDI.ActiveForm.VT1.UsernamePrompt
  97.     suc = WritePrivateProfileString(SessionName, "UsernamePrompt", Tmp, IniFile)
  98.     Tmp = frmMDI.ActiveForm.VT1.PasswordPrompt
  99.     suc = WritePrivateProfileString(SessionName, "PasswordPrompt", Tmp, IniFile)
  100.     'suc = WritePrivateProfileString(SessionName, "PrintMode", Str$(frmMDI.ActiveForm.VT1.PrintMode), IniFile)
  101.     Tmp = frmMDI.ActiveForm.VT1.RemoteAddress
  102.     If (Tmp = "") Then
  103.     Tmp = SessionName
  104.     End If
  105.     suc = WritePrivateProfileString(SessionName, "RemoteAddress", Tmp, IniFile)
  106.     suc = WritePrivateProfileString(SessionName, "RemotePort", Str$(frmMDI.ActiveForm.VT1.RemotePort), IniFile)
  107.     suc = WritePrivateProfileString(SessionName, "TermType", Str$(frmMDI.ActiveForm.VT1.TermType), IniFile)
  108.     suc = WritePrivateProfileString(SessionName, "Top", Str$(frmMDI.ActiveForm.Top), IniFile)
  109.     suc = WritePrivateProfileString(SessionName, "Width", Str$(frmMDI.ActiveForm.Width), IniFile)
  110.     'Com stuff
  111.     Tmp = frmMDI.ActiveForm.VT1.CommSettings
  112.     suc = WritePrivateProfileString(SessionName, "CommSettings", Tmp, IniFile)
  113.     suc = WritePrivateProfileString(SessionName, "FlowControl", Str$(frmMDI.ActiveForm.VT1.FlowControl), IniFile)
  114.     suc = WritePrivateProfileString(SessionName, "Protocol", Str$(frmMDI.ActiveForm.VT1.Protocol), IniFile)
  115.     i = 0
  116.     Do While i < 256
  117.     If frmMDI.ActiveForm.VT1.KeyMap(i) <> "" Then
  118.         Tmp = frmMDI.ActiveForm.VT1.KeyMap(i)
  119.         suc = WritePrivateProfileString(SessionName, "KeyMap(" + Str$(i) + ")", Tmp, IniFile)
  120.     End If
  121.     i = i + 1
  122.     Loop
  123.  
  124.     ' set the Notepad's caption
  125.     FState(frmMDI.ActiveForm.Tag).Session = SessionName
  126.     frmMDI.ActiveForm.Caption = SessionName & " - saved"
  127.     ' reset the dirty flag
  128.     FState(frmMDI.ActiveForm.Tag).Dirty = False
  129. End Sub
  130.  
  131.