×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




Dave, looks like CWBX.StringConverter.FromBytes(bytedata) did the trick.
There are still some formatting issues, such as TABs and other
characters are displayed as squares.

Also in the below code I had to change the code to read 1 byte at a
time. Otherwise I was getting just parts of the spooled file.

I tried to speed the processing up by reading one byte from file,
Marshal.Copy the pointer to a byte, then copy that byte to a byte array,
increase the byte array by 1, read one byte from file... etc... Then
when the entire file was read I used
StringConverter.FromBytes(destinationByteArray). The size of the byte
array was over 2000 but only 5 characters were displayed.



-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Dave
Sent: Thursday, June 25, 2009 1:16 PM
To: Midrange Systems Technical Discussion
Subject: re: API: cwbOBJ_ReadSplF

Not sure if it applies to spool files, but I know when using data queues

you need to use IcwbxStringConverter to and from bytes...

Dave
====
www.openDave.com

----------------------------------------

From: "ibm" <ibm@xxxxxxxxxx>
Sent: Thursday, June 25, 2009 10:34 AM
To: MIDRANGE-L@xxxxxxxxxxxx
Subject: API: cwbOBJ_ReadSplF

I'm trying to read the contents of a spooled file, but all I am getting
is garbage. Anyone have any insight into this?

Thanks

_

Public Shared Function cwbOBJ_ReadSplF(ByVal objectHandle As IntPtr,
_

ByVal bBuffer As IntPtr, _

ByVal bytesToRead As Integer,
_

ByRef bytesRead As Integer, _

ByVal errorHandle As IntPtr)
As Integer

End Function

Public Sub TryObjList()

Dim listSize As Integer = 0

Dim objHandle As IntPtr = IntPtr.Zero

Dim bBuffer As IntPtr = IntPtr.Zero

Dim bbBuffer(1000) As Byte

Dim bytesRead As Integer = 0

Dim CWBOBJ_RC_SPLFENDOFFILE As Integer = (6000 + 8)

m_LastError = cwbOBJ_CreateListHandle(m_SystemName,
enumObjListType.CWBOBJ_LIST_SPLF, m_Handle_ObjList, m_Handle_Error)

m_LastError = cwbOBJ_OpenList(m_Handle_ObjList,
enumObjListOpenType.CWBOBJ_LIST_OPEN_SYNCH, m_Handle_Error)

m_LastError = cwbOBJ_GetListSize(m_Handle_ObjList, listSize,
enumObjListStatus.CWBOBJ_LISTSTS_COMPLETED, m_Handle_Error)

For n As Integer = 0 To listSize - 1

Debug.WriteLine("-------------splf " & n.ToString & "
------------------")

m_LastError = cwbOBJ_GetObjHandle(m_Handle_ObjList, n,
objHandle, m_Handle_Error)

m_LastError = cwbOBJ_OpenSplF(objHandle, m_Handle_Error)

m_LastError = cwbOBJ_SeekSplF(objHandle,
enumSeekOrigin.CWBOBJ_SEEK_BEGINNING, 0, m_Handle_Error)

Do Until m_LastError = CWBOBJ_RC_SPLFENDOFFILE

bBuffer = Marshal.AllocHGlobal(1000)

m_LastError = cwbOBJ_ReadSplF(objHandle, bBuffer, 1000,
bytesRead, m_Handle_Error)

Marshal.Copy(bBuffer, bbBuffer, 0, 1000)

'Debug.WriteLine(System.Text.Encoding.ASCII.GetString(bbBuffer))

Debug.WriteLine(Marshal.PtrToStringUni(bBuffer))

Array.Clear(bbBuffer, 0, 1000)

Try

Marshal.FreeHGlobal(bBuffer)

Catch ex As Exception

End Try

Loop

m_LastError = cwbOBJ_CloseSplF(objHandle, m_Handle_Error)

m_LastError = cwbOBJ_DeleteObjHandle(objHandle,
m_Handle_Error)

objHandle = New IntPtr

Next

m_LastError = cwbOBJ_CloseList(m_Handle_ObjList, m_Handle_Error)

m_LastError = cwbOBJ_DeleteListHandle(m_Handle_ObjList,
m_Handle_Error)

End Sub


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.