Simple Tuple
A Simple Tuple (proper noun) is a homogeneous (integer), immutable data structure, an ordered set of fixed length, the values of whose elements have a limited range. Visually, a Simple Tuple resembles a One-Dimensional Array or List of Numbers (where each element of the list has its own fixed ordinal number). For example: "1,3,5,7,9,".
IMPORTANT: From here on, we are talking ONLY about the functionality of «Simple Tuples» and their features in the @MenuBuilderBot constructor. In general, as well as in programming, Tuples have DIFFERENT properties, features and definitions.
In general, working with Tuples is somewhat similar to working with Flags.
❖ Peculiarities of Simple Tuples
Important things to know about Simple Tuples:
● Simple Tuples are ONLY accessible and stored in the Variable «Simple Tuple».
● The variable name is the name of the Tuple.
● The length of a Simple Tuple is ALWAYS 100 Elements. When outputting data using a variable macros, empty cells are marked with zeros. An empty Simple Tuple will show 100 zeros.
● The number of Elements (Cells) in a Simple Tuple that can be filled in is from 1 to 100.
● Elements in a Simple Tuple can ONLY be numeric.
● Numbers in a Simple Tuple can only be INTEGER (not fractional).
● Elements in a Tuple have a value range from 0 to 255.
● The values of the Elements of a tuple CANNOT be changed (cannot be added or removed). A tuple can only be CREATED or DELETED entirely by clearing the variable.
● The numbering of Tuple Elements (in @MenuBuilderBot) starts with 1 (one).
● Empty Elements (without values) return ZERO (0).
● Accessing outside the range of Elements returns ZERO (0). For example, a Cell with index 101.
● Element with Index ZERO (0) - returns ZERO (0).
● When trying to create an Element with a value less than 0 (zero) - will write ZERO (0).
● When trying to create an Element with a fractional value - will write ZERO (0).
● When trying to create an Element with a value greater than 255 - will write 255.
Visually, a Simple Tuple is a list of numbers (for example): {55, 56, 57, 58, 59}
Spatially, it is a one-dimensional array:
[1]=55
[2]=56
[3]=57
[4]=58
[5]=59
Where [1] is the ordinal number (index) of the Element, and 55 is the value of the Element (Cell).
Once again, we remind you - Elements in Simple Tuples of the @MenuBuilderBot constructor are numbered from ONE (1) (not like in programming). This will allow you to have NATURAL numbering corresponding to the values of your variables. There is no single right or wrong solution here - each approach has its pros and cons - we chose this option as more practical and easier for people not associated with programming to understand.
❖ Working with Simple Tuples
Initialization
Initialization (Initialization Action)
● Number: 1
● Numbers 1, 2, 3, 4, 5 ➨ quotes are not needed
● Function: {stuple_set(1, 2, 3, 4, 5)}
Setting Values
Set (Action Numbers - "Set Value" mode)
● Number: 1
● Numbers: 1, 2, 3, 4, 5 ➨ no quotes needed
● Function: {stuple_set(1, 2, 3, 4, 5)}
Cleaning
Clear (Clear Action)
Specify a variable with a Tuple
Data Request
Requesting data from a tuple element
● Function: {stuple_vget("varname", 3)} (use the Variable NAME - will return the value of the element with index 3)
● Macros: {stuple_get(%varname%, 3)} (use the Variable MACROS - will return the value of the element with index 3)
Viewing Tuple Data
To view the data contained in a Tuple variable, standard tools for working with variables (Macros and Command) are suitable.
For more information on working with variables, see the Guide on Variables.
There is no practical sense in direct viewing (and outputting this data in a message). This feature is used mainly for debugging of created functions and checking for possible errors.
❖ Functions to fill up tuples
The following functions are available to fill the tuple:
stuple_set()
Simple Tuple Set - allows you to set arbitrary values in the Tuple Cells.
stuple_set(num1, num2, num3, num4, num5)
num
- arbitrary INTEGER numbers from 0 to 255
• Example:stuple_set(1, 2, 3, 4, 5)
stuple_rlist()
Simple Tuple Random List - takes a list of consecutive numbers and places them in random order.
stuple_rlist(min, max)
min
- minimum sequence numbermax
- maximum sequence number
Creates a list of ordinal numbers from min
to max
and fills the Tuple with them in RANDOM order. Numbers CANNOT be repeated. If the list is less than 100 elements, the remaining Cells remain zero.
• Example: stuple_rlist(5, 9)
Take the sequence of numbers 5,6,7,8,9 and place them (into variable) in random order, for example (7,9,8,6,5).
stuple_rrange()
Simple Tuple Random Range - will fill a Tuple of the specified length with random numbers of a specified range.
stuple_rrange(min, max, len)
Fill a tuple of size (length) len
with random numbers in the range from min
to max
. The numbers may repeat.
• Example: stuple_rlist(1, 5, 10)
Fill 10 cells with random numbers from 1 to 5, for example (2,4,2,5,1,3,3,1,4,2). The remaining 90 cells will contain zeros (0).
More filling functions may be added in the future if needed.