Array -Commands

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Variable Definitions and Operations > Array -Commands >

Array -Commands

ARR. - Array Command

Previous Top Next


MiniRobotLanguage (MRL)

 

Small Introduction to Arrays

If you have never used Arrays before

 

 

 

### The Enchanting Tale of Numeric Arrays: An Extended Guide for Young Wizards 🌟

 

#### Introduction

Today, we're diving deep into the mystical realm of Numeric Arrays. 

Imagine you have a magical wand that can store not just one, but many spells! 

That's what Numeric Arrays do; they hold multiple numbers in a single, magical container. 🌈

 

#### Chapter 1: The Basics of Numeric Arrays 📚

In the magical world, Numeric Arrays are like enchanted shelves where you can store your potion ingredients in a specific order. 

Each spot on the shelf has a number, called an 'index,' and you can put a potion ingredient— represented by a number —there.

The magic of Arrays therefore lies in the fact that you can index data using a number.

 

##### The Magical Parameters: P1, P2, and P3

 

- **P1 - Array-Name**: This is like naming your magical shelf. You can have up to 33 magical shelves, numbered from 0 to 32.

- **P2 - Array Index**: This is the specific spot on your magical shelf where you want to place your potion ingredient. It starts from 0 and goes up to the dimension of the array.

- **P3 - Value**: This is the potion ingredient (or number) you want to store at that specific spot.

 

**For example**:  

To store a 'Love Potion' with the number 9 at the first spot, you'd use:  

ARR.Set INT Array|1|0|9

 

To check what's at the first spot, you'd use:  

ARR.Get INT Array|1|0|PotionNumber

 

#### Chapter 2: The Power of Multiple Values 🌟

 

The real magic of Numeric Arrays is that they can hold multiple values. This is like having a spellbook where each page contains a different spell.

 

**For example**:  

You can store multiple potion numbers like this:  

ARR.Set INT Array|1|0|9  

ARR.Set INT Array|1|1|7  

ARR.Set INT Array|1|2|5

 

And retrieve them like this:  

ARR.Get INT Array|1|0|$$REA

ARR.Get INT Array|1|1|$$REB

ARR.Get INT Array|1|2|$$REC

 

#### Chapter 3: The Magic of Floating Point and Integer Numbers 🌌

 

In the world of Numeric Arrays, you can store two types of numbers: 

Floating Point (FP) and 

Integer (INT). 

Floating Point numbers can have decimals, like 9.75, while Integer numbers are whole numbers like 9 or -9.

 

- **Floating Point (FP)**: Extended-precision variables that require 10 bytes of storage each. They have a range of approximately +/- 3.4*10^-4932 to 1.2*10^4932, and offer 18 digits of precision.

- **Integer (INT)**: Signed Integer numbers in a 64-bit range.

 

**For example**:  

To store a Floating Point number, you'd use:  

ARR.Set FP Array|1|0|9.75

 

To retrieve it, you'd use:  

ARR.Get FP Array|1|0|$$FPR

 

#### Chapter 4: Sorting and Organizing 🧙‍♂️

Imagine you have a bag of magical gems, and you want to sort them by their power level. 

Numeric Arrays can do this for you! 

You can sort the numbers in ascending or descending order, making it easier to find the most or least powerful gem.

 

**For example**:  

After storing the potion numbers 9, 7, and 5, you can sort them to get 5, 7, and 9.

 

#### Chapter 5: Indexing and Linking 🧙‍♀️

Numeric Arrays can also act as magical indexes for other arrays. This is like having a magical map that shows you where to find hidden treasures.

 

**For example**:  

If you have a String Array of potion names like "Love," "Wisdom," and "Courage," you can use a Numeric Array to link these names to their potion numbers 9, 7, and 5.

 

#### Chapter 6: Why Numeric Arrays Are Magical 🌈

 

1. **Efficiency**: Storing multiple numbers in one place makes your code faster, like a speedy broomstick!

