|
このページは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 (人が)群がる.
許す a nostalgic digression? As I start this tutorial, I must just 支払う/賃金 homage to Per Ranhoff. I can remember 驚くべき/特命の/臨時の 詳細(に述べる) of a day in the late sixties when I age 15, I was sitting in my first computer lesson. Per started us off with the 概念 of variables. The 明確な/細部 machine he was showing us how to use was the same PDP-8 that he- who- would- become technical director of "Toy Story" started his programming on. But I played with it first! So what have I done?
So much for nostalgia.. 負かす/撃墜する to work....
Inside the computer, at one level, everything is numbers. You don't always have to work at such a low level... in the previous tutorial (which you should read before 試みる/企てるing this one), we made a Pascal program 陳列する,発揮する "Hi" without having to worry about the fact that the code for H is 72 and the code for i is 105, for instance.
Given that there are numbers 伴う/関わるd, whether we worry about what they are, or 単に use them to 生成する text, it follows that they must 存在する somewhere. Where they are is, again "at one level", the essence of variables.
Suppose you were 令状ing a programme to calculate the 税金 payable on some 処理/取引. You would need to have the 税金 率 利用できる to your program. It could be 蓄える/店d in a variable.
We're not going to 試みる/企てる to calculate 税金s. We are again going to 簡単に 蓄える/店 strings of characters in variables.
In the に引き続いて program, when it starts, the 使用者 will type in a short word. That will be 蓄える/店d in a variable, and then disappear from the 審査する. The program will then enter a 宙返り飛行, and 出口 only when the 初めの "short word" has been entered again. Think of it as a password for quitting the program. Useless program? Perhaps... but something like it could be part of a program that a teacher wants to start on a classroom machine, and the teacher doesn't want pupils stopping the program.
Here's the finished program. Type it in, get rid of any error inducing typos, play with it. In a moment I'll take you through the new stuff. Try to 人物/姿/数字 out what's happening by yourself.
program Third;
uses crt;
var sItWas, sLatest:string;
begin
ClrScr;
writeln('Type a short word, then 圧力(をかける) the "Enter" 重要な.');
writeln('This will 始める,決める the password to be matched later.');
readln(sItWas);
ClrScr;
repeat
writeln('Type the password again to leave this 宙返り飛行, or');
writeln('type something else. In either 事例/患者, then');
writeln('圧力(をかける) the "Enter" 重要な');
readln(sLatest);
if sLatest=sItWas then writeln('Bye') //no ; here
else writeln('No, that was not the password.');
writeln;//this 原因(となる)s a blank line.
until sLatest=sItWas;
writeln('圧力(をかける) the "Enter" 重要な to end the program.');
readln;//see 公式文書,認めるs
end.
See what's going on?
You can 述べる it on two levels. Such descriptions are called documentation, and you'll need to do documentation to get very far in programming.The deeper level is programmer's documentation. For our little program, it could be....
Notice: The second line of the program: "Var" is a word built into Pascal. It says we're going to "宣言する" some variables. We can't ever use variables unless we've 宣言するd them first. Happily, 宣言するing them is no big 取引,協定. The variables we want are entered after var. There are all sorts of 支配するs about what 指名するs are 許すd. For now:
a) Don't try to use a word that is a built in word of Pascal, e.g. repeat, var, begin, then, etc.
b) Start the 指名する with a letter.
c) Make the 残り/休憩(する) of the 指名する out of letters or digits only. Don't use punctuation 示すs, nor spaces.
"sItWas" and "sLatest" are both variables, both 指名するs made up by me for this program.
After the last variable in the 名簿(に載せる)/表(にあげる) you are 宣言するing, you need a 結腸, then a word to say what TYPE of variable they are to be (more on this in a moment) ("string" is a built in word of Pascal for one of the 許すd data types) and finally, as is (almost) always true, the line ends with a semicolon.
公式文書,認める that the variable 宣言 goes after the "program..." line, but before the program's main "begin".
I hope the 残り/休憩(する) of the program is self evident. More explaining by me at this point may just give you a 頭痛. Before reading on, have a hard look at the program. Try to make sense of what's going on for yourself.
Still not (疑いを)晴らす? The thing that you should get straight is why the program stops 宙返り飛行ing when you type the 権利 thing in at the "readln(sLatest);" line.
Until the two variables, sItWas and sLatest, do not both 持つ/拘留する the same string of characters, the program obeys the "until...", and 宙返り飛行s 支援する. When what's in sLatest is finally changed to what's in sItWas Pascal STOPS 宙返り飛行ing 支援する to the "repeat", because the "until" 条件 is now true. The に引き続いて isn't a real program, but perhaps it will 増強する what you've learned about the repeat... until 宙返り飛行:
program Life; begin repeat Work until YouAreRichEnoughToRetire; EnjoyYourHobbies; end.
A little thing to notice: Notice the "readln" 近づく the end of the program. A readln like that can be useful to let you see what is on the 生産(高) 審査する just before the program ends.
We're now going to make a few 新規加入s to the program, to see a variable 持つ/拘留するing a number. Make the program...
program Third_v2;
uses crt;
var sItWas, sLatest:string;
iCount:integer; //** 1
begin
ClrScr;
iCount:=0; //** 2
writeln('Type a short word, then 圧力(をかける) the "Enter" 重要な.');
writeln('This will 始める,決める the password to be matched later.');
readln(sItWas);
ClrScr;
repeat
iCount:=iCount+1; //** 3
writeln('You have gone through the 宙返り飛行 ',iCount,' times.'); //** 4
writeln('Type the password again to leave this 宙返り飛行, or');
writeln('type something else. In either 事例/患者, then');
writeln('圧力(をかける) the "Enter" 重要な');
readln(sLatest);
if sLatest=sItWas then writeln('Bye') //no ; here
else writeln('No, that was not the password.');
writeln;//this 原因(となる)s a blank line.
until (sLatest=sItWas) or (iCount>5); //** 5
writeln('圧力(をかける) the "Enter" 重要な to end the program.');
readln;
end.
I've 示すd each new line with a rem starting "//**".
At the first, we see another variable 宣言するd. 公式文書,認める that we don't need to repeat the "var" word, as long as the new 宣言 follows another one.
The type of iCount is "integer", which means we can 蓄える/店 whole numbers, but not fractions, and not 非,不,無-digit characters in the variable.
At //**2 we initialize the variable. iCount will 持つ/拘留する some number at this point, but you can't be sure what it is. It is always wise to initialize variables. 公式文書,認める the "assignment 操作者", which is a 結腸 followed by an equals 調印する. (":="). It is best, in your Pascal life, to think of this as a new "character". When you see "iCount:=1", instead of 説 "iCount equals 1", say "iCount becomes 1", or "the variable called iCount has a 1 蓄える/店d in it."
In some program or other, you could see "iCount=1" (公式文書,認める the absence of the 結腸). This would be a 条件 (We've met them before.) "iCount=1" boils 負かす/撃墜する to "true" or "誤った" depending on what was most recently 蓄える/店d in the variable called iCount. You might come across a line 説....
if iCount=1 then writeln('The variable iCount is 現在/一般に 持つ/拘留するing the number 1.');
Just take care to keep assignments to iCount ("iCount:=1") separate in your mind from 条件s, e.g. iCount=1. If you read the ":=" as "becomes", it will help you.
Moving on through our demonstration program....
At //** 3 we have
iCount:=iCount+1; //** 3
If you really took in what you've been told recently, this will come as no shock. We are changing what is in the variable iCount. "iCount becomes what was in iCount 以前, 加える one." So iCount, after this line 遂行する/発効させるs for the first time, 持つ/拘留するs 2.
At //**4....
writeln('You have gone through the 宙返り飛行 ',iCount,' times.');//**4
We've seen writeln before... but notice that now we're not just sending text to the 審査する, but we're also fetching something out of the variable iCount, and putting that on the 審査する to.
At //**5....
until (sLatest=sItWas) or (iCount>5); //**
.. we've 追加するd a second way for the "until" to be 満足させるd. Because of this, in conjuction with the iCount:=iCount+1; inside the 宙返り飛行, even if you've forgotten what you 初めは entered, you will 結局 出口 the 宙返り飛行.
You've done it! You've reached a good place to take a break. Come 支援する and do another tutorial from the series いつか soon!
|
|
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 .....