このページはEtoJ逐語翻訳フィルタによって翻訳生成されました。

翻訳前ページへ


Arrays in Pascal Programming- plt1gf HOME - - - - - - - - - Other 構成要素 for programmers - - - - - - - - - Pascalite Tutorial (米)棚上げする/(英)提議する of Contents

Pascal Programming: Arrays

This 見解/翻訳/版 of this tutorial is 罰金 tuned for the open source FPC, aka 解放する/自由な Pascal. Most of what you read here should also 直接/まっすぐに 適用する if you are using Borland's Turbo Pascal (TP hereafter). It is also 利用できる for 解放する/自由な. Please send me an email with "(民事の)告訴s" if something doesn't work!

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 special place to keep things: Arrays

Before I say what I'm about to, I will say: This tutorial will develop a program which will work with FPC or Turbo Pascal. Now that's out of the way, I come to: Be sure to look at the previous tutorial before 試みる/企てるing this one. (In the previous tutorial, you could only read about something the Pascalite people could do.) In it we looked at using a computer to 記録,記録的な/記録する the activity of a hamster. The "For... To... Do..." 声明 was introduced. In this tutorial we are also going to 跡をつける some events, and will 会合,会う arrays for the first time. They are a special type of data, or a special sort of variable, if you prefer to think of them that way.

This might have left for "Level 2" of the tutorials, but it introduces a 根底となる programming 道具: arrays.

The program we will make could be used for a traffic 調査する. By "traffic 調査する", I mean the 演習 in which someone sits at a 道端 for an hour and counts how many motorbikes, how many 2-door sedans, how many 4-door sedans, and how many 非,不,無-of-the-above 乗り物s pass by. 明白に, such a program could be adapted to many other uses.

As developed here, the program will have a lot of 使用者 unfriendliness. There are lots and lots of things which you would do to it if it were really going to be used for traffic 調査するs... but for the 目的s of the tutorial, the に引き続いて is uncluttered.

The program will be used as follows: 使用者s will start it, at which time they will see "Enter 1, 2, 3, 4, or 99, and 圧力(をかける) enter." They will enter 0 if they see a motorbike, 2 or 4 for a 2 or 4 door sedan, 3 for an "other" 乗り物, and 99 to やめる the program. They will see running subtotals of the 乗り物s seen.

It always 支払う/賃金s, by the way, to 令状 out a description like the above before you start 令状ing a program.

We've already looked at simple variables. They 許す us to keep things so that we can 言及する to them. Now we're moving on to arrays. Like a simple variable, they are a place for keeping something. In 新規加入 to the 特徴 of a simple variable, they 許す us extra ways, clever ways, to 明示する which piece of (警察などへの)密告,告訴(状) we want. Type in the に引き続いて. Notice there is lots of 範囲 for using copy/ paste to 減少(する) typing and 増加する 正確.

Don't let the blank lines 混乱させる you... You can always put them in where ever you want to ーするために help make 論理(学)の 封鎖するs of the program show up. The indenting is there for the same 推論する/理由.

program Traffic;
uses crt;

var sTmp:string;
      bSeen:array [1..4] of byte;//**

begin

bSeen[1]:=0;//Put 無 in each of the subtotals //**
bSeen[2]:=0;//**
bSeen[3]:=0;//**
bSeen[4]:=0;//**

clrscr;
repeat
   writeln('Seen so far: Motorbikes:',bSeen[1],
             '  Two doors:',bSeen[2],
             '  Four doors:',bSeen[4],
             '  Other:',bSeen[3]);//**

   writeln('Enter 1,2,3,4 or 99');
   readln(sTmp);
   if sTmp='1' then bSeen[1]:=bSeen[1]+1;//**
   if sTmp='2' then bSeen[2]:=bSeen[2]+1;
   if sTmp='3' then bSeen[3]:=bSeen[3]+1;
   if sTmp='4' then bSeen[4]:=bSeen[4]+1;

until sTmp='99';

writeln;
writeln('Bye. Make a 公式文書,認める of your subtotals! THEN 圧力(をかける) the "Enter" 重要な.');
readln;
end.

That's all there is to it! I've 示すd lines you should 公式文書,認める 特に carefully with //**s. As I said, it could be done fancier, it could be done better... but what we have so far WORKS, and it shows you an array (bSeen) in 活動/戦闘. Now we'll talk about it a bit.

Our program uses the array bSeen. bSeen 供給するs four places to 蓄える/店 a byte. A particular one of them, say bSeen[2], is called "an element of the array". In the program in the tutorial we 港/避難所't taken advantage of the 力/強力にする of arrays... we could have done what we've done so far with four variables 指名するd bSeen0, bSeen1, bSeen2 and bSeen3. For a very modest example of the 力/強力にする of arrays, let's go 支援する to the start of the program, 支援する to the part that initializes each element of bSeen to 無. We had....

bSeen[0]:=0;
bSeen[1]:=0;
bSeen[2]:=0;
bSeen[3]:=0;

Remember the important "For... To... Do..." 声明 we met in the previous tutorial? If we 単に 追加する "bTmp:byte" to the variables 宣言, we can 取って代わる the four lines above with:

for bTmp:=1 to 4 do bSeen[bTmp]:=0;

Look at that closely; make sure you see what it's doing, why it 達成するs the same thing that the previous answer 達成するd. It may not see very impressive. However, consider what an 改良 it would be if 150 bSeen elements had to be initialized! And there are more subtle things that you can do which can only be done through the 力/強力にする of arrays.

And so to bed! Unless you want to go 支援する to the (米)棚上げする/(英)提議する of contents for another one? :-)




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 場所/位置....

Search this 場所/位置 or the web 力/強力にするd by FreeFind

場所/位置 search Web search
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.)



Valid HTML 4.01 Transitional Page has been 実験(する)d for 同意/服従 with INDUSTRY (not MS-only) 基準s, using the 解放する/自由な, 公然と accessible validator at validator.w3.org. Mostly passes.

AND passes... Valid CSS!


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 .....