BasicsTutorial/Outputting Text

Last-modified: 2008-02-21 (木) 14:58:20

Outputting Text

テキストを出力すること

First we will start with the pretty much the most basic command in the Basic language, it outputs text onto the screen.
最初に、我々はBASIC言語でかなりずばぬけて最も基本的なコマンドから始める、それはスクリーンの上へテキストを出力する。
Type this into your editor.
あなたのエディタに これをタイプしなさい。

Print “Hello World”
Wait key

Now run the program and press any key to exit.
すぐに、プログラムを実行して、脱出するために、どんなキーでも押しなさい。
You should see “Hello World” written across the top of the screen.
あなたは、スクリーンの上部の向こうで書かれる「こんにちは、世界」を見なければならない。
The print command prints whatever is put in quotes after it onto the screen.
PRINT命令は、それの後、引用句(“)に入れられるものは何でもスクリーンの上へプリントする。
You always need to have quotes around text that you want to print, or else you will get an error message or something else printed.
あなたは常に、あなたがプリントしたいテキストを引用符( “” )で囲む必要がある、でなければ、あなたはエラー・メッセージまたは何か他のものをプリントされる。

The second line has the command WAIT KEY on it.
第2の行は、それの上で命令 WAIT KEYを備えている。
This command tells the computer to wait for a keyboard key to be pressed before continuing.
この命令は、続ける前にキーボード・キーが押されるのを待つようにコンピュータに言う。
The computer goes through the code from top to bottom always unless you tell it not to, so PRINT will always happen before WAIT KEY.
あなたがそれを言う限り、コンピュータは常に上から下まで順番にコードを調べるので、PRINTはWAIT KEYの手前で 常に停止する。

Now, what if we wanted to print “World” on the next line down to “Hello”?
現在、我々が「よろしく」と、次の行に「世界」をプリントしたいならば、どうですか?
It couldn’t be simpler, use 2 print commands.
それはより単純ではありえなかった、2つのプリントコマンドを使用しなさい。

Print “Hello”
Print “World”
Wait key

Easy enough!
十分に簡単な!
Want a blank line between the 2 words?
2つの語の間で 空白行が欲しい?
Add another print command with nothing after it.
それの後、もう一つのプリント命令を加える、オプションは無い。

Print “Hello”
Print
Print “World”
Wait key

This simply prints another line with nothing on it.
これは、単にそれの上で何でももう一つの行をプリントしない。
Now what if we wanted to separate a print statement onto 2 lines of code, but keep it printing on the same line, easy again.
我々が2行のコードの上へプリント命令文を切り離したかった今、しかし、それを同じ行(簡単なもう一度)にプリントさせ続けなさい。(;)セミコロンに注目。

Print “Hello”;
Print “World”
Wait key

We may want to do this when we have a massive line of code, after all…
all…の後、我々には1行の大量のコードがあるとき、我々はこうしたいかもしれない

Print “This simply prints another line with nothing on it.
Now what if we wanted to separate a print statement onto 2 lines of code, but keep it printing on the same line, easy again.”

Is a lot harder to read (when pasted into an editor) than…
多くは、(editorにペーストされるとき)than…を読むのがより難しい

Print “This simply prints another line with nothing on it.”;
Print “  Now what if we wanted to separate a print statement”;
Print “ onto 2 lines of code, but keep it printing on the same”;
Print “ line, easy again.”

While we’re at it, you can also print numbers straight out, without quotes.
我々がそれでいる間、引用なしで、あなたは直接に数をプリントすることもできる。

Print 1

So why is that handy?
それで、なぜ、それは便利か?
It will become obvious later on, I just thought I’d mention it now to avoid confusion.
それは後ほど明らかになる、私はちょうど私が混乱を避けるために現在それに言及しない。

Printing at the top of the screen is all well and good, but what if you want to print something at another point on the screen?
スクリーンの最上位行でプリントするすべては結構である、しかし、あなたが画面の違う場所に何かをプリントしたいならば、どうですか?
Here’s how.
方法は、ここにある。

Set cursor 100,200
Print “This text is at the screen coordinates 100,200”
Wait key

The new command SET CURSOR sets the screen coordinates at which any text following it should be printed.
新しい命令 SET CURSORは、それの後のどんなテキストでもプリントされなければならないスクリーンの座標を決める。(ドット単位であることに注意しなさい。)
By default the screen is 640 (along) by 480 (down) pixels.
デフォルトで、スクリーンは480(下の)と640(横に)ピクセルである。
0,0 is at the top left of the screen, and 640,480 is at the bottom right.
0,0はスクリーンの左上にある、そして、640,480は右下にある。

How about clearing the screen of all text so you can start again?
あなたが再び出発することができるように、画面の全てのテキストを片づけること(消去)はどう?
That is done with the use of one simple command.
それは、1つの単純な命令を使ってされる。

