Justinmind

SUPPORT

Learn how to prototype web and mobile apps

# Functions and Constants to build interactive prototypes

Every expression in Justinmind is a combination of Functions/Constants and Data sources.

In this tutorial, you will find a brief explanation for each function and constant.

## Functions

Functions are all represented with a circle (to differentiate them from the hexagons that represent constants) with a drawing or a text indicating what they are for. They are divided in: number functions, comparators, text functions, logic functions, data functions, Data Master functions.

Number Functions

These are operations whose operands are numbers (integers, floating point numbers, etc.).

Addition (+) – Represented by the plus sign. Takes two numeric operands and combines their quantity or value.
Subtraction (-) – Represented by the dash sign. Takes two numeric operands and takes away the quantity of the second from the quantity of the first.
Multiplication (X) – Represented by the cross sign. Takes two numeric operands, say X and Y. X times Y (X multiplied by Y) results in adding X copies of Y together, or adding Y copies of X together, for it has the commutative property.
Division (/) – Represented by a slash. It’s the inverse of the multiplication. Takes two numeric operands, say X and Y. X divided by Y results in the number of groups of size Y one can form out of a group of size X.
Maximum (MAX) – Given two numbers, it returns the largest one in value.
Minimum (MIN) – Given two numeric parameters, it returns the smallest one in value.
Average (AVG) – Given two numeric parameters X and Y, Avg(X, Y) returns the following: (X + Y)/2 where + is the addition and / the division explained above.
Absolute (ABS) – Takes a real number and returns its numerical value without regard of its sign.
Rounding up (ROUND) – Takes two numeric parameters, a floating point number and an integer, and returns an approximate representation of the first using only as many decimal numbers as the second parameter’s value.
Percentage (%) – Takes two numeric operands and the result is the first number expressed as a fraction of the second. For instance, X % of Y = (X x Y)/100.
Square root (SQRT) – Takes just one numeric operand X since the second is always two (square). It returns a number R such that R2 = X, meaing R x R = X.
Modular arithmetic (MOD) – Takes two numeric operands X and Y, and it returns the remnant of the division of X by Y.

Comparator Functions

Equal (=) – Returns true if both elements at the two ends of the equal sign (=) have the same value. Returns false otherwise.
Not equal (=/)- It’s the result of applying the logical function Not explained in the Logic Functions section to the Equal function explained in the previous subsection, so the Not Equal function returns true if the elements at the two ends have a different value.
Greater (>) – Returns true only if the value of the element at the left of the Greater sign represents a neatly larger value than the element on its right.
Less (<) – Returns true only if the value of the element at the left of the Greater sign represents a neatly smaller value than the element on its right.
Greater or equal (_>) – Returns true only if the value of the element at the left of the Greater sign represents a larger or equal value than the element on its right.
Less or equal (_<) – Returns true only if the value of the element at the left of the Greater sign represents a smaller or equal value than the element on its right.

Text Functions

Count (COUNT) – This function takes a string parameter and returns a natural number representing the number of characters of the incoming string.
Concatenation (CONCAT) – This function takes two string parameters A and B and returns a string that represents B appended to the end of A.
Substring (SUBSSTRING)- This function takes a string parameter A and two numeric parameters, X and Y, and returns a sub-string of A that comprises from the character at the index X to that at Y, given that strings’ total range spans from 0 to n-1, where n is the number of characters of the string.
Index of (INDEX) – This function takes two string operands, A and B, and returns an integer with the index in A where the first occurrence of B starts. If B does not occur in a, it returns -1.
To upper case (ABC) – This function takes a string and returns a string which contains the same characters in the same order where lower case letters have been replaced by capital letters.
To lower case (abc) – This function takes a string and returns a string which contains the same characters in the same order where capital letters have been replaced by lower case letters.
First upper (Abc) – This function takes a string and returns a representation of the same string where the letter at the index 0 has been capitalized.
Contains (HAS) – This function takes two input strings A and B. It returns true only if first string A contains the whole string B.
Match regular expression (REG EXP) – This function takes a string A and a string representing a standard regular expression R and returns true if A matches the expression R, and false otherwise.

However, you won’t always need to build your own regular expressions, as Justinmind provides some of the most useful constructions ready-to-use.

Logic Functions

