Problem with c structs and byte arrays...maybe?

BlitzMax Forums/BlitzMax Programming/Problem with c structs and byte arrays...maybe?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hi,

I ended up doing it with a couple of methods, but it would be nice if someone had a simpler way.

Here's what the methods look like:
	Method toBank:TBank(buf:TBank)
		If buf = Null
			buf = CreateBank(33*4 + 40)
		Else
			ResizeBank(buf,33*4 + 40)
		EndIf
		For Local i:Int = 0 To 39
			PokeByte(buf,i,lcName[i])
		Next
		PokeInt(buf,40,lcOptions)
		PokeInt(buf,44,lcStatus)
		PokeInt(buf,48,lcLocks)
		PokeInt(buf,52,lcMsgBase)
		PokeInt(buf,56,lcDevice)
etc...
	Method fromBank(buf:TBank)
		If buf <> Null
			For Local i:Int = 0 To 39
				lcName[i] = PeekByte(buf,i)
			Next
			lcOptions = PeekInt(buf,40)
			lcStatus = PeekInt(buf,44)
			lcLocks = PeekInt(buf,48)
			lcMsgBase = PeekInt(buf,52)
			lcDevice = PeekInt(buf,56)
etc...
And then I use BankBuf() to pass the byte ptr to the c stuff, and convert back afterwards. Like this:
		Local tempbank:TBank = CreateBank()
		context.toBank(tempbank)
		WTInfo(WTI_DEFSYSCTX,0,BankBuf(tempbank))
		context.fromBank(tempbank)