copy array <Var/Array> index <Var/Number> … <Var/Number> into array <Var/Array>

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: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

copy array <Var/Array> index <Var/Number> … <Var/Number> into array <Var/Array>

Post by mark_a_condren »

copy array <Var/Array> index <Var/Number> ... <Var/Number> into array <Var/Array> at index <Var/Number>


<Var/Array> = The name of the source array.
<Var/Number> = The first element to be copied in the source array.
<Var/Number> = The last element to be copied in the source array.
<Var/Array> = The name of the destination array.
<Var/Number> = The index in the destination array for the first copied element from the source array.


Copies the contents of the source <Var/Array> from elements <Var/Number> to <Var/Number> into the already existing destination array <Var/Array>.
The destination array must have been previously allocated large enough to hold all the elements.


Example:

$station.array = $sector get station array from sector

$station.array.size = size of array $station.array ... (for arguments sake, lets say $station.array.size = 10)

$needed.array.size = $station.array.size / 2 ... (5 = 10 / 2)

$partial.array = array alloc: size= $needed.array.size

$mid.point = $needed.array.size - 1 ... (4 = 5 - 1)(remember the first element in an array = 0 not 1, so 0, 1, 2, 3, 4 = 5 elements)

copy array $station.array index 0 ... $mid.point into array $partial.array at index 0

--------------

In the above example, $partial.array would be the first half of $station.array.
(checks for size of $station.array being greater than 1 and other needed checks have been omitted from the example for the sake of less complexity)


Command Location:
  • »» General Commands
    • »» Arrays
      copy array <Var/Array> index <Var/Number> ... <Var/Number> into array <Var/Array> at index <Var/Number>
User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 25041
Joined: Sun, 2. Apr 06, 16:38
x4

[TiP][49] 286723

Post by X2-Illuminatus »

copy array <Var/Array> index <Var/Number> ... <Var/Number> into array <Var/Array> at index <Var/Number>


<Var/Array> = Der Name des Quell-Arrays.
<Var/Number> = Das erste Element, das aus dem Quell-Array kopiert werden soll.
<Var/Number> = Das letzte Element, das aus dem Quell-Array kopiert werden soll.
<Var/Array> = Der Name des Ziel-Arrays.
<Var/Number> = Die Stelle im Ziel-Array, an die das erste Element des Quell-Arrays kopiert werden soll.


Kopiert den Inhalt der Quelle <Var/Array> der Elemente <Var/Number> bis <Var/Number> in das bereits existierende Ziel-Array <Var/Array>.
Das Ziel-Array muss vorher reserviert worden sein, groß genug um alle Elemente aufnehmen zu können.


Beispiel:

$station.array = $sector get station array from sector

$station.array.size = size of array $station.array ... (der Erklärung zuliebe sei $station.array.size = 10)

$needed.array.size = $station.array.size / 2 ... (5 = 10 / 2)

$partial.array = array alloc: size= $needed.array.size

$mid.point = $needed.array.size - 1 ... (4 = 5 - 1) (Vergiss nicht, dass das erste Element eines Arrays gleich 0 ist, nicht 1. Somit sind 0, 1, 2, 3, 4 = 5 elements)

copy array $station.array index 0 ... $mid.point into array $partial.array at index 0

--------------

In obigem Beispiel wäre $partial.array die erste Hälfte von $station.array.
(Überprüfungen, ob die Größe von $station.array größer als 1 ist, und andere wurden in diesem Beispiel zu Gunsten geringerer Komplexität weggelassen.)


Zu finden unter:
  • »» General Commands
    • »» Arrays
      copy array <Var/Array> index <Var/Number> ... <Var/Number> into array <Var/Array> at index <Var/Number>
User avatar
Juggernaut93
Posts: 2897
Joined: Sun, 17. Jul 11, 21:03
x4

[39]286723

Post by Juggernaut93 »

copy array <Var/Array> index <Var/Number> ... <Var/Number> into array <Var/Array> at index <Var/Number>


<Var/Array> = Il nome dell'array sorgente.
<Var/Number> = Il primo elemento da copiare dell'array sorgente.
<Var/Number> = L'ultimo elemento da copiare dell'array sorgente.
<Var/Array> = Il nome dell'array di destinazione.
<Var/Number> = L'indice dell'array di destinazione per il primo elemento copiato dall'array sorgente.


Copia il contenuto dell'array sorgente <Var/array> dall'elemento <Var/Number> a quello <Var/Number> nell'array destinatario già esistente <Var/array>.
L'array di destinazione deve essere stato precedentemente allocato con una grandezza sufficiente a contenere tutti gli elementi.


Esempi:

$station.array = $sector get station array from sector

$station.array.size = size of array $station.array ... (supponiamo $station.array.size = 10)

$needed.array.size = $station.array.size / 2 ... (5 = 10 / 2)

$partial.array = array alloc: size= $needed.array.size

$mid.point = $needed.array.size - 1 ... (4 = 5 - 1) (ricorda che il primo elemento di un array è 0, non 1, dunque 0, 1, 2, 3, 4 = 5 elementi)

copy array $station.array index 0 ... $mid.point into array $partial.array at index 0

--------------

In questo esempio, $partial.array verrebbe a contenere la prima metà di $station.array.
(i controlli per verificare che la dimensione di $station.array sia maggiore di 1 e altri controlli necessari sono stati omessi per evitare un'eccessiva complessità)


Posizione dell'istruzione nella lista:
  • »» General Commands
    • »» Arrays
      copy array <Var/Array> index <Var/Number> ... <Var/Number> into array <Var/Array> at index <Var/Number>
Locked

Return to “MSCI Reference”