home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 April / ChipCD_498.iso / software / ftp / quickftp / quickft1.frm < prev    next >
Text File  |  1996-01-30  |  17KB  |  607 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. End
  236.  
  237. Function Check_info () As Integer
  238. '__
  239. '__ Connectform Check_info
  240. '__   called by Connectform command1_click
  241. '__   calls     GLOBAL getinput
  242. '__   calls     GLOBAL IsValidGet
  243. '__   calls     GLOBAL IsValidPut
  244. '__   calls     GLOBAL switch_to
  245. '__
  246.   'check if Hostname, Userid and password have been defined
  247.   '
  248.   Dim ok%
  249.   Check_info = False
  250.   ok% = True
  251.   If Len(Trim$(ConnectForm!NodeEdit.Text)) = 0 Then
  252.     ConnectForm!NodeEdit = getinput("Host Name", "")
  253.   End If
  254.   If Len(Trim$(ConnectForm!UserEdit.Text)) = 0 Then
  255.     ConnectForm!UserEdit = getinput("Login Name", "anonymous")
  256.   End If
  257.   If Len(Trim$(ConnectForm!PasswordEdit.Text)) = 0 Then
  258.     ConnectForm!PasswordEdit = getinput("Password", "HIDDENVALUE")
  259.   End If
  260.   If Len(Trim$(ConnectForm!NodeEdit.Text)) = 0 Then
  261.     ok% = False
  262.     switch_to NodeEdit
  263.   ElseIf Len(Trim$(ConnectForm!UserEdit.Text)) = 0 Then
  264.     ok% = False
  265.     switch_to UserEdit
  266.   ElseIf Len(Trim$(ConnectForm!PasswordEdit.Text)) = 0 Then
  267.     ok% = False
  268.     switch_to PasswordEdit
  269.   End If
  270.   If Not ok% Then
  271.     MsgBox "Need Host Name, Login Name and Password to proceed.", 64
  272.     Exit Function
  273.   End If
  274.   switch_to txtLocalFile
  275.   If OptPut And Not OptLoginOnly Then
  276.     If Not IsValidPut(txtLocalFile) Then Exit Function
  277.   End If
  278.   If optGet And Not OptLoginOnly Then
  279.     If Not IsValidGet(txtLocalFile) Then Exit Function
  280.   End If
  281.   Check_info = True
  282.   '
  283. End Function
  284.  
  285.  
  286. Sub command1_click ()
  287. '__
  288. '__ Connectform command1_click
  289. '__   calls     Connectform Check_info
  290. '__   calls     Connectform PrivateStrings
  291. '__
  292.   '
  293.   If Check_info() Then
  294.     OkDialog = True
  295.     Hostname = ConnectForm!NodeEdit.Text
  296.     Userid = ConnectForm!UserEdit.Text
  297.     Password = ConnectForm!PasswordEdit.Text
  298.     ServerDirect = ConnectForm!txtDirect.Text
  299.     Host_File_Name = txtRemoteFile
  300.     Local_File_Name = txtLocalFile
  301.     doitmode = OptDoItAll
  302.     cyclemode = Not OptLoginOnly
  303.     putmode = OptPut
  304.     If putmode Then
  305.       Src_name = txtLocalFile
  306.       Dest_name = txtRemoteFile
  307.     Else
  308.       Src_name = txtRemoteFile
  309.       Dest_name = txtLocalFile
  310.     End If
  311.     TransType = Asc("I")
  312.     If chkAscii.Value = 1 Then TransType = Asc("A")
  313.     If Not cyclemode Then txtCycle = 0
  314.     FTP_Form.Cycle_sec = Val(txtCycle)
  315.     Call PrivateStrings(1)
  316.  
  317.     Unload ConnectForm
  318.   End If
  319.   '
  320. End Sub
  321.  
  322.  
  323. Sub Command2_Click ()
  324.   '
  325.   OkDialog = False
  326.   '
  327.   Unload ConnectForm
  328.   '
  329. End Sub
  330.  
  331.  
  332. Sub Form_Load ()
  333. '__
  334. '__ Connectform Form_Load
  335. '__   calls     Connectform PrivateStrings
  336. '__   calls     GLOBAL switch_to
  337. '__
  338.   
  339.  ConnectForm!PasswordEdit.Text = Password
  340.  
  341.  Call PrivateStrings(0)
  342.  switch_to NodeEdit
  343. End Sub
  344.  
  345.  
  346. Sub NodeEdit_GotFocus ()
  347. '__
  348. '__ Connectform NodeEdit_GotFocus
  349. '__   calls     GLOBAL switch_to
  350. '__
  351.  switch_to NodeEdit
  352. End Sub
  353.  
  354.  
  355. Sub NodeEdit_KeyPress (keyascii As Integer)
  356. '__
  357. '__ Connectform NodeEdit_KeyPress
  358. '__
  359. '__   parameter keyascii As Integer
  360. '__   calls     GLOBAL switch_to
  361. '__
  362.  If keyascii = 13 Then keyascii = 0: switch_to UserEdit
  363. End Sub
  364.  
  365.  
  366. Sub OptDoitAll_Click ()
  367. '__
  368. '__ Connectform OptDoitAll_Click
  369. '__   calls     GLOBAL switch_to
  370. '__
  371.  lblCycle.Visible = True
  372.  txtCycle.Visible = True
  373.  frame2.Visible = True
  374.  switch_to txtCycle
  375.  
  376. End Sub
  377.  
  378.  
  379. Sub OptFTPOnly_Click ()
  380. '__
  381. '__ Connectform OptFTPOnly_Click
  382. '__   calls     GLOBAL switch_to
  383. '__
  384.  lblCycle.Visible = True
  385.  txtCycle.Visible = True
  386.  frame2.Visible = True
  387.  switch_to txtCycle
  388. End Sub
  389.  
  390.  
  391. Sub OptLoginOnly_Click ()
  392.  lblCycle.Visible = False
  393.  txtCycle.Visible = False
  394.  frame2.Visible = False
  395. End Sub
  396.  
  397.  
  398. Sub PasswordEdit_GotFocus ()
  399. '__
  400. '__ Connectform PasswordEdit_GotFocus
  401. '__   calls     GLOBAL switch_to
  402. '__
  403.  switch_to PasswordEdit
  404.  
  405. End Sub
  406.  
  407.  
  408. Sub PasswordEdit_KeyPress (keyascii As Integer)
  409. '__
  410. '__ Connectform PasswordEdit_KeyPress
  411. '__
  412. '__   parameter keyascii As Integer
  413. '__   calls     GLOBAL switch_to
  414. '__
  415.  If keyascii = 13 Then keyascii = 0: switch_to txtDirect
  416.  
  417. End Sub
  418.  
  419.  
  420. Sub PrivateStrings (mode)
  421. '__
  422. '__ Connectform PrivateStrings
  423. '__
  424. '__   parameter mode
  425. '__   called by Connectform command1_click
  426. '__   called by Connectform Form_Load
  427. '__   calls     GLOBAL GetPrivateProfileString
  428. '__   calls     GLOBAL writePrivateProfileString
  429. '__
  430. Dim prostring As String * 100
  431.  
  432. INIFILE = app.Path & "\QUICKFTP.INI"
  433.  
  434. INFILE$ = INIFILE
  435. buffer$ = String$(100, 0)
  436. If mode = 0 Then 'read
  437.       
  438.       id% = GetPrivateProfileString("Variables", "RemoteHost", "", buffer$, 100, INFILE$)
  439.       NodeEdit = Left$(buffer$, id%)
  440.  
  441.  
  442.       id% = GetPrivateProfileString("Variables", "LoginID", "", buffer$, 100, INFILE$)
  443.       UserEdit = Left$(buffer$, id%)
  444.  
  445.       id% = GetPrivateProfileString("Variables", "RemoteDirectory", "", buffer$, 100, INFILE$)
  446.       txtDirect = Left$(buffer$, id%)
  447.       
  448.       id% = GetPrivateProfileString("Variables", "RemoteFile", "", buffer$, 100, INFILE$)
  449.       txtRemoteFile = Left$(buffer$, id%)
  450.  
  451.       id% = GetPrivateProfileString("Variables", "LocalFile", "", buffer$, 100, INFILE$)
  452.       txtLocalFile = Left$(buffer$, id%)
  453.  
  454.       id% = GetPrivateProfileString("Variables", "Delay", "40", buffer$, 100, INFILE$)
  455.       txtCycle = Val(Left$(buffer$, id%))
  456.       
  457.       id% = GetPrivateProfileString("Variables", "CycleMode", "LOGIN ONLY", buffer$, 100, INFILE$)
  458.       OptFTPOnly = (Asc(buffer$) = Asc("F"))
  459.       OptLoginOnly = (Asc(buffer$) = Asc("L"))
  460.       OptDoItAll = (Asc(buffer$) = Asc("C"))
  461.       id% = GetPrivateProfileString("Variables", "TransferMode", "A", buffer$, 100, INFILE$)
  462.       chkAscii = -(Left$(buffer$, 1) = "A")
  463.       
  464.       id% = GetPrivateProfileString("Variables", "TransferDirection", "GET", buffer$, 100, INFILE$)
  465.       OptPut = (Left$(buffer$, 1) = "P")
  466.  
  467. Else 'write
  468.  
  469.       prostring = NodeEdit
  470.       id% = writePrivateProfileString("Variables", "RemoteHost", prostring, INFILE$)
  471.       
  472.       
  473.       prostring = UserEdit
  474.       id% = writePrivateProfileString("Variables", "LoginID", prostring, INFILE$)
  475.       
  476.       prostring = txtDirect
  477.       id% = writePrivateProfileString("Variables", "RemoteDirectory", prostring, INFILE$)
  478.       
  479.       prostring = txtRemoteFile
  480.       id% = writePrivateProfileString("Variables", "RemoteFile", prostring, INFILE$)
  481.       
  482.       prostring = txtLocalFile
  483.       id% = writePrivateProfileString("Variables", "LocalFile", prostring, INFILE$)
  484.  
  485.       prostring = Format$(Val(txtCycle))
  486.       id% = writePrivateProfileString("Variables", "Delay", prostring, INFILE$)
  487.       
  488.       If OptFTPOnly Then
  489.         prostring = "FTP ONLY"
  490.       ElseIf OptLoginOnly Then
  491.         prostring = "LOGIN ONLY"
  492.       ElseIf OptDoItAll Then
  493.         prostring = "CONNECT-FTP-DISCONNECT"
  494.       End If
  495.       id% = writePrivateProfileString("Variables", "CycleMode", prostring, INFILE$)
  496.       
  497.       prostring = Chr(TransType)
  498.       id% = writePrivateProfileString("Variables", "TransferMode", prostring, INFILE$)
  499.       
  500.       prostring = "GET"
  501.       If putmode Then prostring = "PUT"
  502.       id% = writePrivateProfileString("Variables", "TransferDirection", prostring, INFILE$)
  503.  
  504. End If
  505. End Sub
  506.  
  507.  
  508. Sub txtCycle_KeyPress (keyascii As Integer)
  509. '__
  510. '__ Connectform txtCycle_KeyPress
  511. '__
  512. '__   parameter keyascii As Integer
  513. '__
  514.  If keyascii = 13 Then keyascii = 0: command1.SetFocus
  515.  
  516. End Sub
  517.  
  518.  
  519. Sub txtDirect_GotFocus ()
  520. '__
  521. '__ Connectform txtDirect_GotFocus
  522. '__   calls     GLOBAL switch_to
  523. '__
  524.  switch_to txtDirect
  525. End Sub
  526.  
  527.  
  528. Sub txtDirect_KeyPress (keyascii As Integer)
  529. '__
  530. '__ Connectform txtDirect_KeyPress
  531. '__
  532. '__   parameter keyascii As Integer
  533. '__   calls     GLOBAL switch_to
  534. '__
  535.  If keyascii = 13 Then keyascii = 0: switch_to txtRemoteFile
  536.  
  537. End Sub
  538.  
  539.  
  540. Sub txtLocalFile_GotFocus ()
  541. '__
  542. '__ Connectform txtLocalFile_GotFocus
  543. '__   calls     GLOBAL switch_to
  544. '__
  545.  switch_to txtLocalFile
  546.  
  547. End Sub
  548.  
  549.  
  550. Sub txtLocalFile_KeyPress (keyascii As Integer)
  551. '__
  552. '__ Connectform txtLocalFile_KeyPress
  553. '__
  554. '__   parameter keyascii As Integer
  555. '__   calls     GLOBAL switch_to
  556. '__
  557.  If keyascii = 13 Then keyascii = 0: switch_to txtCycle
  558.  
  559. End Sub
  560.  
  561.  
  562. Sub txtRemoteFile_GotFocus ()
  563. '__
  564. '__ Connectform txtRemoteFile_GotFocus
  565. '__   calls     GLOBAL switch_to
  566. '__
  567.  switch_to txtRemoteFile
  568.  
  569. End Sub
  570.  
  571.  
  572. Sub txtRemoteFile_KeyPress (keyascii As Integer)
  573. '__
  574. '__ Connectform txtRemoteFile_KeyPress
  575. '__
  576. '__   parameter keyascii As Integer
  577. '__   calls     GLOBAL switch_to
  578. '__
  579.  If keyascii = 13 Then
  580.    keyascii = 0
  581.    switch_to txtLocalFile
  582.  End If
  583. End Sub
  584.  
  585.  
  586. Sub UserEdit_gotfocus ()
  587. '__
  588. '__ Connectform UserEdit_gotfocus
  589. '__   calls     GLOBAL switch_to
  590. '__
  591.  switch_to UserEdit
  592. End Sub
  593.  
  594.  
  595. Sub UserEdit_KeyPress (keyascii As Integer)
  596. '__
  597. '__ Connectform UserEdit_KeyPress
  598. '__
  599. '__   parameter keyascii As Integer
  600. '__   calls     GLOBAL switch_to
  601. '__
  602.  If keyascii = 13 Then keyascii = 0: switch_to PasswordEdit
  603.  
  604. End Sub
  605.  
  606.  
  607.