InoDrive / UserApp / write_var
InoDrive.UserApp.write_var(self, argv=None, value=None, **kwargs)
Write Variable(s) with new value out to User Application, polls User Application Variable List.
Arguments:
• self (Object): Reference to User Application Instance.
• argv (String or Integer or Tuple): Variable Name (String) or ID (Integer) or a Tuple for multiple Variable’s containing Name/ID paired with a new Value.
• value (Boolean, Integer, Floating Point): New Value for single Variable write.
• **kwargs (Dict): Keyword Argument.
Returns: Boolean – True or False on successfully writing new Variable value out to User Application.
import CkInoDriveAPI # Instantiate InoDrive Object and Connect by Name Drive = CkInoDriveAPI.InoDrive(target='Name', autoConnect=True) # Read Old Variable Value old_value = Drive.UserApp.read_var('foo') print(f"Variable Foo's Old Value is: {old_value}") # Write New Variable Value response = Drive.UserApp.write_var('foo', "New Value") # Get New Variable Value if Written Successfully if response: new_value = Drive.UserApp.read_var('foo') print(f"Variable Foo's New Value is: {new_value}") # Write Multiple Variables response = Drive.UserApp.write_var({'foo': "New Value", 'boo': "New Value"}) if response: var_list = Drive.UserApp.read_var(['foo', 'bar']) print(var_list)