Android Question Clearing (and populating) a large structure

Arf

Well-Known Member
Licensed User
Longtime User
I've got a custom Type, which I create an instance of, but need to firstly set all entries to zero, and then at a later point copy the contents of a Byte array into the this structure. The byte array is the same length as the structure.

In C++ usually I'd use a memset or memcpy, but wondering what the correct, efficient was in VB is.


B4X:
Type PktResults(VC As Short,FEV075 As Short, FEV1 As Short,FEV3 As Short _
  ,FEV6 As Short, FVC As Short, PEF As Short,FEF25 As Short, FEF50 As Short _
  ,FEF75 As Short, FEF2575 As Short, FIV1 As Short, FIVC As Short, PIF As Short _
  ,FIF25 As Short, FIF50 As Short, FIF75 As Short, MET2575 As Short, FET As Short _
  ,EVC As Short, IVC As Short, IC As Short, VT As Short, Ti As Short, Te As Short _
  ,IRV As Short, ERV As Short, Vext As Short, FEV075_VC As Short, FEV075_FVC As Short _
  ,FEV1_VC As Short, FEV1_FVC As Short, FEV3_VC As Short, FEV3_FVC As Short _
  ,FEV075_FEV6 As Short, FEV1_FEV6 As Short, FEF50_VC As Short, FEF50_FVC As Short _
  ,MMEF_FVC As Short, FIV1_FIVC As Short, R50 As Short, Ti_Ttot As Short _
  ,VT_Ti As Short, FR As Short, MVV As Short, PEAKTIME As Short, LAST500V As Short _
  ,SPARE(28) As Byte)

Dim Results As PktResults

Oh and as an aside - if I want to use the same Type in multiple different activites, do I need to paste the type definition into each different file in the Process_Globals section? I can't see any means of doing a header file that is visible across all different modules.

The book on VB I ordered a few days ago should arrive today, so less question from then on with a bit of luck :)
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
In C++ usually I'd use a memset or memcpy, but wondering what the correct, efficient was in VB Basic4android is
Calling Dim Results As PktResults will create an empty structure with all number fields set to 0.

if I want to use the same Type in multiple different activites, do I need to paste the type definition into each different file in the Process_Globals section?
No. Only in one of the modules. It will be accessible from all modules.
 
Upvote 0

rzv25

Member
Licensed User
Longtime User
Calling Dim Results As PktResults will create an empty structure with all number fields set to 0.


No. Only in one of the modules. It will be accessible from all modules.

There was also a third question in the first post, that remained unanswered. How can I copy for example a byte array of the same size with the data type over the instance of that data type ?

Thank you,
Razvan
 
Upvote 0
Top