33 lines
1.3 KiB
Markdown
33 lines
1.3 KiB
Markdown
## variableToList()
|
|
|
|
The `variableToList()` command converts an element into a list that contains only that element and stores the resulting list in a target variable. This command is useful to ensure that a single value is handled as a list in subsequent processing.
|
|
|
|
### Parameters
|
|
|
|
* element Type: `variable` Description: The variable that contains the element to be converted into a list. It can be any type of value that you want to include as the only item in the list.
|
|
* TargetVariable Type: `variable` Description: The variable in which the resulting list will be stored. It must be a variable that will receive the list with the included element.
|
|
|
|
### Command Flow
|
|
|
|
### Usage Example
|
|
|
|
Suppose the element in `myElement` is `"apple"` and you want to convert it into a list.
|
|
|
|
```javascript
|
|
// Variable definitions
|
|
myElement = "apple"
|
|
myList = []
|
|
|
|
// Call the command to convert the element into a list
|
|
variableToList(myElement, myList)
|
|
|
|
// Return the resulting list through addResult
|
|
addResult(myList)
|
|
```
|
|
|
|
Since `myElement` is `"apple"` , the `variableToList()` command will convert this element into a list with a single item: `["apple"]` . This list will be stored in the variable `myList` , and `myList` will be returned through `addResult(myList)` , resulting in the following output:
|
|
|
|
```javascript
|
|
["apple"]
|
|
```
|