Difference between revisions of "Event Compile.GetVarSize"

From Flowcode Help
Jump to navigationJump to search
(XML import)
 
Line 25: Line 25:
  
 
==Examples==
 
==Examples==
''<span style="color:red;">No additional examples</span>''
+
 
 +
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]]
 +
 
 +
 
 +
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.
 +
 
 +
 
 +
[[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'''
 +
 
 +
 
 +
 
 +
Here is the file as a demonstration.
 +
 
 +
{{Fcfile|GetVarSize.fcfx|Get Var Size Event Example}}

Latest revision as of 16:36, 23 January 2014

<sidebar>Event Contents</sidebar> Sent to a component to amend the size of the expected array

This event is part of the Compile class

Parameters

STRING VarName

The original Flowcode variable

ULONG Elements

The number of elements in the array
This parameter is returned back to Flowcode


Return value

ULONG The return of this event is currently unused


Detailed description

No additional information


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.


GetVarSizeEvent.jpg


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.


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


Here is the file as a demonstration.

FC6 Icon.png Get Var Size Event Example