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

翻訳前ページへ


Debugging.. and 避けるing the need. HOME     >    >    >     TUTORIALS TABLE OF CONTENTS

Pascal tutorial: Debugging.. and 避けるing the need

This has good (警察などへの)密告,告訴(状)

Please don't 解任する it because it isn't 十分な of graphics, scripts, cookies, etc!
This (警察などへの)密告,告訴(状) should also help Delphi programmers.

Program 創造:

You shouldn't need to debug your programs!! (So why is it that I always have to debug 地雷?) If a program is written in a disciplined, careful manner it won't need debugging. I make this perhaps obvious, perhaps sanctimonious 観察 to encourage you to AVOID "poke and hope" programming. Almost always, if I try to "直す/買収する,八百長をする" something with a little bit of something that hasn't been thought through carefully, I 結局最後にはーなる with a mess that takes longer to get working than if I'd just worked a little more deliberately in the first place.


Semicolons are NOT hard... but they do lead to problems.

In general: if in 疑問, put one in! Also 価値(がある) remembering: The Borland compilers will often point to an "error" in line, say 125, if you have made some mistake (such as a 行方不明になるd semicolon) in line 124.

Where you must NOT put a semicolon: IN FRONT of an "Else" (e.g. in an if..then..else.. 封鎖する, or in a 事例/患者.. of.. else.. 封鎖する*)

(I'll try to 拡大する this in 予定 course)


Pascal is a very 整然とした language. The basis of that order is the "封鎖する".. a 概念 that rewards 熟考する/考慮する.

When 令状ing Pascal, いつかs it 支払う/賃金s NOT to work "from left to 権利, 最高の,を越す to 底(に届く)." Take a simple comment as an example. You could 令状 it as follows...

(*This
(*This is a
(*This is a comment done
(*This is a comment done left to
(*This is a comment done left to 権利
(*This is a comment done left to 権利*)

What I'd recommend is that you do...

(**)
(*This*)
(*This is a*)
(*This is a comment done*)
(*This is a comment done "ends first" then middle*)

The difference? The 終結させるing *) was done すぐに after the 開始 (*, and the text of the comment was filled in after the structure for the comment was 設立するd.

Other ありふれた 事例/患者s where I do the "ends" first, then the "guts":

手続き or 機能(する)/行事 宣言s, e.g. I start with:
手続き DoSomething;
var
begin
end;

If.. then... structures:
if ShouldDoIt then begin
end (*no ; here*)
else begin
end;(*else of if ShouldDoIt..*)

(By the way, I almost always put the "(*no ; here*)" comment in if I have an end before an else. It is so 平易な (and 致命的な) to put on it in passing if you see a "naked" "end" in some code. I also frequently comment WHAT an end ends.*)

And lastly- almost trivial, but still useful:
The ' 示すs either 味方する of a string. If I need sTmp:='Fred';, I 攻撃する,衝突する two 's after the :=, 攻撃する,衝突する the left arrow once, type Fred.


I 約束d to tell you not only how to debug, but also how to 避ける the need. One 援助(する) to Producing Perfect Programs 敏速に is using indents to elucidate the program's structure. There are no 最終的な 支配するs for what is "訂正する", but I think the に引き続いて illustrates some ideas which may be of use.
program デモ;
var sTmp:string;
    bFred:byte;
begin
repeat
  readln(sTmp)
  if length(sTmp)>1 then begin
    writeln('Please enter only one character');
    readln(sTmp);
    end;
  until length(sTmp)=1;
writeln('Here is a lot of them!'+sTmp+sTmp+sTmp+sTmp+sTmp+sTmp);end;


Many texts, by the way, would have you move the "until" out to the same column as its repeat. This is 論理(学)の, but having the first 列/漕ぐ/騒動 AFTER the end of the repeat 封鎖する move left also has 長所s. The same discussion can be held 関心ing the column for the end for the begin on the "if" line. Do what makes sense to you... but have a 計画(する), use it!


When you 指名する variables, of course you will use meaningful 指名するs. For instance in a program to calculate the area of rectangles, you would have variables called Length and Width. If you have other lengths and widths in the program, it may make sense to call them RectLenth and RectWidth... but PREfixing both with "rect" they would appear 近づく one another in an alphabetical 名簿(に載せる)/表(にあげる). While program 存在する to give you 名簿(に載せる)/表(にあげる)s of the variables you are using, I must 収容する/認める I've rarely used them... however, somehow, it still helps me to keep things (疑いを)晴らす to 指名する things so that 関係のある variable's 指名するs would be 近づく one another in a 名簿(に載せる)/表(にあげる). Many of my variable 指名するs are based on several words, and I jam them together, putting a 資本/首都 where each word begins. This seems as good, but with いっそう少なく typing than a ありふれた 代案/選択肢: Rect_length.

Another refinement of variable 指名するing that is VERY worthwhile is, I believe, called Hungarian nomenclature. In this, every variable 指名する is prefixed by something to 示す the type of the variable. In my source code, that part of the variable 指名する is always in lower 事例/患者 ("small" letter), and the next part of the 指名する starts with an upper 事例/患者 letter. I use b for byte type variables, s for string, li for long int, etc. Examples: bRectLength, sFileName

Most of my programs have a 全世界の bTmp (and maybe bTmp2, bTmp3, etc) and sTmp. The TeMPorary in their 指名する tells me that the contents of these variables are 保証(人)d only over very short sections of code. If you don't see the value put into the variable, don't assume what it is going to be. その結果, don't put something into a variable called bTmp if you want it still to be there any 重要な time later.


Turbo Pascal 申し込む/申し出s 広大な/多数の/重要な debugging 道具s. Master them, soon. In the 合間, just putting things like...

writeln('The value in bMyVariable at the moment is:');
writeln(bMyVariable);
readln(sTmp);

... in your code will often open your 注目する,もくろむs to what your program is REALLY doing. (As …に反対するd to what you thought you told it to do!) Choosing the 権利 位置/汚点/見つけ出す to put the little message sender is an art you will master. (The fancy 代案/選択肢 is called a "breakpoint", and you'll want to master "stepping through" and "tracing into" your code... but the message sending system 述べるd above will help until then!) (If you were to put the above into a program, it would need to have sTmp 宣言するd as a string, and not needed for other things at the moment, and you'd have a variable of your own 工夫するing and 宣言するing called bMyVariable in use.)



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

Link to Tutorials main page
How to email or 令状 this page's editor, Tom Boyd

- - o - -