Difference between revisions of "Ds"

From Keyfax Wiki
Jump to: navigation, search
(Setup)
 
(5 intermediate revisions by the same user not shown)
Line 30: Line 30:
  
 
[[File:dsfunction4.png]]
 
[[File:dsfunction4.png]]
 +
 +
===Demonstration===
  
 
[[File:dsfunction3.png]]
 
[[File:dsfunction3.png]]
  
 
==Example Two==
 
==Example Two==
 +
 +
A more complicated use would be to have an SQL query retrieve a value from a number of possible values from a database, then convert the retrieved value into something else.
 +
 +
This example uses a dynamic question to get a value from a database and write it to a databox, the expression in this databox then checks the value and outputs text to a message depending on the value. This has been used by a client to look up a numeric code from their Housing Database and convert this code into different phone numbers to call depending on the property location.
 +
 +
[[File:dsfunction5.png]]
 +
 +
If the User selects
 +
 +
RD returns 1 and converts into "Diagnostics Scripts"
 +
FL returns 2 and converts into "Enquiry Scripts"
 +
ROL returns 3 and converts into "Repairs Online"
 +
EOL returns 4 and converts into "Enquiries Online"
 +
BEN returns 101 and converts into "Benefits"
 +
OC returns 102 and converts into "Office Care"
 +
Test returns 900 and converts into "Test Scripts"
  
 
===Setup===
 
===Setup===
 +
 +
A dynamic list question uses an SQL query to populate a list with script codes.
 +
 +
[[File:dsfunction6.png]]
 +
 +
[[File:dsfunction11.png]]
 +
 +
Depending on the code chosen, a number is output. As shown above, RD results in 1.
 +
 +
A script databox contains the expression to convert the number into the correct script name and is as follows:
 +
 +
[[File:dsfunction15.png]]
 +
 +
The full expression is
 +
 +
='1' Replace('True','Diagnostic Scripts') Replace('False', ds ='2' Replace('True','Enquiry Scripts') Replace('False', ds ='3' Replace('True','Repairs Online') Replace ('False', ds
 +
='4' Replace('True','Enquiries Online') Replace ('False', ds = '101' Replace ('True','Benefits') Replace ('False', ds ='102' Replace ('True', 'Office Care') Replace ('False', ds =
 +
'900' Replace ('True', 'Test Scripts')))))))
 +
 +
This expression first looks to see if the value in the databox is '1', if it is then 'True' will be returned, in this case, 'True' will be replaced with 'Diagnostics Scripts'. If it is not '1' it'll return a value of 'False',  in this case 'False' will then be replaced with the original value (ds) and the expression will check to see if that is '2', if so it'll return a value of 'True', the 'True will be replaced by 'Enquiry Scripts... and so on until either something has come up as 'True' or all the checks have resulted in 'False.
 +
 +
===Demonstration===
 +
 +
[[File:dsfunction7.png]]
 +
 +
[[File:dsfunction8.png]]
 +
 +
[[File:dsfunction9.png]]
 +
 +
[[File:dsfunction10.png]]

Latest revision as of 10:22, 25 April 2019

The ds function is used in a databox to recall the original value of that databox that was entered or populated. This is useful when you want to use the value of a databox multiple times in one expression.

These examples are available in the model scripts database provided when Keyfax is purchased.

Example One

The most simple example of this would be using it to square a number, multiply it by itself.

The script for this would look something like this.

Dsfunction1.png

The user is asked for a number to square, the expression Examples.ds.Square.value then makes the calculation and writes the result into the databox Script.Details which is then displayed in the message Example Message.DSSQR.

Setup

Script databox Examples.ds has an expression setup within as shown below.

Dsfunction2.png

Number * Number(ds)

This tells it to treat the value entered by the user as a number, then multiply it by the original value entered by the user.

For example, if you enter the number 9

Number 9 * Number(9) = 81

The result is written into Script.Details and output the message.

Dsfunction4.png

Demonstration

Dsfunction3.png

Example Two

A more complicated use would be to have an SQL query retrieve a value from a number of possible values from a database, then convert the retrieved value into something else.

This example uses a dynamic question to get a value from a database and write it to a databox, the expression in this databox then checks the value and outputs text to a message depending on the value. This has been used by a client to look up a numeric code from their Housing Database and convert this code into different phone numbers to call depending on the property location.

Dsfunction5.png

If the User selects

RD returns 1 and converts into "Diagnostics Scripts"
FL returns 2 and converts into "Enquiry Scripts"
ROL returns 3 and converts into "Repairs Online"
EOL returns 4 and converts into "Enquiries Online"
BEN returns 101 and converts into "Benefits"
OC returns 102 and converts into "Office Care"
Test returns 900 and converts into "Test Scripts"

Setup

A dynamic list question uses an SQL query to populate a list with script codes.

Dsfunction6.png

Dsfunction11.png

Depending on the code chosen, a number is output. As shown above, RD results in 1.

A script databox contains the expression to convert the number into the correct script name and is as follows:

Dsfunction15.png

The full expression is

='1' Replace('True','Diagnostic Scripts') Replace('False', ds ='2' Replace('True','Enquiry Scripts') Replace('False', ds ='3' Replace('True','Repairs Online') Replace ('False', ds 
='4' Replace('True','Enquiries Online') Replace ('False', ds = '101' Replace ('True','Benefits') Replace ('False', ds ='102' Replace ('True', 'Office Care') Replace ('False', ds = 
'900' Replace ('True', 'Test Scripts')))))))

This expression first looks to see if the value in the databox is '1', if it is then 'True' will be returned, in this case, 'True' will be replaced with 'Diagnostics Scripts'. If it is not '1' it'll return a value of 'False', in this case 'False' will then be replaced with the original value (ds) and the expression will check to see if that is '2', if so it'll return a value of 'True', the 'True will be replaced by 'Enquiry Scripts... and so on until either something has come up as 'True' or all the checks have resulted in 'False.

Demonstration

Dsfunction7.png

Dsfunction8.png

Dsfunction9.png

Dsfunction10.png