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

翻訳前ページへ


使用者 Defined 手続きs: part 1, Pascalite Programming- plt1hp HOME - - - - - - - - - Other 構成要素 for programmers - - - - - - - - - Pascalite Tutorial (米)棚上げする/(英)提議する of Contents

Pascalite Programming

使用者 Defined 手続きs: Part 1

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 (人が)群がる.



If you click on the Help menu item of the Pascalite ソフトウェア, and from there click on contents, then "programming language", and then "reserved words", you will, I hope, be impressed by all of the words that the language can 答える/応じる to already.

Nonetheless, in the course of many 事業/計画(する)s, you will find yourself feeling that その上の words would be useful. Our first example is going to look trivial, but please 耐える with me for a moment.

In an 早期に tutorial we had the に引き続いて program:
program hi;
begin
if b0 then 令状(lcd,'Hi') else 令状(lcd,'Bye');
end.
I hope that is pretty transparent in most 尊敬(する)・点s?. For those who've come to this without seeing the earlier tutorials, the "if b0" part will be true if a switch on the Pascalite is in one position, 誤った if it is in the other position.

If you knew about 使用者-defined 手続きs, you could 達成する the same result with... (don't try to run it, yet, by the way)
program hi;

   手続き SayHi;
     begin
     令状(lcd,'Hi');
     end;

   手続き SayBye;
     begin
     令状(lcd,'Bye');
     end;

begin
repeat
if b0 then SayHi else SayBye;
until 4=5;
end.
At first ちらりと見ること, this might not seem an 改良.... but once you know your way around the basic structure, it isn't bad, and as your programs become more sophisticated, the breaking up of the program into manageable chunks becomes 必須の. So.... WHAT IS that "basic structure" you need to know your way around?


The main part of the program is at the end. In this 事例/患者, it is the に引き続いて....
begin
repeat
if b0 then SayHi else SayBye;
until 4=5;
end.
"SayHi" and "SayBye" are not 基準 Pascal words. They are words we have created ーするために do the 職業 we have in mind for this program. The 指名するs should tell us what they do. We can look at the 詳細(に述べる)s in the part of the program before the main part. It is a classic "divide and 征服する/打ち勝つ" 戦略.

Remember that you can 挿入する new lines and spaces whereever it helps to make something more (疑いを)晴らす. The main part of this program might better be written....
begin
  repeat
    if b0 then
      SayHi {no ; here}
      else SayBye;
  until 4=5;
end.
Now... a わずかに tedious little work around to solve a problem I don't understand. Remember I said above "Don't try to 収集する yet"? That's because the program as shown won't work, even though it should. The に引き続いて, however, WILL 収集する... I've 単に "wrapped" the SayHi in a begin.. end

The work around may not be needed by the time you read this, assuming a Pascalite 見解/翻訳/版 greater than 2.60B. I was very impressed by the quick, come-clean, answer I received when I sent an email asking about this 事柄.
program hi;

   手続き SayHi;
     begin
     令状(lcd,'Hi');
     end;

   手続き SayBye;
     begin
     令状(lcd,'Bye');
     end;

begin
  repeat
    if b0 then
      begin
      SayHi;
      end {no ; here}
      else SayBye;
  until 4=5;
end.


Let's alter the program so that the LCD is (疑いを)晴らすd before each 令状 of "Hi" or "Bye". To do this in the obvious way, we'd just put a 令状(lcd,255); in 前線 of the 令状 in the 鮮明度/定義 of "SayHi" and in 前線 of the 令状 in the 鮮明度/定義 of "SayBye". (Now the "begin... end" within the two 手続きs isneeded.)....
program hi;

   手続き SayHi;
     begin
     令状(lcd,255);
     令状(lcd,'Hi');
     end;

   手続き SayBye;
     begin
     令状(lcd,255);
     令状(lcd,'Bye');
     end;

begin
  repeat
    if b0 then
      begin
      SayHi;
      end {no ; here}
      else SayBye;
  until 4=5;
end.
If you'll 許す a slight overkill, the に引き続いて illustrates that you can even use words you've made up in words you've made up! The only 制限 is that the "手続き ClearLCD begin.. end" stuff must appear BEFORE any place you try to use your new word (proper 称する,呼ぶ/期間/用語 for "your word": 使用者 Defined 手続き). Even in this "trivial" example of the technique, I think you can see an advantage. Within the 鮮明度/定義s of SayHi and SayBye, instead of the rather cryptic "令状(lcd,255)", we have the much more meaningful "ClearLCD". And if that isn't "meaningful" to you, change the 指名する I used to something that is meaningful!

Besides making the code more (疑いを)晴らす, the に引き続いて has another advantage. What if you 手配中の,お尋ね者 to move the code to a different machine? I am in fact, genuinely, adapting the code to a 平行の tutorial which illustrates the same 原則s, only in the FPC/ TP dialect of Pascal. Instead of 追跡(する)ing through the code, which would typically be much longer, of course, for every place where I want the 審査する (疑いを)晴らすd, I only have to alter what is between the "begin" and "end" of the code that defines what happens when "ClearLCD" is called. "Automatically", all through the program, all the things that were 初めは "令状(lcd,255)" are altered to work however the system I am on needs them to work. Brilliant! And it will get better in 未来 tutorials, in which we'll 調査する other 面s of "making up your own words."

So... just to finish off... here's the code I talked about a moment ago, in which we use a word we've made up ("ClearLCD") within the 鮮明度/定義s of other words we've made up. ("SayHi" and "SayBye")...
program hi;

   手続き ClearLCD;
     begin
     令状(lcd,255);
     end;

   手続き SayHi;
     begin
     ClearLCD;
     令状(lcd,'Hi');
     end;

   手続き SayBye;
     begin
     ClearLCD;
     令状(lcd,'Bye');
     end;

begin
  repeat
    if b0 then
      begin
      SayHi;
      end {no ; here}
      else SayBye;
  until 4=5;
end.

There's more to using 手続きs than you might 心配する from this 簡潔な/要約する and 限られた/立憲的な introduction. They are important because they 簡単にする keeping a 事業/計画(する) under 支配(する)/統制する. We'll 調査する them その上の in 未来 tutorials.

Here's the link, if you are ready to return to the 索引 of Pascal tutorials 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 .....