a!save() Function

In interface saveInto parameters, updates the target with the given value. Use a!save for each item that you want to modify or alter in a saveInto parameter. This function has no effect when called outside of a component’s saveInto parameter.

Syntax

save(target, value)

target: (List of Save) A load() variable, rule input, process variable, or node input in which to save the value. with() variables are reset each evaluation and cannot be used as save targets.

value: (Any Type) The value to save. The component’s updated value can be accessed using the special variable save!value.

Returns

Save

Notes

a!save() can be called multiple times for a given component by passing them in a list to the component's saveInto parameter.

The target and value parameters are not evaluated until the user interacts with the component.

The variable save!value is only available in a!save()'s value parameter. It cannot be used in the target parameter or outside a!save.

If the component's updated value should be saved directly into a variable without modification, the a!save() function is not necessary (see first example below).

Examples

Copy and paste an example into the INTERFACE DEFINITION in EXPRESSION MODE to see how this works.

Saving a variable without modification (doesn't need a!save function)

1
2
3
4
5
6
7
	=load(
	  local!text,
	  a!textField(
	    value: local!text,
	    saveInto: local!text
	  )
	)

Upper-casing the typed text

1
2
3
4
5
6
7
	=load(
	  local!text,
	  a!textField(
	    value: local!text,
	    saveInto: a!save(local!text, upper(save!value))
	  )
	)

Upper-casing and appending to the typed text

1
2
3
4
5
6
7
	=load(
	  local!text,
	  a!textField(
	    value: local!text,
	    saveInto: a!save(local!text, "You just typed: " & upper(save!value))
	  )
	)

Upper-casing and appending to the typed text in one variable, saving unchanged to another

1
2
3
4
5
6
7
8
9
10
11
12
	=load(
	  local!modifiedText,
	  local!unmodifiedText,
	  a!textField(
	    instructions: local!modifiedtext,
	    value: local!unmodifiedText,
	    saveInto: {
	      a!save(local!modifiedtext, "You just typed: " & upper(save!value)),
	      local!unmodifiedText
	    }
	  )
	)

Modifying two variables based on the same typed text

1
2
3
4
5
6
7
8
9
10
11
12
	=load(
	  local!upperCaseText,
	  local!appendedText,
	  a!textField(
	    value: local!upperCaseText,
	    instructions: local!appendedText,
	    saveInto: {
	      a!save(local!upperCaseText, upper(save!value)),
	      a!save(local!appendedText, "You just typed: " & save!value)
	    }
	  )
	)

Modifying two variables, one based on the typed text and one with an arbitrary value=

1
2
3
4
5
6
7
8
9
10
11
12
	=load(
	  local!upperCaseText,
	  local!isModified: false,
	  a!textField(
	    value: local!upperCaseText,
	    instructions: if(local!isModified, "Modified", ""),
	    saveInto: {
	      a!save(local!upperCaseText, upper(save!value)),
	      a!save(local!isModified, true)
	    }
	  )
	)

Modifying two variables, one based on the typed text and one conditionally

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
	=load(
	  local!text,
	  local!longText: "Short Text",
	  local!shortText: "Long Text",
	  a!textField(
	    label: local!shortText,
	    instructions: local!longText,
	    value: local!text,
	    saveInto: {
	      local!text,
	      a!save(
	        if(
	          len(local!text) > 5,
	          local!longText,
	          local!shortText
	        ),
	        save!value
	      )
	    }
	  )
	)
FEEDBACK