HP3000-L Archives

October 2002, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Arthur Frank <[log in to unmask]>
Reply To:
Arthur Frank <[log in to unmask]>
Date:
Fri, 25 Oct 2002 14:52:42 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (241 lines)
Evan,

You're right -- it appears that without the "Do While" loops, multiple "inetFTP.Execute" commands pile up on each other.  On the second command, the program bombs with a "Still executing last request" error.  However, my program is getting stuck in your "Do While" loop, as written.  I just want to set my transfer type to "binary", so I issue the command:

inetFTP.Execute , "binary"

followed by one of your "Do While" loops.  Well, my program gets stuck in the "Do While" loop until it times out.  Any ideas?

TIA,

Art Frank
Manager of Information Systems
OHSU Foundation
[log in to unmask] 
(503) 220-8320

>>> Evan Vaala <[log in to unmask]> 10/25/02 09:09AM >>>
Just a couple of other tidbits:

the "inetFTP.Execute" sub spins off on a seperate thread.  Therefore if you
have multiple ftp commands to apply, such as 'CD' for change directory you
must place the following code after each inetFTP.Execute calls:

inetFTP.Execute , "CD MYDIR"

Do While inetFTP.stillExecuting
 DoEvents
Loop

inetFTP.Execute , "PUT MYFILE"

Do While inetFTP.stillExecuting
 DoEvents
Loop

inetFTP.Execute , "CLOSE"

It may appear that an infinite loop is probable from this code, but inetFTP
has a timeout property that can be set manually or via its properties
parameter in the vb display for the object


I must also admit I am not a guru on this subject in VB.  The very detailed
example that Matt provided may be compensating for the thread via the
StateChanged subroutine.  It is an example that I am archiving for further
references.

Also, to get the Inet object into your VB environment, you have to add
the "Microsoft Internet Transfer Control" component.

On your visual toolbox, click right mouse button.

Select "components" from popup menu.  - VB 5.0

Select the "Microsoft Internet Transfer Control" component.

The control will appear as an icon on you toolbox toolbar.

Drag it into your form and it is now available with your vb environment.  I
believe the default var name is Inet1.  Change it to inetFTP to make Matt's
example work.

Good luck!

Evan Vaala
Rockwell Automation



On Fri, 25 Oct 2002 08:22:59 -0700, Arthur Frank <[log in to unmask]> wrote:

>Matt,
>
>Thank you!  This looks great.  Is there a reference or module that I need
to include to use the inetFTP object?
>
>Art Frank
>Manager of Information Systems
>OHSU Foundation
>[log in to unmask] 
>(503) 220-8320
>
>>>> "Matt Hawrysko" <[log in to unmask]> 10/25/02 08:11AM >>>
>Arthur,
>        Here is a sample of code to put, but a few quick changes will
>fix that.
>--------------------------- ~Code Sample` ------------------------------
>Option Explicit
>Private m_GettingDir As Boolean
>Private flag As Boolean
>
>Private Sub AddMessage(ByVal msg As String)
>    txtResults.Text = txtResults.Text & vbCrLf & msg
>    txtResults.SelStart = Len(txtResults.Text)
>End Sub
>
>Private Sub cmdUpload_Click()
>    Dim host_name As String
>    Dim today As Date
>    today = Date
>    Dim myFile As String
>    Dim i As Integer
>
>    flag = True
>
>    myFile = "MYFILE.MPEF"
>    ' myFile = myFile & Format(today, "mmdd") & ".DATA"
>    ' txtRemoteFile = myFile
>
>    Enabled = False
>    MousePointer = vbHourglass
>    txtResults.Text = "Working"
>    txtResults.SelStart = Len(txtResults.Text)
>    DoEvents
>    ' You must set the URL before the user name and
>    ' password. Otherwise the control cannot verify
>    ' the user name and password and you get the error:
>    '
>    '       Unable to connect to remote host
>
>    host_name = "XXX.XXX.XXX.XXX"
>    ' txtHost.Text = host_name
>    ' If LCase$(Left$(host_name, 6)) <> "" Then host_name = host_name  '
>"ftp://" &
>    inetFTP.URL = host_name
>
>    txtUserName = "USERNAME.ACCT"
>    txtPassword = "USERPASS,ACCTPASS"
>
>    inetFTP.UserName = txtUserName.Text
>    inetFTP.Password = txtPassword.Text
>
>    ' Do not include the host name here. That will make
>    ' the control try to use its default user name and
>    ' password and you'll get the error again.
>    txtLocalFile = "x:\MYFILE.EXT"
>    ' txtLocalFile = txtLocalFile & myFile
>
>    txtRemoteFile = "MYFILE.MPEF"
>
>    inetFTP.Execute , "Put " & _
>       txtLocalFile & " " & txtRemoteFile
>    m_GettingDir = True
>End Sub
>
>
>Private Sub Command1_Click()
>   End
>End Sub
>
>Private Sub Form_Load()
>'Form1.Show
>   ' Dim today As Date
>   ' today = Date
>   ' Dim myFile As String
>   ' myFile = "FILENAME"
>   ' myFile = myFile & Format(today, "mmdd") & ".DATA"
>   ' txtRemoteFile = myFile
>DoEvents
>    Call cmdUpload_Click
>
>End Sub
>
>
>Private Sub inetFTP_StateChanged(ByVal State As Integer)
>
>    Select Case State
>        Case icError
>            AddMessage "Error: " & _
>                "    " & inetFTP.ResponseCode & vbCrLf & _
>                "    " & inetFTP.ResponseInfo
>        Case icNone
>            AddMessage "None"
>        Case icConnecting
>            AddMessage "Connecting"
>        Case icConnected
>            AddMessage "Connected"
>        Case icDisconnecting
>            AddMessage "Disconnecting"
>        Case icDisconnected
>            AddMessage "Disconnected"
>        Case icRequestSent
>            AddMessage "Request Sent"
>        Case icRequesting
>            AddMessage "Requesting"
>        Case icReceivingResponse
>            AddMessage "Receiving Response"
>        Case icRequestSent
>            AddMessage "Request Sent"
>        Case icResponseReceived
>            AddMessage "Response Received"
>        Case icResolvingHost
>            AddMessage "Resolving Host"
>        Case icHostResolved
>            AddMessage "Host Resolved"
>        Case icResponseCompleted
>            AddMessage inetFTP.ResponseInfo
>
>            If m_GettingDir Then
>                Dim txt As String
>                Dim chunk As Variant
>
>                m_GettingDir = False
>
>                ' Get the first chunk.
>                chunk = inetFTP.GetChunk(1024, icString)
>                DoEvents
>                Do While Len(chunk) > 0
>                    txt = txt & chunk
>                    chunk = inetFTP.GetChunk(1024, icString)
>                    DoEvents
>                Loop
>
>                AddMessage "----------"
>                AddMessage txt
>                If flag = True Then
>                    Call cmdUpload2_Click
>                Else
>                    Call Command1_Click

>                End If
>
>            End If
>
>       Case Else
>            AddMessage "State = " & Format$(State)
>    End Select
>
>    Enabled = True
>    MousePointer = vbDefaulta    MousePointer = vbHourglass

>
>End Sub
>

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2