Variables are containers in which you can store text and numbers — referred to as the variable's "value" — for later use. You can display a variable's value on a widget as text, use it in a conditional logic statement, or manipulate it with a bracketed expression.变量是储存文本和数字的容器,通常称之为"变量值",可供后续使用。你可以在窗口部件上以文本的形式展示变量值,也可以将其应用于条件逻辑语句,或者使用带括号的表达式对进行操作。
To see variables in action, check out these tutorials:要查看变量的实际应用,请查看以下教程:
Set Dynamic Panel State on Next Page在下页上设置动态面板的状态
Slider Control滑块控制
Global Variables全局变量
Global variables and their values are accessible from every page in a project, so you can use them to pass information between pages. Go to Project → Global Variables to create and manage your project's global variables.全局变量及变量值可以在项目的每个页面访问到,所以你可以在页面之间通过全局变量传递信息。点击项目→全局变量可以创建和管理项目的全局变量。
Setting Global Variable Values设置全局变量值
Global variables can start out empty or with a default value. To assign a default value to a global variable, double-click the cell to the right of it, under Default Value in the Project → Global Variables dialog.全局变量以空值或者默认值开始。要将默认值赋给全局变量,请在项目→全局变量对话框中双击全局变量右侧的默认值下的单元格。 |
You can also dynamically set a global variable's value with the Set Variable Value action in a page or widget interaction.你还可以在页面或者部件交互中使用“设置变量值”操作动态设置全局变量的值。
|
Accessing Global Variable Values访问全局变量值
You can access a global variable's value in condition fields and any actions that include the value of variable or length of variable value value options. These include actions like Set Text, Set Selected/Checked, and Set Selected List Option.你可以在条件场景以及任何包含变量值或变量值长度的选项操作中访问全局变量值。这些操作包含设置文本、设置选择/选中和设置选中列表选项。 |
You can also access the values of global variables in bracketed expressions anywhere you see the fx icon. You can type the name of a global variable directly into an expression or select from a list of the project's global variables in the Insert Variable or Function dropdown.你可以在任何看到fx图标的位置访问带括号表达式的全局变量的值。你可以在表达式中直接输入全局变量的名称,也可以从插入变量或函数的下拉列表中找到项目的全局变量进行选择。
Tip提示
Use a bracketed expression when you need to alter the value of a global variable in some way before it gets evaluated, such as performing a math function on a numeric value or capitalizing a text value.当你需要对全局变量进行运算或转换时,请使用方括号表达式,例如对数字值执行数学函数或将文本值转换成大写。
Checking Global Variable Values in the Web Browser在Web浏览器中检查全局变量的值
While previewing a prototype in the web browser, you can see the current values of its global variables in the the prototype player's Console. This is useful for testing and troubleshooting complex prototypes since you can see the value of each variable at each stage of an interaction. In the console, you can also reset the variables back to their default values to help with testing. 在Web浏览器中预览原型时,你可以在原型播放器的控制台中查看其全局变量的当前值。这对于测试和故障排除复杂的原型很有帮助,因为你可以在交互的每一步查看每个全局变量的值。 在控制台中,你可以将全局变量重置为默认值以帮助进行测试。 |
Local Variables局部变量
Local variables and their values are defined and accessed within a single action or condition field. Use a local variable instead of a global variable when you only need to access the stored value once, in a single location.局部变量及其值是在单个操作或条件场景中定义和访问的。当你仅需要在单个位置访问一次变量的储存值时,请使用局部变量而不是全局变量。
You can create local variables in the Edit Value dialog, accessible anywhere you see the fx icon.你可以在编辑值对话框中创建局部变量,在你看到fx图标的任何位置均可访问。
Accessing Local Variable Values访问局部变量值
You can access the value of a local variable in bracketed expressions in the Edit Value dialog that the variable is declared in. You can type the name of the variable directly into an expression or select from a list of local variables in the Insert Variable or Function dropdown.你可以在声明局部变量的编辑值对话框的方括号中访问局部变量的值。可以在表达式中直接输入变量值的名称,也可以在插入变量或函数的下拉列表中从局部变量列表中进行选择。
|