<RetVar/IF> reverse array <Value>

This forum serves as MSCI Reference at EGOSOFT. It's Read-Only for non MSCI Group members.

Moderators: Scripting / Modding Moderators, MSCI Moderators

Locked
mark_a_condren
Posts: 1385
Joined: Wed, 3. Aug 05, 05:05
x3tc

<RetVar/IF> reverse array <Value>

Post by mark_a_condren » Wed, 15. Sep 10, 16:42

[skip] if [not]|while [not]| <RetVar/IF> = reverse array <Value>


[skip] if [not]|while [not]| = The possible 'Conditional' statements that can be used with this command.
<RetVar/IF> = Command return, with an 'if' statement used it will be TRUE (1) if condition passes or FALSE (0) if it fails, orherwise if you use a Variable it will be TRUE / FALSE as an integer.
<Value> = The required array name that you wish to reverse.


Will reverse the contents of an array <Value>, the last element becoming the first and the first element becoming the last.

This command is quite often used in conjuntion with 'dec =' and 'sort array' as part of the lead up commands to a 'while' loop when displaying array entries in a menu to keep the correct display order due to the use of the 'dec ='. ('dec =' starts from the bottom of an array rather than the top)


Example:

The initial contents order for $this.array
  • 1
    2
    3
    4
    5
    6
$this.array = reverse array $this.array

The resulting contents order for $this.array
  • 6
    5
    4
    3
    2
    1

Command Location:

Locked

Return to “MSCI Reference”