WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Create Single Byte Arrays and Structures

 Keywords:  Create Single Byte Array Structures ByteStruct MyStruct BinaryAlloc BinaryPoke2 BinaryPoke4 BinaryOleType ObjectType

Question:

Is there a way to do this in WinBatch? Not sure how things like Single Byte Arrays and Structures would convert.
Private Type MyStruct
    i As Integer
     l As Long
End Type

Private Type ByteStruct
   b(6) As Byte ' b MUST be the same length as i and l from MyStruct
End Type

Private Sub Command1_Click()
	On Error GoTo OnError ' use intrinsic error handling
	Dim Count As Long
	Dim x As MyStruct, y As ByteStruct
	x.i = 127 ' a binary integer
	x.l = 12612324 ' a binary long
	LSet y = x ' move the data into a structure that is a single Byte array
	Count = Tcp1.Send(y.b) ' send the Byte array that has the binary data in it
	Exit Sub
	OnError: ' Any error jumps here
	Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.Description
End Sub 

Answer:

Assuming standard VB 6 style array representation.
hStruct = BinaryAlloc(6)
;x.i = 127 ' a binary integer
BinaryPoke2(hStruct, 0, 127)
;x.l = 12612324 ' a binary long
BinaryPoke4(hStruct, 2, 12612324)
BinaryOleType(hStruct, 103, 0, 0, 0)
; Count = Tcp1.Send(hStruct) or
; aByte = ObjectType("ARRAY", hStruct)
; Count = Tcp1.Send(aByte) or
; Count = Tcp1.Send(ARRAY:hStruct)


Article ID:   W17920
Filename:   Create Single Byte Arrays and Structures .txt
File Created: 2012:10:29:14:29:58
Last Updated: 2012:10:29:14:29:58