It is currently Mon Jun 18, 2018 12:45 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: C# Structure to PB
PostPosted: Sat Dec 09, 2017 9:02 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 382
How can I define this structure in PB.
The problem is data has a dynamic size (chunkSize) and I can't read p.
Code:
typedef struct {
  ID      chunkID;
  long    chunkSize;
  char    data[]; //how does this work?
  char    p;
} LabelChunk;


Code:
Structure lablStruc
  chunkID.s{4}
  chunkSize.l
  data ;[]  the size is the chunkSize
  p.a
EndStructure


Top
 Profile  
Reply with quote  
 Post subject: Re: C# Structure to PB
PostPosted: Sat Dec 09, 2017 9:33 pm 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 3860
Location: Germany
Hi,

Code:
Structure labelChunkStructure
  chunkID.a[4]
  chunkSize.l
  chunkData.a[0]
  p.a
EndStructure


*Buffer = AllocateMemory(100)
PokeS(*Buffer + 0, "TEST", 4, #PB_Ascii|#PB_String_NoZero)
PokeL(*Buffer + 4, 10)
For i = 0 To 9
  PokeA(*Buffer + 8 + i, i)
Next i
PokeA(*Buffer + 4 + 4 + 10, 'E')

*Ptr.labelChunkStructure = *Buffer
If PeekS(@*Ptr\chunkID[0], 4 , #PB_Ascii) = "TEST"
 
  For i = 0 To *Ptr\chunkSize - 1
    Debug *Ptr\chunkData[i]
  Next i
 
  ; no direct access to \p
  Debug Chr(PeekA(*Ptr + 8 + *Ptr\chunkSize))
 
EndIf


You have no direct access to \p
And you have to use .a for the ID, because .s reserves 8 Bytes (Unicode) and you can not tell PB tat it is Ascii.

Bernd


Top
 Profile  
Reply with quote  
 Post subject: Re: C# Structure to PB
PostPosted: Sat Dec 09, 2017 10:16 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 382
Thanks !


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye