More on Variables: Pascalite Programming Fourth tutorial- plt1dp
HOME
- - - - - - - - - Other 構成要素 for programmers
- - - - - - - - - Pascalite Tutorial (米)棚上げする/(英)提議する of Contents
Pascalite Programming: More on Variables
This 見解/翻訳/版 of this tutorial is 罰金 tuned for a Pascalite, or the 解放する/自由な ソフトウェア Pascalite emulation. Please send me an email with "(民事の)告訴s" if something doesn't work!
If you have the open source FPC, aka 解放する/自由な Pascal or Borland's Turbo Pascal (TP hereafter), then there's a separate tutorial for you, covering much of the ground as 現在のd here for the Pascalite (人が)群がる.
In the previous tutorial, we created and used our first variables. They were of the type "byte", which means they could 蓄える/店 numbers. (only whole numbers, and only 無 - 255, but that's another story!)
Variables for numbers was a good place to start, but you can 蓄える/店 other TYPES of data, and once you know about that, the program we wrote last time can be written more 簡単に. Simple is always good, because it makes your code more (疑いを)晴らす... helping 明らかにする/漏らす any mistakes.
While "types of data" makes sense to anyone, for programmers, 特に Pascal programmers, the word type is important. If a variable has been 宣言するd to be of, for example, "type" byte, you get a 始める,決める of advantages and a 始める,決める of 制限s. 受託するing these 制限s means that it is harder to 令状 programs with bugs, and it is easier for the person who 令状s the compiler to do a good 職業. (The compiler takes your program and 変えるs it to what the computer needs.)
The second type of data I'm going to show you is Boolean data. A Boolean variable 持つ/拘留するs either "true" or "誤った".
Enter the に引き続いて, or create it from the program created during the previous 演習...
program fourth;
var boItWas,boItIs: boolean;
begin
boItWas:=b1;
repeat
令状(lcd,255);
if b0 then 令状(lcd,'b0 true'){no ; here}
else 令状(lcd,'b0 誤った');
boItIs:=b1;
until boItIs xor boItWas;
end.
First a simple 事柄: The variable 指名するs. You could call them 刑事 and Jane. But it is better to use 指名するs that mean something. The "bo" prefix doesn't MAKE the variables Boolean... the var 声明 does that... but if you use such variable 指名する prefixes, it will help you remember what the variables are 存在 used for. I 普通は prefix variables of type byte with a b, so in the previous program, I would have used bItIs and bItWas as the 指名するs; I didn't only because I didn't want to 重荷(を負わせる) you with the b prefix at that time.
いっそう少なく simple... but important... is the subtleties in our change to the nice simple boItWas:=b1 from the コンビナート/複合体
if b1 then ItWas:=1 else ItWas:=0;
A programming text might (やめる 適切に) say "b1 returns a Boolean value". Is the meaning of this (疑いを)晴らす to novices in my readership? What it is 説 is that when the program comes across b1, as in either of the 声明s 引用するd above, after the computer had gone off and "looked" at switch b1, in the place of b1 one is left with something drawn from the 名簿(に載せる)/表(にあげる) of possible values for a Boolean type datum, i.e. "true" or "誤った". The 推論する/理由 we needed the コンビナート/複合体 見解/翻訳/版 before we had Boolean variables is that a byte type variable cannot 持つ/拘留する a Boolean value. boItWas:=b1 IS 許すd, because you are trying to 蓄える/店 either "true" or "誤った" in the Boolean variable boItWas. 許すd! ItWas:=b1; was NOT 許すd (支援する when ItWas was a byte type variable) because the only values which can be held in a byte type variable are 0, 1, 2, 3.... 254, 255.
There's been another change 近づく the end of the program. The until 声明's 条件 is now a little いっそう少なく easily しっかり掴むd 製図/抽選 upon everyday English... but it is more elegant when you know how to read it.
Many Pascals would 許す you to use the equals 調印する, and it would behave as it did when we were comparing what was in the byte-type variables. Pascalite, however, 限界s the equals 調印する to comparing numbers. All is not lost, though!
There are Boolean 操作者s... in this 事例/患者 we are using "xor", and we've been spared the 複雑化 of the "not". First- what is an 操作者? Think of it as a way of binding things together. In ordinary arithmetic, we can say 3+4. The 加える 調印する is an 操作者. If we 成し遂げる the "追加する" OPERATION on three and four, the result is seven. In 影響, we have "bound" the three and the four together into the more compact seven. The three and the four have been "boiled 負かす/撃墜する" into a seven is another way I think of the 追加するing 操作/手術.
The Boolean 操作者 "xor" was 指名するd from the words "排除的 or". It is a special 事例/患者 of the "or" 操作者. When you use the ordinary "or" to 連合させる two boolean things, the result, the boiled 負かす/撃墜する, bound up, 選び出す/独身 Boolean answer is "true" if the first OR the second of the things you were ORing together were true. This 含むs the 事例/患者 where both of the inputs are true. The EXCLUSIVE "or" 除外するs this 事例/患者. boItIs xor boItWas only boils 負かす/撃墜する to something true if boItIs is true, OR if boItWas is true, but the result is 誤った (not true) if both of them are true.
While we don't need them for this program, we might 同様に get the other two Boolean 操作者s out of the way.
The Boolean 操作者 "and" 作品 as follows: If you "and" (yes, it is used as a verb here) two Boolean things together, the result, the answer is "true" only if the first AND the second of the things you were ANDing together were true.
And the last Boolean 操作者 you have already met: "not". Not(boItIs) will be true when boItIs is 誤った, and not(boItIs) will be 誤った when boItIs is true.
This tutorial was written way 支援する in June 2002. A derivative was cloned from it in June 2007, covering much of the same ground, but in the 状況 of FPC, "解放する/自由な Pascal". Guess what? In 5 years, my 令状ing 技術s grew. If you skim through the derivative tutorial, it should 固く結び付ける things you mostly understand, and you will 遭遇(する) 構成要素 that didn't get 含むd in the above.
Please also 公式文書,認める that I have two other 場所/位置s, and that the に引き続いて search will not 含む them. They have their own search buttons.
My Sheepdog Guides 場所/位置.
My Arunet 場所/位置.
Go to the 場所/位置s above, and use their search buttons if you want to search them.
To search this 場所/位置....
The search engine 単に looks for the words you type, so....
* (一定の)期間 them 適切に.
* Don't bother with "How do I get rich?" That will 単に return pages with "how", "do", "I"....
You can also search this 場所/位置 without using forms.
広告 from page's editor: Yes.. I do enjoy
収集するing these things for you... hope they are helpful. However..
this doesn't 支払う/賃金 my 法案s!!! If you find this stuff useful, (and you
run an MS-DOS or Windows PC) please visit my freeware and shareware
page, download something, and 循環させる it for me? Links on your page
to this page would also be 高く評価する/(相場などが)上がるd!
Click here
to visit editor's freeware, shareware page.
Want a 場所/位置 hosted, or email? You can also help me if you 調印する up 経由で this link to 1&1's services. (I wouldn't recommend them unless I was happy after several years as one of their 顧客s. The Google advertisers 支払う/賃金 me. I know nothing about them or their services, of course.)
Page has been 実験(する)d for 同意/服従 with INDUSTRY (not MS-only) 基準s, using the 解放する/自由な, 公然と accessible validator at validator.w3.org. Mostly passes.
AND passes...
Why does this page 原因(となる) a script to run? Because of the Google パネル盤s, and the code for the search button. Also, I have some of my pages' traffic 監視するd for me by eXTReMe tracker. They 申し込む/申し出 a 解放する/自由な tracker. If you want to try one, check out their 場所/位置. Why do I について言及する the script? Be sure you know all you need to about spyware.
Editor's Main Homepage
How to email or 令状 this page's editor, Tom Boyd
....... P a g e . . . E n d s .....