name

Prev Next

Function Names

name

Description

This function checks returns the current variable name as a string. If applicable, the name also contains the members.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

1-2

Parameters

No.TypeDescription
1
code
variable
:string
Variable to check

2
input
string Option

Following options are supported:

text Variable name is provided as text
members named Variable name is provided as parameter set containing base variable as string and members as names (for structure members) and numbers (for array members)
members numbered Variable name is provided as parameter set containing base variable as string and members are always numbered.

Default value: text

Return value

TypeDescription
string Variable name as text

Uses same syntax as B4P code

parameter set Variable name as parameter set

Parameter set contains variable name in 1st element followed by member names and/or numbers.

boolean false if variable not found

In this case, false is returned.

Examples

  a[] =  Ah;
  b[2] = two;
  c[alex] = Alexander;
  c[tim] = Timothy;

  d[] = ^c[alex]; // Reference

  echo( name( a[]  ) );
  echo( name( c[tim]  ) );
  echo( name( c[tim], members named  ) );
  echo( name( b[2],   members named  ) );   // Array members will always be numbered
  echo( name( c[tim], members numbered) );  // All members are numbered

  echo( name( d[] ) ); // References reveal their destination variables

Output

a[]
c[tim]
{'c','tim'}
{'b',2}
{'c',1}
c[alex]
Try it yourself: Open LIB_Function_name.b4p in B4P_Examples.zip. Decompress before use.