|
このページはEtoJ逐語翻訳フィルタによって翻訳生成されました。 |
If you have a Pascalite, or the ソフトウェア emulation, then there's a separate tutorial for you, covering much of the ground as 現在のd here for the FPC/ TP (人が)群がる.
program second;
uses crt;
begin
ClrScr;
repeat
writeln('Hi');
until 4=5;
end.
For FPC, you can copy that from here by selecting it and 圧力(をかける)ing ctrl-C in the usual way. Within FPC 接近 Edit from the menu, and select the "Copy from Windows" 選択 近づく the 底(に届く) of the 名簿(に載せる)/表(にあげる). Also: Within FPC, the keyboard shortcut for 削除するing a selected 封鎖する of text is ctrl-削除する.) You can probably do something 類似の under TP, but I 港/避難所't run the 実験(する)s yet. 実験!
When you've entered the code, first save what you've entered. Remember that...
"Second" would be a good 指名する to use for saving this program. (You can put all these little programs from the tutorials in a 株d folder), then run the program. You should get a 黒人/ボイコット 審査する with white 令状ing 説 "Hi" on every line. You won't go 支援する to the editor 審査する, as before, because the program you started is still running. It will run forever. This is called an infinite 宙返り飛行, and is 一般に thought to be a Bad Thing.
Before "ctrl-alt-削除する" became the elephant gun that would kill most rogue 過程s, ctrl-C and ctrl-Break were popular, and it is the latter we need here. (The "Break" 重要な is usually also the "Pause" 重要な, and is usually at the extreme upper 権利 of the keyboard. To the left of the numeric keypad, but above it. At the 権利 手渡す end of the 列/漕ぐ/騒動 of 機能(する)/行事 重要なs.
圧力(をかける) ctrl-break to ひったくる your computer 支援する from the infinite 宙返り飛行 which you created. The Good News is that it will get your computer 支援する. The Bad News is that FPC will be shut 負かす/撃墜する, 同様に. (I have at some 未来 date to check the exact 業績/成果 of TP in this regard. For now, 実験! I'm sure you'll find what you need.)
再開する FPC. Sorry. We'll try to 避ける infinite 宙返り飛行s in the 未来! You may find that FPC comes up with the program you were working on 支援する in the edit window. If not, re-負担 it. (You did save it, didn't you?)
Two 詳細(に述べる)s: The ClrScr clears the 生産(高) screen. Without it, you would see "stuff" left over from starting up your Pascal, and, when you are getting more proficient, "stuff" left from previous runs (in the 現在の 開会/開廷/会期) of the compiler. The uses crt line tells your Pascal to 負担 a "部隊" (more on that, much later). 部隊s are "libraries" of code for things that you don't need in every program. The ClrScr 命令(する) is part of the Crt 部隊, so when you want to use ClrScr, you have to tell your Pascal to "use" the Crt 部隊, so that your Pascal will have the necessary code for ClrScr. ("Code" here as in "computer 指示/教授/教育s", not as in "secret code").
The word Repeat is one of the rare instances of something that is not followed by a semicolon. It is like Begin, which was discussed in the first tutorial. "Repeat" is always paired with an Until. The Until is always followed by something which is either true or 誤った. The "something" is called a 条件, in this 事例/患者 "4=5". 4 doesn't equal 5, of course, so the 条件 is always 誤った. You will soon 会合,会う more コンビナート/複合体 (and sensible!) 条件s. (People with some experience of programming may wonder why I didn't say "until 誤った". I find that beginners are often thrown by "Until 誤った". "Until 4=5" is more intuitively something that hasn't happened, so the until is unsatisfied.)
Our program, because of the "repeat/ until" pair will 成し遂げる the "writeln('Hi');" 指示/教授/教育 over and over again. As I said, this is called an infinite 宙返り飛行. 宙返り飛行s are powerful and useful, though you rarely make infinite 宙返り飛行s... on 目的! Some bugs are based on inadvertent infinite 宙返り飛行s.
修正する the program so that it says
program second; uses crt; begin repeat ClrScr; 令状(lcd,'Hi'); until 4=5; end.
The word "repeat" has been moved up one line. You can make the modifications "by 手渡す" (削除するing and re-typing), or you can do them by selecting the text, doing 転換-削除する, moving the cursor and doing 転換-挿入する. 転換-削除する is the ctrl-X of this 環境, 転換-挿入する the ctrl-C.
When you've made the change, re-save the program and re-run it. It almost looks as though "nothing" is happening. Depending on さまざまな things, the "Hi" may appear and disappear, and we didn't 逆戻りする to the edit 審査する, as you "should have".... but that's not much, is it? 非,不,無-the-いっそう少なく, the program is doing ClrScr / writeln('Hi'); over and over again. Notice the big 影響 on the results that arises from moving the "repeat" just one line. You should be able to see why the program behaves 異なって. I'm afraid you'll have to kill your Pascal with ctrl-break again, and re-start it again.
At this point, the FPC/ TP 見解/翻訳/版 of these Pascal tutorials takes やめる a different path from that taken by the Pascalite 見解/翻訳/版. Pascalite, 存在 written for a 明確な/細部 piece of 金物類/武器類, has a few special features not 設立する in more general Pascals. As the 金物類/武器類 is a microcontroller, the usual way you give it input is more basic than is usual on a PC. The Pascalite tutorials were able to defer talking about input, and we can't. It isn't a big 取引,協定, though.
Change the program to what follows. You may have to re-size your browser window to see all of every line....
program second_V2;
uses crt;
var sTmp:string;
begin
ClrScr;
repeat
writeln('圧力(をかける) a 重要な, and then 圧力(をかける) the "Enter" 重要な');
readln(sTmp);
if sTmp='X' then writeln('Bye')
else writeln('圧力(をかける) X to eXit program. (It must be an upper 事例/患者 X).');
until sTmp='X';
end.
Save this. I'd 示唆する "Second_v2" as the 指名する. In general, keep 指名するs short, and without any spaces. Also, it is best to use what is on the "program..." line of the sourcecode as the 指名する with which the program is saved. The 指名する in the sourcecode can't have hyphens, so either CombineWordsWithoutSpaces or use_the_underscore.
Run the program. You should get a message telling you what to do. We'll look at the code in 詳細(に述べる) in a moment. 圧力(をかける) any 重要な except X, and then 圧力(をかける) the "Enter" 重要な. You should get the message again. Enter another 重要な, and you get the message again... and again... and again. This is a 宙返り飛行! (This lesson is supposed to be about 宙返り飛行s, after all!) But! This is not an infinite 宙返り飛行. 圧力(をかける) an uppercase ("資本/首都") X, and you may see "Bye" 簡潔に (or the 審査する may go away before you can perceive the "Bye") and the program will end, putting you 支援する in the FPC/ TP editor 審査する.
I hope that if you work through the code, what is going on is not too hard to discern? 非,不,無- the- いっそう少なく, read what follows carefully, to learn about a few 半端物s and ends
"Var" is a Pascal word. It says we are about to "宣言する" some "variables". You will see var 声明s in many places within a program. The "sTmp" after var is a 指名する we made up. We are 宣言するing a "new word", for use in this program. We can be pretty inventive with our 指名するs, but...
There may be one or more 指名するs, separated by commas, after the "var", but 結局 there must be a 結腸, and after the 結腸 the 指名する of a "type" known to Pascal. "Type" is a big topic, which you will master 徐々に. For now, all you need to know is that "string" is a good type for sTmp. (And its 指名する is the 推論する/理由 we used "s" for the first letter of sTmp.)
"var sTmp:string;" created a variable (more in a moment) called sTmp, a variable 有能な of 持つ/拘留するing "string" type data. ("String type data" is data consisting of one or more characters in a string. Examples: "abc", "Fred", "123"... or even "234QEWFQ#$" !) You must always "create" ("宣言する" is the 称する,呼ぶ/期間/用語 usually used) variables before you use them.
When the program 遂行する/発効させるs this line, it will sit and wait until the 使用者 types something, and 圧力(をかける)s the "enter" 重要な. Once that has happened, sTmp will "持つ/拘留する" whatever the 使用者 typed. That's what variables are for: They "持つ/拘留する" things. We'll see what that's good for in a moment.
What, on the page, is two lines (or more, depending on your browser window).....
if sTmp='X' then writeln('Bye')
else writeln('圧力(をかける) X to eXit program. (It must be an upper 事例/患者 X).');
... is, as far as Pascal is 関心d, one line.
In essence, that line is....
IF (something) THEN (do this) ELSE (do that)
This is a tremendously powerful 声明, but it does take some explaining.
The "something" part must be "a 条件". A 条件 is something that is either true or 誤った. In our little demonstration program, the 条件 is....
sTmp='X'
this is not going to make sTmp equal X; it is asking "Does sTmp 持つ/拘留する the letter X?"
Does it? That depends on what we typed when the program (機の)カム to the readln 声明. What we put into the variable sTmp then is what the computer compares to "X" now. (公式文書,認める: We are not doing anything mathematical or clever here. We don't mean "x" as in algebra, e.g. as in "y=mx+c".)
Another aside: be careful with 引用するs. Pascal distinguishes between 選び出す/独身 引用するs ('s) and 二塁打 引用するs ("s). (You will いつかs even 遭遇(する) 二塁打 選び出す/独身 引用するs (''), but we 港/避難所't had any of them... yet!) Pascal is fussy. In general, it wants 選び出す/独身 引用するs.
支援する to the if... then... else...
If the 条件 is true, then the computer will do what is 示すd as "something" above. In the program we are discussing, what the computer does is....
writeln('Bye')
On the other 手渡す, if the 条件 is not true, then the computer will do what is 示すd as "do that" above. In the program we are discussing, what the computer does is....
writeln('圧力(をかける) X to eXit program. (It must be an upper 事例/患者 X).')
公式文書,認める that there is only one semicolon for this whole, 論理(学)の, line... at the end. Semicolons are the "glue" between 声明s. In particular, there is no semicolon before the "else".
Another thing to notice: the word "then" has at least two meanings in English. It can be a 事柄 of sequence: I put on my socks, THEN I put on my shoes. Or it can be a 事柄 of consequence: If you eat three pizzas, THEN you will be sick. While sequence comes into that, too, I hope you'll see the more 重要な "consequence" element. In programming, "then" is used in the consequence sense.
Time to talk about 贈呈. 公式文書,認める how I have indented the second part of the "if... then... else... 声明. The indent is optional, but it makes reading through your program easier, because it 強調するs the fact that the "else..." stuff is just a 延長/続編 of what started on the previous line. 公式文書,認める that I've used indenting to 強調する other elements of the program's structure, too, for instance the extent of the repeat... until 宙返り飛行.
Let's talk some more about where 半分-結腸s go. That is linked to "What is a 声明?" The 概念 of 声明s is important in Pascal, and gets subtle in more コンビナート/複合体 事例/患者s. The big thing to notice here is that there is no semicolon before the else. The 概念 of 声明s is a little like the 概念 of 宣告,判決s in everyday English. Both of the に引き続いて are valid (関わりなく where you break the lines, as in Pascal), and 類似の to 選び出す/独身 声明s in Pascal:
I will go to town.
I will go to town if it is raining.
It is incorrect to 令状:
I will go to town. If it is raining.
Pascal's semicolon is a bit like English's period (十分な stop). Because so many lines in Pascal end with a semicolon, and because putting one before an "else" 原因(となる)s problems, and because if...then...else 声明s are usually 分裂(する) across two (or more) lines, I still enter 類似の lines in my programs as follows:
if sTmp='X' then writeln('Bye') //no ; here
else writeln('圧力(をかける) X to....
The text after the "//" is ignored by Pascal. The chance to 追加する comments thus can be a real help to the programmer. Comments are also called 発言/述べるs, or rems. Multi-line comments can be written thus...
(*This is a rem that 分裂(する)s across two lines*)
... or
{This is a long comment:
0: 無
1:one
2:two
... etc}
|
|
Page has been 実験(する)d for 同意/服従 with INDUSTRY (not MS-only) 基準s, using the 解放する/自由な, 公然と accessible validator at validator.w3.org. Mostly passes.
....... P a g e . . . E n d s .....