# How to store coordinates?

## Recommended Posts

I'd like to store/save the postion for 20 objects

```DIM \$Planetpos[21]
for \$i=1  to 20
\$X = Random ( 1,20,1)
\$y = Random ( 1,20,1)
\$pos[\$i] = \$X,\$Y  ; <- LINE DO NOT WORK!!!!
next```

It should looks like:

pos[1] = 10 , 10

pos[2] = 15 , 11

pos[1] = 11 , 19

\$pos[\$i] = \$X,\$Y ; <- LINE DO NOT WORK!!!!

Can anbody help me ?

##### Share on other sites

```#include <Array.au3>
Dim \$Planetpos[20][2]
For \$i = 0 To 19
\$Planetpos[\$i][0] = Random(1, 20, 1)
\$Planetpos[\$i][1] = Random(1, 20, 1)
Next
_ArrayDisplay(\$Planetpos, 'Positions')```

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-CafĂ© Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

##### Share on other sites

Use a bidimensional array or a separator, for example "|".

```DIM \$Planetpos[21]
for \$i=1  to 20
\$X = Random ( 1,20,1)
\$y = Random ( 1,20,1)
\$pos[\$i] = \$X & "|" & \$Y ; <- LINE DO NOT WORK!!!!
next```

And when you want to read the coordinates you can use StringSplit().

When the words fail... music speaks

##### Share on other sites

```#include <Array.au3>
Dim \$Planetpos[20][2]
For \$i = 0 To 19
\$Planetpos[\$i][0] = Random(1, 20, 1)
\$Planetpos[\$i][1] = Random(1, 20, 1)
Next
_ArrayDisplay(\$Planetpos, 'Positions')```
WOW

## Create an account

Register a new account

×

• Wiki

• Back

• Git