2. **Organization**: It's easier to manage your magical items when they're neatly stored in a single array.

3. **Flexibility**: You can easily add, remove, or change numbers, just like swapping out ingredients in a potion.

4. **Advanced Magic**: By sorting and indexing, you can perform more complex spells and calculations.

 

#### Chapter 7: The Grand Spellbook 📖

 

As you master the art of Numeric Arrays, your magical abilities will grow exponentially. 

You'll be able to cast more complex spells, brew advanced potions, and solve the riddles of the magical world.

 

Chapter 8: The Enchantment of String Arrays 🌠

Ah, young magicians, just when you thought Numeric Arrays were the pinnacle of magical storage, let me introduce you to another marvel: String Arrays! 🌟

 

String Arrays are like enchanted scrolls where you can store not just numbers, but words, phrases, or even entire spells in written form. 

Imagine having a scroll that can hold the incantations for "Levitation," "Invisibility," and "Time Travel" all in one place!

 

The Magical Parameters: P1, P2, and P3

Just like Numeric Arrays, String Arrays also use the mystical parameters P1P2, and P3.

 

P1 - Array-Name: This is like naming your enchanted scroll. You can have up to 33 magical scrolls, numbered from 0 to 32.

P2 - Array Index: This is the specific line on your scroll where you want to write your incantation.

P3 - Value: This is the incantation or phrase you want to store at that specific line.

 

For example:

To store the incantation for "Invisibility" at the first line, you'd use:

 
$$LEV=Nacht und Nebel niemand gleich

ARR.Set|1|0|$$LEV

 

To read what's at the first line, you'd use:

ARR.Get|1|0|$$LEV

 

Why String Arrays Are Also Magical 🌈

Versatility: While Numeric Arrays are great for numbers, String Arrays can hold text, making them perfect for storing names, descriptions, or even entire spells.

Organization: Just like Numeric Arrays, String Arrays help you keep your magical elements in order.

Advanced Magic: You can even use Numeric Arrays as indexes for your String Arrays. Imagine having a Numeric Array that tells you which line of your enchanted scroll holds the spell you need!

 

For example:

Arrays for Indexing:

  If you have a String Array of spells like "Levitation," "Invisibility," and "Time Travel," you can use a Numeric Array to link these spells to their power levels 9, 7, and 5.

Lets say you use ARRAY 1+2 for INT and ARRAY 3 for Strings. In fact you have then sort of 2 dimensional ARRAY where the Array-Name is the second dimension.

Then you can get a "String" by its "Number". You will then take special measure to act always on all 3 Arrays when adding or removing elements.

Doing so, the ARR.-Command can be used like a multidimensional Array  with up to 32 Dimensions also.

 

And so, young wizards, our magical journey through the realms of Numeric and String Arrays comes to a close.

May your spells be ever potent, your potions ever effective, and your arrays ever organized! 🌟🌈

 

Thus concludes our extended guide to the magical world of Arrays. 

May your coding journey be as enchanting as the realms we've explored today! 🌟🌈🌠

 

Practical Applications

String Arrays: Useful for text manipulation and storage.

INT Arrays: Ideal for arithmetic operations and data sorting.

FP Arrays: Best for scientific calculations requiring high precision.

 

See also:

ARR_---3D---Arrays

ARR_---4D---Arrays

SDO.Arr----Sample-Script

SDO.Arr----Small-Introduction-To-A

Append Array

Clm Array

Clr Array

Dim Array

Get Array

Get FP Array

Get INT Array

Pack-Array-to-File

Pack-Array-to-FileDelimiter

Pack-Array-to-Var

Pack-Array-to-Var

Send to AI

Set Array

Set FP Array

Set INT Array

Unpack-Array-from-File

Unpack-Array-from-File_Delimiter

Unpack-Array-from-Var

Unpack-Array-from-Var_Delimiiter