system.dataset.setValue
This function is used in Python Scripting.
Description​
Takes a dataset and returns a new dataset with one value altered.
Datasets are immutable, which means they cannot be directly modified once created. Instead, this scripting function returns a new dataset with some modification applied, which must be assigned to a variable to be used. See Altering a Dataset.
Client Permission Restrictions​
This scripting function has no Client Permission restrictions.
Syntax - columnName​
system.dataset.setValue(dataset, rowIndex, columnName, value)
Parameters​
Type | Parameter | Description |
---|---|---|
Dataset | dataset | The starting dataset. Will not be modified (datasets are immutable), but acts as the basis for the returned dataset. |
Integer | rowIndex | The index of the row to set the value at (starting at 0). |
String | columnName | The name of the column to set the value at. Case insensitive. |
Any | value | The new value for the specified row/column. |
Returns​
Dataset - A new dataset, with the new value set at the given location.
Scope​
Gateway, Vision Client, Perspective Session
Syntax - columnIndex​
system.dataset.setValue(dataset, rowIndex, columnIndex, value)
Parameters​
Type | Parameter | Description |
---|---|---|
Dataset | dataset | The starting dataset. Will not be modified (datasets are immutable), but acts as the basis for the returned dataset. |
Integer | rowIndex | The index of the row to set the value at (starting at 0). |
Integer | columnIndex | The index of the column to set the value at (starting at 0) |
Any | value | The new value for the specified row/column. |
Returns​
Dataset - A new dataset, with the new value set at the given location.
Scope​
Gateway, Vision Client, Perspective Session
Code Examples​
# This snippet demonstrates how to take an initial dataset, set a new value on a new dataset, and then write back to the source of the initial dataset.
# In this case we're using a Table component from the Vision module.
# Fetch a reference to an existing dataset.
table = event.source.parent.getComponent("Table")
# Make a new dataset with an updated value
newData = system.dataset.setValue(table.data, 3, "lname", 7)
# Repalce the table's dataset with our new dataset
table.data = newData
# This snippet could be used for a Vision Button's actionPerformed event to change the selected cell's value in a Table component to zero.
# Fetch table reference
table = event.source.parent.getComponent("Table")
# Fetch selected row and column
selRow = table.getSelectedRow()
selCol = table.getSelectedColumn()
# If row and column have been selected, update value in table to 0.
if selRow != -1 and selCol != -1:
newData = system.dataset.setValue(table.data, selRow, selCol, 0.0)
table.data = newData