You are viewing an older version of the site. Click here to view
the latest version of this page. (This may be a dead link, if so, try the root page of the docs
here.)
== export ==
[[../objects/ms.lang.IndexOverflowException|ms.lang.IndexOverflowException]] |- ! scope="row" | Since | 3.3.0 |- ! scope="row" | Restricted |
Copy Code
The output would be:
Copy Code
The output would be:
Copy Code
The output would be:
Copy Code
The output would be:
Stores a value in the global storage register. An arbitrary value is stored with the given key, and can be retrieved using import. If the value is already stored, it is overwritten. See {{function|import}}. The reference to the value is stored, not a copy of the value, so in the case of arrays, manipulating the contents of the array will manipulate the stored value. An array may be used as a key. It is converted into a string with the array values separated by dots. export() is threadsafe.
=== Vital Info ===
{| style="width: 40%;" cellspacing="1" cellpadding="1" border="1" class="wikitable"
|-
! scope="col" width="20%" |
! scope="col" width="80%" |
|-
! scope="row" | Name
| export
|-
! scope="row" | Returns
| void
|-
! scope="row" | Usages
| key, value
|-
! scope="row" | Throws
| [[../objects/ms.lang.IllegalArgumentException|ms.lang.IllegalArgumentException]][[../objects/ms.lang.IndexOverflowException|ms.lang.IndexOverflowException]] |- ! scope="row" | Since | 3.3.0 |- ! scope="row" | Restricted |
Yes
|-
! scope="row" | Optimizations
| None
|}
=== Usages ===
export(key, value)=== Examples === ====Example 1==== Basic usage Given the following code:
@var = 2;
export('custom.name', @var);
@var2 = import('custom.name');
msg(@var2);

1 @var = 2;
2 {{function|export}}('custom.name', @var);
3 @var2 = {{function|import}}('custom.name');
4 {{function|msg}}(@var2);
2====Example 2==== Storage of references Given the following code:
@array = array(1, 2, 3);
export('array', @array);
@array[0] = 4;
@array2 = import('array');
msg(@array2);

1 @array = {{function|array}}(1, 2, 3);
2 {{function|export}}('array', @array);
3 @array[0] = 4;
4 @array2 = {{function|import}}('array');
5 {{function|msg}}(@array2);
{4, 2, 3}====Example 3==== Array key usage Given the following code:
@key = array('custom', 'name');
export(@key, 'value');
@value = import(@key);
msg(@value);

1 @key = {{function|array}}('custom', 'name');
2 {{function|export}}(@key, 'value');
3 @value = {{function|import}}(@key);
4 {{function|msg}}(@value);
value====Example 4==== Default value usage Given the following code:
export('custom.name', null);
@value = import('custom.name', 'default value');
msg(@value);

1 {{function|export}}('custom.name', {{keyword|null}});
2 @value = {{function|import}}('custom.name', 'default value');
3 {{function|msg}}(@value);
default value===See Also===
[[API/functions/import.html|import]]
Find a bug in this page? Edit this page yourself, then submit a pull request. (Note this page is automatically generated from the documentation in the source code.)