home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 April / ChipCD_498.iso / software / ftp / quickftp / quickft1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-01-30  |  16.2 KB  |  487 lines

  1. VERSION 2.00
  2. Begin Form Connectform 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Quick Connect"
  6.    ClientHeight    =   4395
  7.    ClientLeft      =   630
  8.    ClientTop       =   2445
  9.    ClientWidth     =   8070
  10.    ControlBox      =   0   'False
  11.    ForeColor       =   &H0000C0C0&
  12.    Height          =   4800
  13.    Left            =   570
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   4395
  18.    ScaleWidth      =   8070
  19.    Top             =   2100
  20.    Width           =   8190
  21.    Begin Frame Frame2 
  22.       Caption         =   "Transfer Info"
  23.       Height          =   1695
  24.       Left            =   240
  25.       TabIndex        =   1
  26.       Top             =   2040
  27.       Width           =   7575
  28.       Begin CheckBox ChkAscii 
  29.          Caption         =   "ASCII transfer"
  30.          Height          =   255
  31.          Left            =   3000
  32.          TabIndex        =   3
  33.          Top             =   1200
  34.          Value           =   1  'Checked
  35.          Width           =   1935
  36.       End
  37.       Begin OptionButton OptGet 
  38.          Caption         =   "GET"
  39.          Height          =   255
  40.          Left            =   720
  41.          TabIndex        =   4
  42.          Top             =   1200
  43.          Value           =   -1  'True
  44.          Width           =   855
  45.       End
  46.       Begin OptionButton OptPUT 
  47.          Caption         =   "PUT"
  48.          Height          =   255
  49.          Left            =   1800
  50.          TabIndex        =   5
  51.          Top             =   1200
  52.          Width           =   855
  53.       End
  54.       Begin TextBox txtLocalFile 
  55.          Height          =   285
  56.          Left            =   3720
  57.          TabIndex        =   6
  58.          Top             =   720
  59.          Width           =   3615
  60.       End
  61.       Begin TextBox txtRemoteFile 
  62.          Height          =   285
  63.          Left            =   3720
  64.          TabIndex        =   7
  65.          Top             =   360
  66.          Width           =   3615
  67.       End
  68.       Begin Label Label6 
  69.          Alignment       =   1  'Right Justify
  70.          BackColor       =   &H00C0C0C0&
  71.          Caption         =   "Local Path (Drive:\Directory\Filename):"
  72.          Height          =   255
  73.          Left            =   240
  74.          TabIndex        =   8
  75.          Top             =   720
  76.          Width           =   3375
  77.       End
  78.       Begin Label Label5 
  79.          Alignment       =   1  'Right Justify
  80.          BackColor       =   &H00C0C0C0&
  81.          Caption         =   "Host FileName:"
  82.          Height          =   255
  83.          Left            =   840
  84.          TabIndex        =   15
  85.          Top             =   360
  86.          Width           =   2775
  87.       End
  88.    End
  89.    Begin Frame Frame3 
  90.       Caption         =   "Connection Info"
  91.       Height          =   1815
  92.       Left            =   240
  93.       TabIndex        =   19
  94.       Top             =   240
  95.       Width           =   4335
  96.       Begin TextBox txtDirect 
  97.          Height          =   285
  98.          Left            =   1680
  99.          TabIndex        =   16
  100.          Top             =   1440
  101.          Width           =   2535
  102.       End
  103.       Begin TextBox UserEdit 
  104.          Height          =   285
  105.          Left            =   1680
  106.          TabIndex        =   22
  107.          Top             =   720
  108.          Width           =   2535
  109.       End
  110.       Begin TextBox PasswordEdit 
  111.          Height          =   285
  112.          Left            =   1680
  113.          PasswordChar    =   "*"
  114.          TabIndex        =   21
  115.          Top             =   1080
  116.          Width           =   2535
  117.       End
  118.       Begin TextBox NodeEdit 
  119.          Height          =   285
  120.          Left            =   1680
  121.          TabIndex        =   20
  122.          Top             =   360
  123.          Width           =   2535
  124.       End
  125.       Begin Label Label4 
  126.          Alignment       =   1  'Right Justify
  127.          BackColor       =   &H00C0C0C0&
  128.          Caption         =   "Initial Directory:"
  129.          Height          =   255
  130.          Left            =   120
  131.          TabIndex        =   17
  132.          Top             =   1440
  133.          Width           =   1455
  134.       End
  135.       Begin Label Label1 
  136.          Alignment       =   1  'Right Justify
  137.          BackColor       =   &H00C0C0C0&
  138.          Caption         =   "Host Name:"
  139.          Height          =   255
  140.          Left            =   240
  141.          TabIndex        =   18
  142.          Top             =   360
  143.          Width           =   1335
  144.       End
  145.       Begin Label Label2 
  146.          Alignment       =   1  'Right Justify
  147.          BackColor       =   &H00C0C0C0&
  148.          Caption         =   "Login Name:"
  149.          Height          =   255
  150.          Left            =   240
  151.          TabIndex        =   24
  152.          Top             =   720
  153.          Width           =   1335
  154.       End
  155.       Begin Label Label3 
  156.          Alignment       =   1  'Right Justify
  157.          BackColor       =   &H00C0C0C0&
  158.          Caption         =   "Password :"
  159.          Height          =   255
  160.          Left            =   240
  161.          TabIndex        =   23
  162.          Top             =   1080
  163.          Width           =   1335
  164.       End
  165.    End
  166.    Begin Frame Frame1 
  167.       Caption         =   "Connection Sequence"
  168.       Height          =   1815
  169.       Left            =   4560
  170.       TabIndex        =   9
  171.       Top             =   240
  172.       Width           =   3255
  173.       Begin TextBox txtCycle 
  174.          Height          =   285
  175.          Left            =   2160
  176.          TabIndex        =   13
  177.          Top             =   1320
  178.          Visible         =   0   'False
  179.          Width           =   975
  180.       End
  181.       Begin OptionButton OptLoginOnly 
  182.          Caption         =   "Login Only"
  183.          Height          =   255
  184.          Left            =   120
  185.          TabIndex        =   12
  186.          Top             =   240
  187.          Value           =   -1  'True
  188.          Width           =   1455
  189.       End
  190.       Begin OptionButton OptFTPOnly 
  191.          Caption         =   "Cycle FTP Only"
  192.          Height          =   255
  193.          Left            =   120
  194.          TabIndex        =   11
  195.          Top             =   600
  196.          Width           =   2175
  197.       End
  198.       Begin OptionButton OptDoitAll 
  199.          Caption         =   "Cycle Connect-FTP-Disconnect"
  200.          Height          =   255
  201.          Left            =   120
  202.          TabIndex        =   10
  203.          Top             =   960
  204.          Width           =   3015
  205.       End
  206.       Begin Label lblCycle 
  207.          Alignment       =   1  'Right Justify
  208.          BackColor       =   &H00C0C0C0&
  209.          Caption         =   "Cycle Time (sec):"
  210.          Height          =   255
  211.          Left            =   480
  212.          TabIndex        =   14
  213.          Top             =   1320
  214.          Visible         =   0   'False
  215.          Width           =   1575
  216.       End
  217.    End
  218.    Begin CommandButton Command2 
  219.       Cancel          =   -1  'True
  220.       Caption         =   "&Cancel"
  221.       Height          =   375
  222.       Left            =   6840
  223.       TabIndex        =   2
  224.       Top             =   3840
  225.       Width           =   975
  226.    End
  227.    Begin CommandButton Command1 
  228.       Caption         =   "&Login"
  229.       Height          =   375
  230.       Left            =   5760
  231.       TabIndex        =   0
  232.       Top             =   3840
  233.       Width           =   975
  234.    End
  235. Function Check_info () As Integer
  236. '__ Connectform Check_info
  237. '__   called by Connectform command1_click
  238. '__   calls     GLOBAL getinput
  239. '__   calls     GLOBAL IsValidGet
  240. '__   calls     GLOBAL IsValidPut
  241. '__   calls     GLOBAL switch_to
  242.   'check if Hostname, Userid and password have been defined
  243.   Dim ok%
  244.   Check_info = False
  245.   ok% = True
  246.   If Len(Trim$(ConnectForm!NodeEdit.Text)) = 0 Then
  247.     ConnectForm!NodeEdit = getinput("Host Name", "")
  248.   End If
  249.   If Len(Trim$(ConnectForm!UserEdit.Text)) = 0 Then
  250.     ConnectForm!UserEdit = getinput("Login Name", "anonymous")
  251.   End If
  252.   If Len(Trim$(ConnectForm!PasswordEdit.Text)) = 0 Then
  253.     ConnectForm!PasswordEdit = getinput("Password", "HIDDENVALUE")
  254.   End If
  255.   If Len(Trim$(ConnectForm!NodeEdit.Text)) = 0 Then
  256.     ok% = False
  257.     switch_to NodeEdit
  258.   ElseIf Len(Trim$(ConnectForm!UserEdit.Text)) = 0 Then
  259.     ok% = False
  260.     switch_to UserEdit
  261.   ElseIf Len(Trim$(ConnectForm!PasswordEdit.Text)) = 0 Then
  262.     ok% = False
  263.     switch_to PasswordEdit
  264.   End If
  265.   If Not ok% Then
  266.     MsgBox "Need Host Name, Login Name and Password to proceed.", 64
  267.     Exit Function
  268.   End If
  269.   switch_to txtLocalFile
  270.   If OptPut And Not OptLoginOnly Then
  271.     If Not IsValidPut(txtLocalFile) Then Exit Function
  272.   End If
  273.   If optGet And Not OptLoginOnly Then
  274.     If Not IsValidGet(txtLocalFile) Then Exit Function
  275.   End If
  276.   Check_info = True
  277. End Function
  278. Sub command1_click ()
  279. '__ Connectform command1_click
  280. '__   calls     Connectform Check_info
  281. '__   calls     Connectform PrivateStrings
  282.   If Check_info() Then
  283.     OkDialog = True
  284.     Hostname = ConnectForm!NodeEdit.Text
  285.     Userid = ConnectForm!UserEdit.Text
  286.     Password = ConnectForm!PasswordEdit.Text
  287.     ServerDirect = ConnectForm!txtDirect.Text
  288.     Host_File_Name = txtRemoteFile
  289.     Local_File_Name = txtLocalFile
  290.     doitmode = OptDoItAll
  291.     cyclemode = Not OptLoginOnly
  292.     putmode = OptPut
  293.     If putmode Then
  294.       Src_name = txtLocalFile
  295.       Dest_name = txtRemoteFile
  296.     Else
  297.       Src_name = txtRemoteFile
  298.       Dest_name = txtLocalFile
  299.     End If
  300.     TransType = Asc("I")
  301.     If chkAscii.Value = 1 Then TransType = Asc("A")
  302.     If Not cyclemode Then txtCycle = 0
  303.     FTP_Form.Cycle_sec = Val(txtCycle)
  304.     Call PrivateStrings(1)
  305.     Unload ConnectForm
  306.   End If
  307. End Sub
  308. Sub Command2_Click ()
  309.   OkDialog = False
  310.   Unload ConnectForm
  311. End Sub
  312. Sub Form_Load ()
  313. '__ Connectform Form_Load
  314. '__   calls     Connectform PrivateStrings
  315. '__   calls     GLOBAL switch_to
  316.  ConnectForm!PasswordEdit.Text = Password
  317.  Call PrivateStrings(0)
  318.  switch_to NodeEdit
  319. End Sub
  320. Sub NodeEdit_GotFocus ()
  321. '__ Connectform NodeEdit_GotFocus
  322. '__   calls     GLOBAL switch_to
  323.  switch_to NodeEdit
  324. End Sub
  325. Sub NodeEdit_KeyPress (keyascii As Integer)
  326. '__ Connectform NodeEdit_KeyPress
  327. '__   parameter keyascii As Integer
  328. '__   calls     GLOBAL switch_to
  329.  If keyascii = 13 Then keyascii = 0: switch_to UserEdit
  330. End Sub
  331. Sub OptDoitAll_Click ()
  332. '__ Connectform OptDoitAll_Click
  333. '__   calls     GLOBAL switch_to
  334.  lblCycle.Visible = True
  335.  txtCycle.Visible = True
  336.  frame2.Visible = True
  337.  switch_to txtCycle
  338. End Sub
  339. Sub OptFTPOnly_Click ()
  340. '__ Connectform OptFTPOnly_Click
  341. '__   calls     GLOBAL switch_to
  342.  lblCycle.Visible = True
  343.  txtCycle.Visible = True
  344.  frame2.Visible = True
  345.  switch_to txtCycle
  346. End Sub
  347. Sub OptLoginOnly_Click ()
  348.  lblCycle.Visible = False
  349.  txtCycle.Visible = False
  350.  frame2.Visible = False
  351. End Sub
  352. Sub PasswordEdit_GotFocus ()
  353. '__ Connectform PasswordEdit_GotFocus
  354. '__   calls     GLOBAL switch_to
  355.  switch_to PasswordEdit
  356. End Sub
  357. Sub PasswordEdit_KeyPress (keyascii As Integer)
  358. '__ Connectform PasswordEdit_KeyPress
  359. '__   parameter keyascii As Integer
  360. '__   calls     GLOBAL switch_to
  361.  If keyascii = 13 Then keyascii = 0: switch_to txtDirect
  362. End Sub
  363. Sub PrivateStrings (mode)
  364. '__ Connectform PrivateStrings
  365. '__   parameter mode
  366. '__   called by Connectform command1_click
  367. '__   called by Connectform Form_Load
  368. '__   calls     GLOBAL GetPrivateProfileString
  369. '__   calls     GLOBAL writePrivateProfileString
  370. Dim prostring As String * 100
  371. INIFILE = app.Path & "\QUICKFTP.INI"
  372. INFILE$ = INIFILE
  373. buffer$ = String$(100, 0)
  374. If mode = 0 Then 'read
  375.       
  376.       id% = GetPrivateProfileString("Variables", "RemoteHost", "", buffer$, 100, INFILE$)
  377.       NodeEdit = Left$(buffer$, id%)
  378.       id% = GetPrivateProfileString("Variables", "LoginID", "", buffer$, 100, INFILE$)
  379.       UserEdit = Left$(buffer$, id%)
  380.       id% = GetPrivateProfileString("Variables", "RemoteDirectory", "", buffer$, 100, INFILE$)
  381.       txtDirect = Left$(buffer$, id%)
  382.       
  383.       id% = GetPrivateProfileString("Variables", "RemoteFile", "", buffer$, 100, INFILE$)
  384.       txtRemoteFile = Left$(buffer$, id%)
  385.       id% = GetPrivateProfileString("Variables", "LocalFile", "", buffer$, 100, INFILE$)
  386.       txtLocalFile = Left$(buffer$, id%)
  387.       id% = GetPrivateProfileString("Variables", "Delay", "40", buffer$, 100, INFILE$)
  388.       txtCycle = Val(Left$(buffer$, id%))
  389.       
  390.       id% = GetPrivateProfileString("Variables", "CycleMode", "LOGIN ONLY", buffer$, 100, INFILE$)
  391.       OptFTPOnly = (Asc(buffer$) = Asc("F"))
  392.       OptLoginOnly = (Asc(buffer$) = Asc("L"))
  393.       OptDoItAll = (Asc(buffer$) = Asc("C"))
  394.       id% = GetPrivateProfileString("Variables", "TransferMode", "A", buffer$, 100, INFILE$)
  395.       chkAscii = -(Left$(buffer$, 1) = "A")
  396.       
  397.       id% = GetPrivateProfileString("Variables", "TransferDirection", "GET", buffer$, 100, INFILE$)
  398.       OptPut = (Left$(buffer$, 1) = "P")
  399. Else 'write
  400.       prostring = NodeEdit
  401.       id% = writePrivateProfileString("Variables", "RemoteHost", prostring, INFILE$)
  402.       
  403.       
  404.       prostring = UserEdit
  405.       id% = writePrivateProfileString("Variables", "LoginID", prostring, INFILE$)
  406.       
  407.       prostring = txtDirect
  408.       id% = writePrivateProfileString("Variables", "RemoteDirectory", prostring, INFILE$)
  409.       
  410.       prostring = txtRemoteFile
  411.       id% = writePrivateProfileString("Variables", "RemoteFile", prostring, INFILE$)
  412.       
  413.       prostring = txtLocalFile
  414.       id% = writePrivateProfileString("Variables", "LocalFile", prostring, INFILE$)
  415.       prostring = Format$(Val(txtCycle))
  416.       id% = writePrivateProfileString("Variables", "Delay", prostring, INFILE$)
  417.       
  418.       If OptFTPOnly Then
  419.         prostring = "FTP ONLY"
  420.       ElseIf OptLoginOnly Then
  421.         prostring = "LOGIN ONLY"
  422.       ElseIf OptDoItAll Then
  423.         prostring = "CONNECT-FTP-DISCONNECT"
  424.       End If
  425.       id% = writePrivateProfileString("Variables", "CycleMode", prostring, INFILE$)
  426.       
  427.       prostring = Chr(TransType)
  428.       id% = writePrivateProfileString("Variables", "TransferMode", prostring, INFILE$)
  429.       
  430.       prostring = "GET"
  431.       If putmode Then prostring = "PUT"
  432.       id% = writePrivateProfileString("Variables", "TransferDirection", prostring, INFILE$)
  433. End If
  434. End Sub
  435. Sub txtCycle_KeyPress (keyascii As Integer)
  436. '__ Connectform txtCycle_KeyPress
  437. '__   parameter keyascii As Integer
  438.  If keyascii = 13 Then keyascii = 0: command1.SetFocus
  439. End Sub
  440. Sub txtDirect_GotFocus ()
  441. '__ Connectform txtDirect_GotFocus
  442. '__   calls     GLOBAL switch_to
  443.  switch_to txtDirect
  444. End Sub
  445. Sub txtDirect_KeyPress (keyascii As Integer)
  446. '__ Connectform txtDirect_KeyPress
  447. '__   parameter keyascii As Integer
  448. '__   calls     GLOBAL switch_to
  449.  If keyascii = 13 Then keyascii = 0: switch_to txtRemoteFile
  450. End Sub
  451. Sub txtLocalFile_GotFocus ()
  452. '__ Connectform txtLocalFile_GotFocus
  453. '__   calls     GLOBAL switch_to
  454.  switch_to txtLocalFile
  455. End Sub
  456. Sub txtLocalFile_KeyPress (keyascii As Integer)
  457. '__ Connectform txtLocalFile_KeyPress
  458. '__   parameter keyascii As Integer
  459. '__   calls     GLOBAL switch_to
  460.  If keyascii = 13 Then keyascii = 0: switch_to txtCycle
  461. End Sub
  462. Sub txtRemoteFile_GotFocus ()
  463. '__ Connectform txtRemoteFile_GotFocus
  464. '__   calls     GLOBAL switch_to
  465.  switch_to txtRemoteFile
  466. End Sub
  467. Sub txtRemoteFile_KeyPress (keyascii As Integer)
  468. '__ Connectform txtRemoteFile_KeyPress
  469. '__   parameter keyascii As Integer
  470. '__   calls     GLOBAL switch_to
  471.  If keyascii = 13 Then
  472.    keyascii = 0
  473.    switch_to txtLocalFile
  474.  End If
  475. End Sub
  476. Sub UserEdit_gotfocus ()
  477. '__ Connectform UserEdit_gotfocus
  478. '__   calls     GLOBAL switch_to
  479.  switch_to UserEdit
  480. End Sub
  481. Sub UserEdit_KeyPress (keyascii As Integer)
  482. '__ Connectform UserEdit_KeyPress
  483. '__   parameter keyascii As Integer
  484. '__   calls     GLOBAL switch_to
  485.  If keyascii = 13 Then keyascii = 0: switch_to PasswordEdit
  486. End Sub
  487.