Difference between revisions of "API Expand.VarName"

From Flowcode Help
Jump to navigationJump to search
(XML import)
 
(13 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<sidebar>API contents</sidebar>
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Expands a string to the name of a global variable used in the generated code
+
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''VarName'''
 +
|-
 +
| colspan="2" | Expands a string to the name of a global variable used in the generated code&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
 +
| width="90%" | Source
 +
|-
 +
| colspan="2" | The variable name to expand&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-h32-icon.png]] - HANDLE
 +
| width="90%" | Owner
 +
|-
 +
| colspan="2" | A component that owns the variable&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
 +
| width="90%" | SizeName
 +
|-
 +
| colspan="2" | Set true to return the expanded size define&nbsp;
 +
|-
 +
| 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&nbsp;
 +
|-
 +
| 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''
 +
|}
  
<div style="width:25%; float:right" class="toc">
 
===Class hierarchy===[[API |API ]]
 
:[[API Expand|Expand]]
 
::VarName
 
</div>
 
__TOC__
 
  
==Parameters==
+
==Detailed description==
''[[Variable types|STRING]] Source''
+
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.
:The variable name to expand
 
  
''[[Variable types|HANDLE]] Owner''
 
:A component that owns the variable
 
:''The default value for this parameter is: '''''this'''
 
  
''[[Variable types|BOOL]] SizeName''
+
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.
:Set true to return the expanded size define
 
  
==Return value==
 
[[Variable types|STRING]]
 
  
No additional information
+
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.
 +
 
 +
{| class="wikitable"
 +
|-
 +
! SizeName
 +
! FullLine
 +
! Result
 +
|-
 +
| false
 +
| false
 +
| <tt>FCV_TESTVAR</tt>
 +
|-
 +
| true
 +
| false
 +
| <tt>FCVsz_TESTVAR</tt>
 +
|-
 +
| false
 +
| true
 +
| <tt>MX_UINT8 FCV_TESTVAR[FCVsz_TESTVAR]</tt>
 +
|-
 +
| true
 +
| true
 +
| <tt>#define FCVsz_TESTVAR 16</tt>
 +
|}
  
==Detailed description==
 
''No additional information''
 
  
 
==Examples==
 
==Examples==
 
===Calling in a calculation===
 
===Calling in a calculation===
 
* 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)</pre>
+
* Add to a calculation icon: <pre class="brush:[cpp]">result = ::Expand.VarName("source", owner, false, true)</pre>

Latest revision as of 11:55, 16 January 2023

Fc9-comp-macro.png VarName
Expands a string to the name of a global variable used in the generated code 
Fc9-string-icon.png - STRING Source
The variable name to expand 
Fc9-h32-icon.png - HANDLE Owner
A component that owns the variable 
Fc9-bool-icon.png - BOOL SizeName
Set true to return the expanded size define 
Fc9-bool-icon.png - BOOL FullLine
Set true to expand to a full declaration, else just the name 
Fc9-string-icon.png - 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)