And (&) – Given two boolean operands the AND it returns true if both are true, and returns false otherwise.
Or (OR) – Given two boolean operands, the OR operation returns true if either or both of them are true and returns false otherwise.
Not (NOT) – Given a boolean operand, the NOT operation returns its opposite. NOT(true) = false, NOT(false) = true.
Xor (XOR) – Given two boolean operators, the XOR operation returns true if only one of them is true, and false otherwise.

Data Functions
Some data elements may be represented as collections and some other functions may be needed. This is the case for Data Masters, Data Grids, Data Lists, Selection Components, etc.

Data selection
This function takes two input parameters A and B. Parameter A represents the data collection where the selection will be applied to (eg: Data Master), and parameter B works as a selection filter represented by a Data Master’s attribute. Hence, this function will return the filtered data from A following B rules. The result will be generally a list of values.

Filter – This function takes two input parameters A and B. Parameter A represents the data collection where the filter is applied to (eg: Data Master), and parameter B represents the filter condition. Parameter B is usually a conditional expression made of Data Master’s attributes and conditional operators. Hence, this function will return a list of Data Master’s instances following B rules.
Select Distinct – This function works as ‘Data selection’ returning the same list of values but repeated items.
Filter Distinct – This function works as ‘Select Distinct’ but returning a list of Data Master’s instances instead of a list of values
Count – This function returns the number of data instances the input collection has.
Summation – This function returns the summation of an input data list. The function needs two parameters A and B: parameter A represents a data collection and B acts as a filter of A as the ‘Data Selection’ operation does. Moreover, parameter B may contain number operators. The filtered data collection must consist of numbers for the operation to work properly.
Average – This function returns the mean from a data set by dividing the sum of data by the number of items in the data set. The input parameters are the same as for the Summation operation.
Maximum – This function takes the same parameters as Summation. In this case, it will return the maximum number found in the input data set.
Minimum – This function takes the same parameters as Summation. In this case, it will return the minimum number found in the input data set.
Concatenate – This function represents the concatenation of two data collections. It takes two input parameters each one representing a data collection and returns a list containing both sets.
Substract – This function takes two input parameters A and B, each one representing a data collection. It returns a list containing all the items from data set A which do not appear in B.
Sort – This function takes two input parameters A and B. Parameter A represents the data collection that will be sorted (eg: Data Master), and parameter B is an attribute from the data source that acts as the category to sort. This function will return the same data from parameter A sorted by attribute B.
Also, there is a dropdown indicating the order the sort must take: ascending or descending. This will order the data in parameter A in one way or another, for numbers, texts or even dates.

Data Master Functions
Some functions can be only applied to Data Masters. This is the case for the functions New, Modify and Delete.

## Constants

There are several static elements, or ‘Constants’,  you can use as parameters:

Text – This element allows the user to input any desired string as a literal.
Date – This element lets you select a date from a calendar
System date – This element gives the current system date.
System time – This element gives the current system time.
Random Number – This element generates a random number between 0 and 1 that can be used to include randomness in calculations. It is very useful to simulate a random or vague behaviour.
Window width – This element generates a number that is the width of the screen in pixels.
Window height – This element generates a number that is the height of the screen in pixels.
Window scroll X – This element gives the window’s horizontal scroll position.
Window scroll Y – This element gives the window’s vertical scroll position.
Cursor X – This element gives the horizontal mouse position within the window.
Cursor Y – This element gives the vertical mouse position within the window.

Regular Expressions
Use the regular expressions to easily check if a value meets a ‘rule’. E.g.: Check if a number is a correct postal code. See how to construct this expressions in the Text Functions section. There are several regular expressions already created that you can use together with the ‘Regular Expression’ function:

Number – This regular expression represents any number, with its sign and its decimal part separated from the integer part by either ‘.’ or ‘,’.
Email – This regular expression represents any valid email address according to the standard. Check for the name, the @ symbol and the domain names.
Percentage – This regular expression accepts any number with an integer part up to two digits and a decimal part up to two digits.
Money – This regular expression accepts any monetary value in the form \$34,245,456.33, where the dollar symbol and the decimal part are optional.
Postal code – Accepts any UK postal code, which are one or two town district letters, followed by one or two digits, followed by a white space, followed by a digit, followed by two postal district letters. Also any Spanish postal code is accepted, which are numbers of five digits.
Credit card – This accepts all Visa credit cards.
Phone – Accepts any number between six and ten digits, optionally separated in its second or third digit by a dash or a white space.
URL – This accepts all possible URLs, which are strings matching the following notation: resource_type://username:password@domain:port/filepathname?query_string#anchor.