Print “Press any key to clear the screen and paste some more text”
Wait key
Cls
Print “Ta Da!”
Wait key

That code should print some text, then when you press a key, clear the screen and write a new line of code.
そのコードは若干のテキストをプリントしなければならない、それからあなたがキーを押すとき、スクリーンをすっきりさせて、1行の新しいコードを書きなさい。
When the command CLS is used, the cursor is reset to 0,0.
命令 CLSを使う、カーソルは0,0にリセットされる。

Now how about some colours to liven things up?
現在、ものを活気づける色数はどう?

Ink rgb(255,0,0),0
Print “Red text!!!”
Wait key

Now, this may just look like 1 command to you, but in actual fact it is comprised of 2 commands, INK and RGB().
現在、ちょうど1つの命令があなたに実際には、それが2つの命令から成る、INK、そして、RGB()。
INK sets the foreground and background colours, the foreground being text (and shapes, which we will come on to), and the background being the background (duh!).
インクは、前景と背景色をセットする。テキストである前景(そして、我々が言及する形)、そして背景の色。

DBPro uses numbers to represent its colours, for example 4294967040 is red, and 4294967040 is yellow, but who wants to remember all the numbers for every colour (remember you can have different shades of red and yellow as well)?
DBProは、色番号をその色を表すのに用いられる、たとえば、4294967040は赤い、そして、4294967040は黄色である、しかし、誰があらゆる色のために全ての数を覚えていたいか?(あなたが同様に赤と黄色の中間色を持つことができるのを思い出す)
No?
いいえ?
Well that’s why we use the RGB() command, it changes colours that we recognise, into colours that DBPro recognises.
かなりそういうわけで、我々はRGB()命令を使う。それは、DBProが認識する色に、我々が認識する色を変える。
All colours on a computer are made up of the three primary colours of light (red, green and blue, hence RGB()), as you may already know.
あなたがすでに知っているかもしれないように、コンピュータの全ての色は光の3つの原色から成り立つ。(赤、緑、青、それゆえに、RGB())
You can input different amounts of each colour into the command, up to 255 for each colour.
あなたは、命令(各々の色のための最高255)に、各々の色の異なる量を入力することができる。
So red is (255,0,0), green is (0,255,0) and blue is (0,0,255).
赤がある(255,0,0)ように、緑はある(0,255,0)、そして、青はある(0,0,255)。
You can also combine the colours to make something like yellow - (255,255,0).
あなたは、何かを黄色 ― (255,255,0) ― を好ませるために、色を結合することもできる。
I don’t use an RGB() command for the background, I just use 0 as that is the DBPro number for black.
私はRGB()命令を背景の為に使わない。それが黒のためのDBPro番号であって、私はちょうど0を使う。
Here are some useful colours you may want to remember.
あなたが覚えていたいかもしれない若干の役に立つ色は、ここにある。

Red = 255,0,0
赤い= 255,0,0
Green = 0,255,0
緑の= 0,255,0
Blue = 0,0,255
青い= 0,0,255
Yellow = 255,255,0
黄色の= 255,255,0
Orange = 255,100,0
オレンジの= 255,100,0
Purple = 200,0,255
紫の= 200,0,255
Pink = 255,0,200
ピンクの= 255,0,200
Brown = 150,100,0
茶色の= 150,100,0
Black = 0,0,0
黒い= 0,0,0
White = 255,255,255
白= 255,255,255
Grey = 150,150,150
灰色= 150,150,150

Using CLS will re-colour the background in your specified colour (this doesn’t work in U5 but may work in later versions of DBPro).
色に関してCLSを使うことは、あなたの指定された色の背景で再び塗る事である。(これはU5で働かなくて、DBProの後のバージョンで働くかもしれない)

Summary of Commands

命令の概要

· PRINT text - Pastes the text onto the screen

  • PRINTテキスト-スクリーンの上にテキストを貼り付けする

· SET CURSOR x,y - Sets the position of the PRINT cursor

  • SET CURSOR x,y-プリントカーソルの位置を決める

· CLS - Clears the screen of all text

  • CLS - 画面の全てのテキストを片づける。画面消去。

· INK bgCol,fgCol - Sets the background and foreground colours, use in conjunction with RGB()

  • INK bgCol,fgCol-背景と前景が色づける設定、RGB()とともに使用

· RGB(r,g,b) - Converts 255,255,255 colour into DBPro colour code

  • RGB(r,g,b)-255,255,255色をDBPro色コードに変える

· WAIT KEY - Pauses at that line of code until a keyboard key is pressed

  • WAIT KEY ― キーボード・キーが押されるまでコードのその行での休止

End of Section Tasks

セクション終わりの作業

l Experiment with combining the PRINT, SET CURSOR, CLS and INK commands to see the different effects.

  • 異なる影響を見るために PRINT, SET CURSOR, CLS and INK命令を結合することで実験しなさい。