Jump to content

API Expand.VarName: Difference between revisions

From Flowcode Help
JonnyW (talk | contribs)
XML import of updated Expand.VarName
m Text replacement - "width="90%" style="background-color:#D8C9D8; color:#4B008D;"" to "width="90%" class="mtx-class-macrohead""
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''VarName'''
|-
| colspan="2" | Expands a string to the name of a global variable used in the generated code 
|-
|-
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| width="90%" | Source
|-
| colspan="2" | The variable name to expand 
|-
| width="10%" align="center" | [[File:Fc9-h32-icon.png]] - HANDLE
| width="90%" | Owner
|-
| colspan="2" | A component that owns the variable 
|-
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
| width="90%" | SizeName
|-
| colspan="2" | Set true to return the expanded size define 
|-
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
| width="90%" | FullLine
|-
| colspan="2" | Set true to expand to a full declaration, else just the name 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


<sidebar>API contents</sidebar>
Expands a string to the name of a global variable used in the generated code


<div style="width:25%; float:right" class="toc">
==Detailed description==
====Class hierarchy====
This expands a global variable to the name it would be given in the generated code. The size define (the size of the final dimension of the array) may be returned instead if required.
[[API Expand|Expand]]
:[[API Expand|VarName]]
</div>
__TOC__


==Parameters==
[[Variable Types|STRING]] ''Source''
:The variable name to expand


[[Variable Types|HANDLE]] ''Owner''
Note this does not return the full expression unless ''FullLine'' is true. In this case, ''Source'' ''must'' be a valid variable name for the ''Owner'' component, as the system needs this in order to expand the variable type, array sizes and initialisers.
:A component that owns the variable
:''The default value for this parameter is: '''''this'''


[[Variable Types|BOOL]] ''SizeName''
:Set true to return the expanded size define


[[Variable Types|BOOL]] ''FullLine''
This is an example of what may be shown with differing ''SizeName'' and ''FullLine'' values. The sample variable is '''TestVar''', a byte array of 16 elements.
:Set true to expand to a full declaration, else just the name


 
{| class="wikitable"
==Return value==
|-
[[Variable Types|STRING]]
! SizeName
 
! FullLine
The global variable name as it would exist in the generated code
! Result
 
|-
 
| false
==Detailed description==
| false
This expands a global variable to the name it would be given in the generated code. The size define (the size of the final dimension of the array) may be returned instead if required.
| <tt>FCV_TESTVAR</tt>
 
|-
 
| true
Note this does not return the full expression unless ''FullLine'' is true. In this case, ''Source'' ''must'' be a valid variable name for the ''Owner'' component, as the system needs this in order to expand the variable type, array sizes and initialisers.
| false
| <tt>FCVsz_TESTVAR</tt>
|-
| false
| true
| <tt>MX_UINT8 FCV_TESTVAR[FCVsz_TESTVAR]</tt>
|-
| true
| true
| <tt>#define FCVsz_TESTVAR 16</tt>
|}




Line 42: Line 69:
* Declare a variable 'result' of type STRING
* Declare a variable 'result' of type STRING
* Add to a calculation icon: <pre class="brush:[cpp]">result = ::Expand.VarName("source", owner, false, true)</pre>
* Add to a calculation icon: <pre class="brush:[cpp]">result = ::Expand.VarName("source", owner, false, true)</pre>
''<span style="color:red;">No additional examples</span>''

Latest revision as of 14:11, 13 July 2026

VarName
Expands a string to the name of a global variable used in the generated code 
- STRING Source
The variable name to expand 
- HANDLE Owner
A component that owns the variable 
- BOOL SizeName
Set true to return the expanded size define 
- BOOL FullLine
Set true to expand to a full declaration, else just the name 
- STRING Return


Detailed description

This expands a global variable to the name it would be given in the generated code. The size define (the size of the final dimension of the array) may be returned instead if required.


Note this does not return the full expression unless FullLine is true. In this case, Source must be a valid variable name for the Owner component, as the system needs this in order to expand the variable type, array sizes and initialisers.


This is an example of what may be shown with differing SizeName and FullLine values. The sample variable is TestVar, a byte array of 16 elements.

SizeName FullLine Result
false false FCV_TESTVAR
true false FCVsz_TESTVAR
false true MX_UINT8 FCV_TESTVAR[FCVsz_TESTVAR]
true true #define FCVsz_TESTVAR 16


Examples

Calling in a calculation

  • Declare a variable 'result' of type STRING
  • Add to a calculation icon:
    result = ::Expand.VarName("source", owner, false, true)