Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Inet Control to ASCII??

Status
Not open for further replies.

byrne1

Programmer
Aug 7, 2001
415
US
Is there a way to set the Inet control to transfer in ASCII mode instead of Binary mode?
 
GetChunk Method (Internet Transfer Control)
Retrieves data from in the StateChanged event. Use this method after invoking the Execute method as a GET operation.
Syntax
object.GetChunk( size [ignore][[/ignore],datatype[ignore]][/ignore])
The Get property syntax has these parts:
Part Description
object An object expression that evaluates to an object in the Applies To list.
size Required. A long numeric expression that determines the size of the chunk to be retrieved.
datatype Optional. An integer that specifies the data type of the retrieved chunk, as shown in Settings below.
Settings
The settings for datatype are:
Constant Value Description
icString 0 Default. Retrieves data as string.
icByteArray 1 Retrieves data as a byte array.
Return Type
Variant
Remarks
Use the GetChunk method in the StateChanged event. When the State property is icResponseCompleted (12), then use the GetChunk method to retrieve the buffer's contents.
 
From the MSDN:

GetChunk Method (Internet Transfer Control)
Retrieves data from in the StateChanged event. Use this method after invoking the Execute method as a GET operation.
Syntax
object.GetChunk( size [,datatype])
The Get property syntax has these parts:
Part Description
object An object expression that evaluates to an object in the Applies To list.
size Required. A long numeric expression that determines the size of the chunk to be retrieved.
datatype Optional. An integer that specifies the data type of the retrieved chunk, as shown in Settings below.
Settings
The settings for datatype are:
Constant Value Description
icString 0 Default. Retrieves data as string.
icByteArray 1 Retrieves data as a byte array.
Return Type
Variant
Remarks
Use the GetChunk method in the StateChanged event. When the State property is icResponseCompleted (12), then use the GetChunk method to retrieve the buffer's contents.
 
When I use the GETCHUNK command I get the following error:

35764 - Still executing last request

I have not found a way to get around this. The code I am using is copied from the MSDN library and is as follows (I marked the line where I'm getting the error message with '***'):


Private Sub Inet1_StateChanged(ByVal State As Integer)
Select Case State
Case icResponseReceived
Dim vtData As Variant ' Data variable.
Dim strData As String: strData = ""
Dim bDone As Boolean: bDone = False
' Get first chunk.
*** vtData = Inet1.GetChunk(1024, icString)
DoEvents
Do While Not bDone
strData = strData & vtData
DoEvents
' Get next chunk.
vtData = Inet1.GetChunk(1024, icString)
If Len(vtData) = 0 Then
bDone = True
End If
Loop

Open "c:\tesstt.txt" For Output As #1
Print #1, strData
Close #1
End Select
end sub
 
Oh, and I almost forgot, but the command I am executing to GET the file is:

Inet1.Execute , "get '" & HostDSN & "' " & PCFile

It's a rather large file coming from the mainframe. Is there something else I should do instead of this?
 
OK, I just noticed that I need to use the GETCHUNK command in the icResponseCompleted state. But when I do this I end up w/ a file that has nothing in it. My binary file is there and populated w/ data but my text file (where I am trying to save my ASCII text) is empty.
 
[tt]Also from the MSDN[/tt]

In general, you will use the StateChanged event to determine when to retrieve data using the GetChunk method. To do this, use a Select Case statement and test for icResponseReceived (8) or icResponseCompleted (12).
Note, however, that the icResponseReceived state may occur when the control has completed an operation that hasn't resulted in any data in the buffer. For example, when connecting to an FTP site, the control will perform a "handshake" with the site that doesn't result in any data transfer, yet the icResponseReceived state will occur.
On the other hand, the icResponseCompleted state occurs after an operation has completed in its entirety. For example, if you are using the Execute method with the GET operation to retrieve a file, the icResponseCompleted event will occur only once — after the file has been totally retrieved.
In practice, using the icResponseReceived state allows you to parse the data until you have retrieved only the information you need (for example, when retrieving an HTML file, retrieving only the headers). Once you have the information, you can cancel the retrieval. On the other hand, if you are intent on retrieving the whole file, the icResponseCompleted state will notify you that the transfer is completed, allowing you to proceed.

[tt]Don't have much time today. Deadline to meet. Will get back to you afterwards.[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top