Jump to content

Event Compile.GetVarSize: Difference between revisions

From Flowcode Help
JonnyW (talk | contribs)
XML import
m Text replacement - "class="wikitable" style="width:60%; background-color:#FFFFFF;"" to "class="mtx-class-macrotable wikitable""
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<sidebar>Event Contents</sidebar>
{| class="mtx-class-macrotable wikitable"
Sent to a component to amend the size of the expected array
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''GetVarSize'''
|-
| colspan="2" | Sent to a component to amend the size of the expected array&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| width="90%" | VarName
|-
| colspan="2" | The original Flowcode variable&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
| width="90%" | Elements
|-
| colspan="2" | The number of elements in the array&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - NONE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


This event is part of the [[Event class Compile|Compile]] class


__TOC__
Details on using Event Macros can be found here: [[Simulation Events|Event Macros]]


==Parameters==
[[Variable Types|STRING]] ''VarName''
:The original Flowcode variable


[[Variable Types|ULONG]] ''Elements''
==Detailed description==
:The number of elements in the array
 
:''This parameter is returned back to Flowcode''
 
 
==Examples==
 
On some microcontroller devices there are sometimes limitation on the size of a single data array or other reasons to adjust the size of a variable based on a set of parameters etc.
 
 
For example if we try and create an array of size bigger then 256 bytes then this will cause a compilation error.
 
 
 
'''#define FCVsz_DATAARRAY 500'''
 
 
 
'''GetVarSize.c(53): error: total number of array elements can not exceed 0x100'''
 
 
 
By enabling the GetVarSizeevent we can override the number of elements in the array.
 


[[File:GetVarSizeEvent.jpg]]


==Return value==
 
[[Variable Types|ULONG]]
Inside the event macro we check for the name of the variable with the size we want to override and overwrite the .Elements local variable to edit the array size.
The return of this event is currently unused
 
 
[[File:GetVarSizeMacro.jpg]]
 
 
After saving the project and refreshing the C code window the variable now looks like this.
 
 
 
'''#define FCVsz_DATAARRAY 255'''
 
 
 
And during compilation we now get this.
 
 
 
'''success'''




==Detailed description==
''<span style="color:red;">No additional information</span>''


Here is the file as a demonstration.


==Examples==
{{Fcfile|GetVarSize.fcfx|Get Var Size Event Example}}
''<span style="color:red;">No additional examples</span>''

Latest revision as of 14:13, 13 July 2026

GetVarSize
Sent to a component to amend the size of the expected array 
- STRING VarName
The original Flowcode variable 
- ULONG Elements
The number of elements in the array 
- NONE Return


Details on using Event Macros can be found here: Event Macros


Detailed description

Examples

On some microcontroller devices there are sometimes limitation on the size of a single data array or other reasons to adjust the size of a variable based on a set of parameters etc.


For example if we try and create an array of size bigger then 256 bytes then this will cause a compilation error.


#define FCVsz_DATAARRAY 500


GetVarSize.c(53): error: total number of array elements can not exceed 0x100


By enabling the GetVarSizeevent we can override the number of elements in the array.



Inside the event macro we check for the name of the variable with the size we want to override and overwrite the .Elements local variable to edit the array size.



After saving the project and refreshing the C code window the variable now looks like this.


#define FCVsz_DATAARRAY 255


And during compilation we now get this.


success


Here is the file as a demonstration.

Get Var Size Event Example