4. Logic Dictionary: Difference between revisions
(New page: = Key commands (red) = == <code> after </code> == The <code>after</code> key command is used after a page to perform functions that relate to that page. The <code>after</code> key comma...) |
|||
Line 1: | Line 1: | ||
== <code> after </code> == | == <code> after </code> == | ||
Revision as of 10:05, 13 July 2012
after
The after
key command is used after a page to perform functions that relate to that page.
The after
key command is an important command to learn. It is likely that you will use this command quite regularly in your intervention logic. The most common way of using the after key command is with the if
and goto
key commands in the following formula:
show page1
after page1 if (any_commands_you_want_to_relate_to_this_page) goto page2
Example
after page1 if (page1.interaction1 = "yes") goto page2
In this example the end-user will be directed to page2 if they have answered 'yes' to 'interaction1' on page1.
As will be seen throughout this dictionary any command can be used with the after
key command.
begin
The begin
key command is always used with the end
key command
If your intervention has separate sessions or groups (e.g. different weekly sessions in your behavioural intervention, or a different set of pages for different user groups) then splitting your pages into sections can make it easier for you to organise parts of your intervention and find sections easily.
Things to remember when splitting you intervention into sections:
- If you begin a section, you should always end the section.
- All the logic related to the section must be between begin sectionname and end
- The name of the section should not be the same as any unique name that has been given to an object or page in your intervention.
- As you can only ever end the section that you are currently in you do not need to write the section name after end.
Example 1
begin session1
show page1
show page2
end
This will begin session1, show page1 and page2, and will end session1. All the pages related to session1 (page1 and page2) are between begin session1 and end.
Example 2 – Beginning and ending a section within another section
begin stress
begin causes
show page1
show page2
end
begin relieve
show page3
show page4
end
end
This will begin the section stress. The section causes will then begin and page1 and page2 in the section causes will be shown. he first end will end the section causes. The section relieve will then begin and page3 and page4 will be shown. The next end will end the ection relieve. The final end will end the section stress.
end
See begin
for
The for
key command is used with the save
and graph
key commands.
goto
The goto
key command always follows the after
key command. See above.
graph
The graph
key command is used when you have used the graph interaction. It is used to plot the information given by end-users to the graph.
This key command always follows the same formula and requires users to set up a user account.
graph value to "data variable determined on the graph interaction" for unique_identifier_for_the_end-user_e.g._a_username
Another line of logic is then needed for the page where the graph occurs. This will also always follow the same formula:
set pagename.graph-1 to graph "data variable determined on the graph interaction" for username
Here, pagename.graph-1 is the automatically generated name of the graph that has been put on the page where the graph occurs.
Example1
In this example the number entered in the interaction ‘kg’ on the page ‘progresschart’ will be used as the data for the “weight” variable for the graph. The variable username has been set earlier in the logic as the unique identifier for the end-user (see the set
key command for more information).
show progresschart
graph progresschart.kg to "weight" for username
Later in the logic the following line is needed after the page where the graph occurs:
show weightgraph
set weightgraph.graph-1 to graph "weight" for username
A full tutorial for using graphs will soon be available.
if
The if
key command is always used with the set
or after
key commands.
load
The load
command is always used with the save command.
named
Use this key command to re-show a page you have already shown.
For example, if you had a page that you need to keep showing back to your end-users you could use the named
key command as so (note that in the example below the line [etc, etc] has been used to indicate that there would be other lines of logic here):
Example
show page1
[etc, etc]
show page1 named page2
[etc, etc]
show page1 named page3
save
The save
key command allows you to save the responses that an end-user enters on a page. This can then be loaded using the load
key command onto another page to re-show it to your end-user. The save and load commands can be used across sessions and requires end-users to have registered a user account.
Example:
show page1
save page1 for username
Then, later on in the logic (either in the same session or a later session) the following logic would be used:
show page20
set default page20.interaction2 to load page1.interaction1 for username
So, in the first part of this logic page1 is saved for the end-user. Then when they get to page20 in the intervention the response that they entered on interaction1 on page1 will be reshown to them on interaction2 on page20.
saveandload
This key command can be used after a page that includes interactions so that if an end-user moves away from that page and then comes back to it, the page will automatically show them what they entered the last time they were on that page. This line of logic would simply be written as so:
show page1
saveandload page1 for username
Any interaction on page1 would then be saved and loaded each time the end-user comes back to that page.
set
The set
key command can be used to set variables within the logic or for performing calculations.
Example 1
The most common use of setting variables will be to set a username for the user. Many of the logic commands such as save
will need a username to be set. This will need to be done at the start of your logic file.
Set username to login.loginuname
This will set the variable username to whatever the end-user enters into the interaction uniquely named loginuname on the login page. The word username can then be used any time throughout the logic to mean whatever the person entered in that interaction.
Example 2
The set
key command can also be used to set a variable based on how end-users respond to certain interactions. This can then be used to tailor the intervention based on this variable.
show page1
set condition1 to and (page1.chooseoptions contains "optiona", page1.chooseoptions contains "optiond")
after page1 if condition1 goto page3
So in example 2, the variable ‘condition1’ is set if end-users select options a and d from the interaction ‘chooseoptions’ on page1. Then those that are in this condition are sent to page 3 where they will receive tailored information based on the options they selected.
Example 3
In this example, the set
key command is used to set a score based on the calculation that follows. In this calculation the number that the end-user selects in the interaction ‘dailyexercise’ on page1 is multiplied by 5 to create their exercise score
set exercisescore to (page1.dailyexercise * 5)
show
The show
key command is the first and most important logic command you will need to know. It is also probably the most common one that you will use.
This key command shows each of the pages that you have created. Pages will be shown in the order they are mentioned in the logic. When an end-user clicks on a Next button on a page, they will be moved to the next page written in the logic.
Example 1
show page1
show page2
show page3
show page4
In the example above the end-user will first be presented with the page uniquely named ‘page1’. Then, when they click on the next button on page1 they will see the page called ‘page2’. This is followed by ‘page3’ and finally ‘page4’.
Note: Before you can preview your intervention you will need to have the show key command in the logic file for each page you want to view.
As the logic requires you to use unique names for each page in your logic, you can only use the show key command once for each page. However, see the named
key command above for how to re-show the same page to users.
You can also reshow pages to your end-user by using a jump button on a previous page.
to
The to
key command is used with the set
key command to set variables.