BasicsTutorial/Arrays

Last-modified: 2008-03-10 (月) 12:05:52

Arrays

配列

Arrays will become one of the things you use the most in DBPro, they are really handy for storing information, shortening your code and making your code less nonsensical.
配列はあなたがDBProで最も使うもののうちの1つになる、それは情報を格納して、あなたのコードを短くして、あなたのコードをより意味があることに本当に便利である。
Some people find arrays hard to understand so I am going to try and explain them in the easiest and clearest way.
私が最も簡単で最も明白な方向でそれらを説明するようにするつもりであるように、一部の人々はわかるのが難しい配列を見つける。
Imagine a 1D grid, no in fact here’s one to look at…
一次元格子を想像しなさい、少しも実際、at…に見える人はここにいない

Ages(x)

01234
 

That represents the array Ages(), we will use it to store the ages of different people, it’s exactly like an integer variable except it has four slots (the white boxes) where it can store integer values.
それは Ages()配列を示す、我々はそれをさまざまな人の年齢を保存するのに用いられる、それ以外の変数がそれが整数値を保存することができる4つのスロット(ホワイトボックス)を持つことは正確に整数のようである。
Now all arrays don’t have to have just 5 slots, they can have 6 or 8 or 105 or even just one.
今、全ての配列がちょうど5つのスロットを持つ必要があるというわけではない、それは6または8または105またはちょうどものさえ持っていることができる。
This is how you set up an array, you have to define how many slots you want it to have.
これはあなたが配列を準備した方法である、あなたはあなたがそれがどれくらいのスロットを持つことを望むかについて定めなければならない。

Dim Ages(4)

Arrays are formed by a name (like a variable), with a set of brackets on the end for inputting various values.
いろいろな値を入力するための終わりの一組の括弧で、配列は名前(変数のような)によって生まれられる。
DIM is a command used for setting up variables, you have to put the array name after it, and in this case you need to put the MAXIMIUM slot that you want the variable to have, the number is not the number of slots since variables have a ‘0th’ slot also.
DIMは変数を準備するために使用されるコマンドである、あなたはそれの後、配列名を置かなければならない、そして、あなたがあなたが変数が持つことを望むMAXIMIUMスロットを置く必要がある、 この場合では、変数が『第0』スロットも持つから、数はスロットの数でない。

Now that we have set up our array with 5 slots (0-4), we need to fill them with values.
我々が5つのスロット(0-4)で我々の配列を準備した、我々はそれらを値で満たす必要がある。
We do that just like if we were giving variables values.
我々が変数値を与えているように、我々はそうする。

Ages(1) = 10

We just write the name of the array and the value that we want to assign after the = operator.
我々は、ちょうど配列の名前と我々が =オペレーターの後で割り当てたい値を書く。
The difference is that this time we put the number of the slot we want to assign the value to, inside the brackets.
違いは、今度は、我々が、括弧の中に、値を割り当てたいスロットの数を置いたということである。
This would be how our grid would look now.
これは、我々の格子が現在見る方法である。

Ages(x)

01234
 10

You don’t have to fill the array in any particular order, I filled slot 1 first as it seemed logical to start at 1.
あなたは少しの特定の順序でも配列を満たす必要はない、1に始まることが論理的なようだったので、私は最初にスロット1をふさいだ。
I often don’t fill slot 0 as it can be easier to use arrays that go up to slot 4 to store 4 values.
それが4値を保存するためにスロット4まで上がるより使いやすい配列でありえて、私はしばしばスロット0をふさがない。
Sometimes slot 0 can be used to store other values, for example the number of slots in your array that actually store something.
時々、スロット0は他の値(たとえば実際に何かを保存するあなたの配列のスロットの数)を保存するのに用いられることができる。
Let’s fill the rest of the array now, I will fill 0 for the sake of it.
すぐに残りの配列を満たそう、私はそれのために0を満たす。

Ages(0)=3
Ages(2)=16
Ages(3)=98
Ages(4)=9

Our grid now looks like this.
我々の格子は、現在これのように見える。

Ages(x)

01234
  31016989

Now how about reading it all off?
現在、それのすべてを読みとることはどう?
Well it’d just the same as putting values in.
よく、それは値を入れながら、まさに同上を持っていた。
Here I use a FOR_NEXT loop to print all the values.
ここでは、私は全ての値を printするために、FOR_NEXTループを使用する。

For x=0 to 4
  Print Ages(x)
Next x
Wait key

That is one of the other handy things about an array, not only do you not have to use loads of different variables, you can also loop through the array and access all the values.
配列についての他の便利なもののうちの1つでつまりある、だけでなくあなたが、たくさんの異なる変数を使わない、あなたは配列中をループすることもできて、全ての値にアクセスすることができる。
Imagine writing as PRINT statement for every value in a set of 1000, you’d be here for a year (OK I’m exaggerating, but it’s still take a long time)…
1000の集合のあらゆる値のためのプリント命令文として書くことを想像しなさい、あなたが1年の(OK、私は誇張している、しかし、それは静寂に長い間がかかるということである)…のためにここにいるだろう

Print Ages1
Print Ages2
Print Ages3
Print Ages4

All the way to….
全ての方法to…。

Print Ages100

As opposed to
対抗されて、

For x=1 to 100
  Print Ages(x)
Next x

You can use other variables to choose which value to access, which you wouldn’t be able to do with regular variables…
あなたは どの値にアクセスするべきかについて 選ぶために他の変数を使うことができる。そして、あなたはそれを規則的な変数…ですることができないだろう

For x=1 to 100
  Print Agesx
Next x

That’d just print the variable Agesx 100 times, not what we want.
That'dは、ちょうど変数で Agesx 100回をプリントする。(我々が欲しいものでない)

Now arrays take up memory (memory is basically where the computer stores values) and there is a limited amount of this, so it is useful if we delete the array when it is no longer in use.
現在、配列は記憶(記憶は、基本的に、コンピュータが値を保存するところである)を占める、そして、これの限られた量があるので、それがもはや使用中でないとき我々が配列を削除するならば、それは役に立つ。
This can speed up the computer and prevent other problems like crashing if you have a large program.
あなたには大きなプログラムがあるならば、これはコンピュータの速度を上げることができて、壊れるような他の問題を防ぐことができる。
We use this command to delete an array.
我々は、配列を削除しなさいというこの命令を使う。

Undim Ages(0)

You always need to put a 0 between the brackets, it’s just the way the UNDIM command works.
あなたは常に括弧の間で0を置く必要がある、UNDIMコマンドが仕事することはまさに方法である。

Summary of Commands

命令の概要

· DIM array() - Sets up an array of a certain size.
DIM配列()-多数の特定の配列サイズを準備する。

· UNDIM array(0) - Deletes an array.
UNDIM配列(0)-配列を削除する。

End of Section Tasks

セクション終わりの作業

l Write something that allows the user to enter in data for the computer to store in an array, then print it off using a loop.
ユーザーがコンピュータが配列に保存するデータで入るのを許す何かを書きなさい、そして、ループを使用することから、それをプリントしなさい。