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

翻訳前ページへ


Moving とじ込み/提出するs, building pages of HTML -lt3Nd.htm HOME - - - - - Lazarus Tutorials TOC - - - - - - Other 構成要素 for programmers
Delicious.Com Bookmark this on Delicious     StumbleUpon.Com Recommend to StumbleUpon

Moving とじ込み/提出するs. Creating HTML pages. 陳列する,発揮するing still images. CCTV

This has good (警察などへの)密告,告訴(状), and a search button at the 底(に届く) of the page

Please don't 解任する it because it isn't 十分な of graphics, scripts, cookies, etc!

This page is "browser friendly". Make your browser window as wide as you want it. The text will flow nicely for you. It is easier to read in a 狭くする window. With most browsers, 圧力(をかける)ing 加える, minus or 無 while the 支配(する)/統制する 重要な (ctrl) is held 負かす/撃墜する will change the texts size. (大きくする, 減ずる, 回復する to default, それぞれ.) (This is more fully explained, and there's another tip, at my 力/強力にする Browsing page.)


DE48 論証するs some simple Lazarus 手続きs.

I 港/避難所't tried this code in Delphi, but would be 大いに surprised if anything here didn't work 平等に 井戸/弁護士席 under Delphi.

A zip とじ込み/提出する with the 十分な Lazarus sourcecode, etc, and a pre-収集するd .exe is 利用できる for you to download. Before the .exe will do anything sensible, you need to 始める,決める up some folders with some .jpg とじ込み/提出するs in them, as explained 早期に in the tutorial.

What it does... in a nutshell

This 使用/適用 is a step along the road to a system I am building for 監視するing the still images 生産(高) from IPCams which I have feeding images to an FTP server. The 使用/適用 will run on the same PC as the FTP server, and periodically 収穫 copies of images the IPCams have "押し進めるd" の上に the hard 運動, 経由で the FTP service the PC 供給するs to the cameras. The 使用/適用 will also put together a page of HTML to 許す anyone on that PC, or 接近ing the web-server which also runs on that PC, to see the images which have been selected by the 使用/適用.

The 使用/適用, as 現在のd here, does not have all of those features. (I will be selling the 十分な 使用/適用, in 予定 course.) But the 使用/適用, as 現在のd here, does have many of the features which will be 現在の in the final 見解/翻訳/版.

その上に, I have spent hours 令状ing up an account of how the 使用/適用 was developed. I hope you will work your way through the account, if you are trying to become a stronger programmer.... and when you are done, I hope you will feel you 利益d from your 成果/努力 and my 成果/努力.

The IP (機の)カムs will, for 推論する/理由s we won't go into here, from time to time 令状 とじ込み/提出するs to folders. Each camera has its own folder.

For the 目的s of this デモ, the contents of those folders are static. However, the program is 存在 written with a 見解(をとる) to 延長するing it to 診察する the folders periodically. A copy of the most 最近の image in each folder will be made, and a page created to 陳列する,発揮する those copies of the 最近の images.

DE48 will take one image from each folder, and copy it to another folder (the "page 議会 folder"). Along the way, it will 選ぶ up (警察などへの)密告,告訴(状) about the images, in particular, their 創造 dates.

DE48 will create a text とじ込み/提出する 含む/封じ込めるing html. Calling that page up in a web browser, e.g. Firefox, will 陳列する,発揮する the images, with labels giving the time of the image's 創造.

What Lazarus 技術s are 論証するd

I hope that you will see さまざまな general good practices in all of my Lazarus and Delphi code, for example meaningful 指名するs for 反対するs.

In 新規加入, in DE48 I am going to illustrate...

(You may 選ぶ up a few ideas about HTML along the way, too. You don't need a web server to 完全にする this tutorial. Just point your web browser at the .htm とじ込み/提出する our 使用/適用 will create, and it should 陳列する,発揮する nicely.

Building a text とじ込み/提出する

I'm going to use a "cheap and cheerful" method: I will put the text I want in the とじ込み/提出する into a "覚え書き" (one of the 基準 Lazarus and Delphi 構成要素s, and then save the 覚え書き to the レコード. Not suitable for every 仕事, but 井戸/弁護士席 ふさわしい to many, 含むing this one.

You can download a 完全にするd DE48, if you wish. You will learn much more by building it up with me.

設立する a folder for this 事業/計画(する). Call it DE48.

的 for "goto" 公式文書,認める above: "zDLtarget"

設立する a 爆撃する 使用/適用 "DE48", with two buttons: buQuit and buDoIt. Caption them "やめる" and "Do It".

For the やめる button, I've never やめる got to the 底(に届く) of whether it is best to leave an 使用/適用 with the form's の近くに method or the 使用/適用's 終結させる method. Use whichever you like.

You could put コンビナート/複合体 code into the buDoIt button's OnClick handler... but this is a Bad Idea.

Instead, create a separate 手続き called DoIt, and have the buDoIt OnClick handler just call that. Remember to put the 今後 言及/関連 to your DoIt in the interface part of your code, in the "私的な" 封鎖する. (It would work in the "public" 封鎖する, too, but using "私的な" for anything which doesn't need to be "public" is, I think, a good habit.)

Just to get things started, DoIt can be just a "showmessage('Hello world');

Here's the code for that much...

部隊 DE48u1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, 支配(する)/統制するs, Graphics, Dialogs, StdCtrls;

type

  { TDE48f1 }

  TDE48f1 = class(TForm)
    buDoIt: TButton;
    buQuit: TButton;
    手続き buDoItClick(Sender: TObject);
    手続き buQuitClick(Sender: TObject);
  私的な
    { 私的な 宣言s }
    手続き DoIt;
  public
    { public 宣言s }
  end;

var
  DE48f1: TDE48f1;

実施

{$R *.lfm}

{ TDE48f1 }

手続き TDE48f1.buDoItClick(Sender: TObject);
begin
 DoIt;
end;

手続き TDE48f1.buQuitClick(Sender: TObject);
begin
  の近くに;
end;

手続き TDE48f1.DoIt;
begin
 showmessage('Hello world');
end;

end.

Put a 覚え書き on the form, call it meBuildTextFile

始める,決める the に引き続いて 所有物/資産/財産s to the values shown...

取って代わる the showmessage line in DoIt with a call to FillMemo, and create a FillMemo 手続き as follows...

手続き TDE48f1.DoIt;
begin
 FillMemo;
end;

手続き TDE48f1.FillMemo;
begin
 meBuildTextFile.(疑いを)晴らす;//Empty the 覚え書き
 meBuildTextFile.lines.追加する('デモ 1');
 meBuildTextFile.lines.追加する('デモ 2');
 meBuildTextFile.lines.追加する('デモ 3');
end;

Now clicking "DoIt" should change what is in the 覚え書き, make it 持つ/拘留する the three lines shown above.

So! We've got the 覚え書き filled. We'll turn to saving our "masterpiece" as a とじ込み/提出する in a moment. (And later we will return to the "filling" 過程, and fill the 覚え書き with something more useful.) But first....

Laying some 基礎...

Before we turn to saving what is in the 覚え書き, we need to build the part of the program which will take care some configuration 事柄s. For a start, we are going to 始める,決める things up so that the 使用者 doesn't have to say where the text from the 覚え書き will be saved. (結局, we will give 使用者s a way to change their choice... but still spare them having to say again and again where things are to be saved.) We will 追加する other configuration features as we go along.

In the "私的な" section of the 宣言 of our TDE48f1 class (which you will have if you 指名するd the main form for this 事業/計画(する) DE48f1, which makes sense if you've called the 事業/計画(する) "DE48")... 追加する the new line shown in...

  私的な
    { 私的な 宣言s }
    sPathOfAssmFldr:string;
    手続き DoIt;
    手続き FillMemo;

(公式文書,認める that all 手続き and 機能(する)/行事 今後 宣言s (there are two in the above) have to be at the end of the "私的な" 封鎖する. They have to come after any variable 宣言s. (There is just one in the above, so far, but usually there are many.) The same 支配する 適用するs when putting things in the "public" 封鎖する.)

The variable will be used to 設立する where the 議会 Folder (AssmFldr) will be. The 議会 Folder will be the folder where we will put the two .htm とじ込み/提出するs we are 組み立てる/集結するing, and we will also put the .jpg とじ込み/提出するs one of them uses there, too, in a sub-folder. Always "divide and 征服する/打ち勝つ" when you can.

In the DoIt 手続き, 追加する, at the start, a call to "FillVariousVariables", and 追加する the 手続き to the 使用/適用, as follows....

手続き TDE48f1.FillVariousVariables;
begin
  sPathToAssmFldr:='';
end;  

Setting sPathToAssmFldr to nothing ('') will 原因(となる) the 使用/適用 to save the things we want to save in the same folder that the .exe とじ込み/提出する is in. This will be 罰金 for now, and when we want things saved どこかよそで, we only need to 供給(する) the "どこかよそで" in the bit of code above. We will 令状 the 残り/休憩(する) of the 使用/適用 to always 言及する to the "place for saving stuff" 経由で sPathOfAssmFldr.

Now we can move on to the "saving" part, because we have "the 成分s" 供給するd for...

From 覚え書き to とじ込み/提出する on disk...

"The secret to saving the contents of a 覚え書き to our hard disk is in just one line of code... but, as ever, we will "挿入する" that line of code into our 使用/適用 in a way that keeps things 組織するd, 許すs debugging and 延長するing to go quickly and easily.

Create a 手続き called SaveMemo. Make a call to it as part of the 手続き DoIt. The SaveMemo 手続き is as follows...

手続き TDE48f1.SaveMemo;
begin
 meBuildTextFile.lines.savetofile(sPathToAssmFldr+'DE48pics.htm');
end;

We will be creating a text とじ込み/提出する. It will, 結局, 持つ/拘留する HTML, so the とじ込み/提出する's 拡張 should be .htm, not .txt. But it is still a text とじ込み/提出する. (You could read it into a text editor.) But it is also an .htm とじ込み/提出する, and if we give it the .htm 拡張, then by default, on most systems, it will open in a web browser... which is what we are going to want it to do, because web browsers are good at (判決などを)下すing .jpg とじ込み/提出するs as pictures, and, 経由で the HTML, we are going to be asking a browser to do just that.

公式文書,認める that this rather 天然のまま 実施 will 簡単に over-令状 any pre-存在するing DE48pics.htm とじ込み/提出する which happens to be in the sDE48WriteToFolder when we call SaveMemo. (There are steps you can introduce to bring up the often necessary "とじ込み/提出する 存在するs, do you want to over-令状 it". But for now, we are making a simple 使用/適用.)

Recap. So far...

So far, we have and 使用/適用 which...

Put some USEFUL text in the 覚え書き

We're going to make some changes to the text that gets put in the 覚え書き. Some of the changes will 伴う/関わる やめる lot of text, but keep the 原則s (疑いを)晴らす: It is still just text, even though it may start becoming hard to see the forest for all the trees in the way.

Before we do that, in order for the new text to do 利益/興味ing things, create a sub- folder in the folder where you have Lazarus creating the 使用/適用. (The folder should be "DE48", if you did as I asked earlier. That can be where-ever you want it on you hard 運動. (I have a "folder of folders" called something like "LazarusProjects" for 持つ/拘留するing... you can guess, I hope!))

Call the subfolder "Images".

Put four different small .jpgs in the folder. Call them TmpImg01.jpg, TmpImg02.jpg, TmpImg03.jpg, and TmpImg04.jpg. It won't 事柄 if you have other とじ込み/提出するs with 類似の 指名するs どこかよそで... the place where you find the folder they are in will help you remember what these copies of TmpImgXX.jpg are for.

Let's digress for a moment: There is nothing in the operating system taking advantage of my "支配する", but I never start the 指名する of a とじ込み/提出する "Tmp" if that とじ込み/提出する is something I need to keep if I come across it later, and wonder what it is. By using that 指名するing 条約, you can save yourself worry during disk tidying 開会/開廷/会期s. Digression ends.

For the moment, our web-page will always 陳列する,発揮する the same images. Later, we are going to get an unchanging web page to 陳列する,発揮する changing pictures by changing what is in TmpImg01.jpg, etc.

Whew! All this 準備 work! We're nearly there now.

Remembering what I said a moment ago about forests and trees, 改訂する FillMemo, to make it...

手続き TDE48f1.FillMemo;
begin
 meBuildTextFile.(疑いを)晴らす;//Empty the 覚え書き first
 meBuildTextFile.lines.追加する('<html>');
 meBuildTextFile.lines.追加する('<長,率いる>');
 meBuildTextFile.lines.追加する('</長,率いる>');
 meBuildTextFile.lines.追加する('<団体/死体>');
 meBuildTextFile.lines.追加する('<img width="20%" src="Images\TmpImg01.jpg">');
 meBuildTextFile.lines.追加する('<br><br>');
 meBuildTextFile.lines.追加する('<img width="20%" src="Images\TmpImg02.jpg">');
 meBuildTextFile.lines.追加する('</団体/死体>');
 meBuildTextFile.lines.追加する('</html>');
end;

... and run the app. (You may want to 配列し直す, re-size the layout of the buttons and 覚え書き on your form.)

Then open your とじ込み/提出する browser (e.g. Windows Explorer). Navigate to the newly (re-) created Tmp.htm. 二塁打-click on that, and your web browser should pop up, 陳列する,発揮するing the two images you 明示するd!

Not all that we 手配中の,お尋ね者, 正確に/まさに... but getting there. (You don't have to keep going off to your とじ込み/提出する browser... just 攻撃する,衝突する your internet browser's "refresh" (or "reload") button after each time you run the 使用/適用, which changes what is in Tmp.htm. But what you see in the browser only changes when you tell it to go look at the new Tmp.htm.

Boring 詳細(に述べる)s

In this section, I'm just 精製するing the form of the "img" lines. It will look messy, but there's no ロケット/急騰する science here. And we aren't yet beginning to 演説(する)/住所 the 必要物/必要条件 that the images 陳列する,発揮するd should be copies of the most recently arrived images in the folders we are supposed to be (but are not yet) watching.

We're going to 陳列する,発揮する two images per line, by using 提携させる="left" and 提携させる="権利" in our "img" 命令(する)s. Because we need to (手先の)技術 a number of 類似の lines, we will 令状 a little 機能(する)/行事 (sLineOfHTML) to help us "組み立てる/集結する" them.

Remember: We are just filling the 覚え書き with some text, text which doesn't change between 死刑執行s of "FillMemo". (Later, we will be 追加するing some things that do change (labels for the images), or we could just 令状 the page once and be done with it.)

Since we are "just filling the 覚え書き with some text", don't let the 複雑さ of the text distract you.

To make a start, we will forget we are doing images for the moment, and, in place of the "img" lines we had before, we'll have something simpler, which will just say "HelloWorldX" where "X" will be a digit.

Create the 機能(する)/行事 sLineOfHTML inside the FillMemo 手続き, and use it, as follows. 公式文書,認める that sLineOfHTML takes two parameters. Remember: We are still "just putting some text in the 覚え書き."

手続き TDE48f1.FillMemo;
   機能(する)/行事 sLineOfHTML(sTmp1,sTmp2:string):string;
    (*This is done a little crudely, in 尊敬(する)・点 of the "L" and "R"*)
    begin
      if sTmp2='L' then
      sLineOfHTML:='<img 提携させる="left" '+
                'width="45%" src="Images\TmpImg0'+sTmp1+'.jpg" '+
                'alt="No such とじ込み/提出する">';
      if sTmp2='R' then
      sLineOfHTML:='<img 提携させる="権利" '+
                'width="45%" src="Images\TmpImg0'+sTmp1+'.jpg" '+
                'alt="No such とじ込み/提出する">';
      if (sTmp2<>'L') and (sTmp2<>'R') then
      sLineOfHTML:='<p>There''s an error in the app''s code. Err 13921a</p>';
    end;

begin
 meBuildTextFile.(疑いを)晴らす;//Empty the 覚え書き first
 meBuildTextFile.lines.追加する('<html>');
 meBuildTextFile.lines.追加する('<長,率いる>');
 meBuildTextFile.lines.追加する('</長,率いる>');
 meBuildTextFile.lines.追加する('<団体/死体>');
 meBuildTextFile.lines.追加する(sLineOfHTML('1','L'));
 meBuildTextFile.lines.追加する(sLineOfHTML('2','R'));
 meBuildTextFile.lines.追加する('<br (疑いを)晴らす=left><br (疑いを)晴らす=権利>');
 meBuildTextFile.lines.追加する(sLineOfHTML('3','L'));
 meBuildTextFile.lines.追加する(sLineOfHTML('4','R'));
 meBuildTextFile.lines.追加する('<br (疑いを)晴らす=left><br (疑いを)晴らす=権利>');
 meBuildTextFile.lines.追加する('</団体/死体>');
 meBuildTextFile.lines.追加する('</html>');
end;

The 使用/適用 should now, when you look at Tmp.htm in a web browser, give you a way to look at 4 jpegs, nicely 始める,決める out in two columns.

Some 詳細(に述べる)s about SaveMemo

Here are some 詳細(に述べる)s about the way we programmed the SaveMemo 手続き, which I didn't go into earlier....

Because it is simpler, in this 使用/適用, we will 決定する the 指名する of the とじ込み/提出する the 覚え書き is saved to within the code of the 使用/適用. I.e., the 使用者 will have no direct choice in the 事柄 at the time the とじ込み/提出する is saved. (In 予定 course, the choice of filename can be made be "settable" in the ini とじ込み/提出する.)

Also to make this simpler, we will 始める,決める up a folder for the 覚え書き (and other things) to be saved in, the folder 明示するd in sAssmFldr. We 割り当てるd a value to sAssmFldr within the code. In 予定 course, it will be possible to change that in the ini とじ込み/提出する.

(詳細(に述べる): Also, against the day when we want to use something other than the .exe's folder, just after "sPathToAssmFldr:='';", 追加する the に引き続いて to insure a "\" at the 権利 手渡す end of the path 指名する...

 if sPathToAssmFldr<>'' then if
    sPathToAssmFldr[length(sPathToAssmFldr)]<>'\' then
      sPathToAssmFldr:=sPathToAssmFldr+'\';

Onward!...

Changing what is in the TmpImg01.jpg, etc, とじ込み/提出するs...

Once again, before we can go very far, we need to 始める,決める up some 資源s. Remember: This tutorial arises along the way of my 創造 of a program to ざっと目を通す some folders, and make copies of the most 最近の とじ込み/提出するs in each, and then 生成する two .htm とじ込み/提出するs based on those images and when the とじ込み/提出するs changed.

公式文書,認める that all of this is 存在 done in ways which make it 平易な to "move things", if the way I've 始める,決める things up doesn't 控訴 my needs the next time I want to (軍隊を)展開する,配備する a copy of the 使用/適用. For the 目的s of 完全にするing the tutorial, I 示唆する you put things where I'm about to 述べる I put them. With some OSs, working in the root can be a 苦痛, hence, in part, the subordinate folder "DE48DataRoot".

In the root of your C: 運動, create a folder "DE48DataRoot".

In that, create a folder called "pseudoroot".

Within that, create the に引き続いて folders. (You could start with just one of them, and just one .jpg (see below))

(The 指名するs, "IVA152", etc, come from the IDs I've 割り当てるd to my IPCams. And no, I don't have 213 of them. The IVA prefix is 株d!)

Within each of THOSE put some .jpg とじ込み/提出するs. It would be best if you didn't use the same one over and over. In the first, have one called Img152.jpg, in the second one called Img155.jpg, and so on. (Once we have the program doing simple things, we may go on, make it fancier. For now one .jpg per folder will 十分である.)

A first 行う/開催する/段階

To made a VERY 天然のまま start, create a 手続き CopyFiles as follows, and put a call of it in DoIt, just before the FillMemo call.

Whenever you use this technique, starting with something 天然のまま, and building it up....

Beware starting off before you know where you are going. PLAN ahead (before you start building), but BUILD by 行う/開催する/段階s.

Before I show you the 天然のまま CopyFiles, a 思い出の品 of what it needs to do....

We are 令状ing an 使用/適用 which will "収穫" images from a repository on a hard disk. They will be arriving their by FTP from さまざまな IPCams 有能な of 令状ing to an FTP server... but where they are coming from is a mere 詳細(に述べる), as far as DE48 is 関心d. DE48 does need to know where they are arriving. It needs to know that new ones come in from time to time, and that it is DE48's 職業 to 持続する copies of the 現在の most 最近の とじ込み/提出する in each source folder in one "議会 Area" (the path to that 存在 given to DE48 in sPathToAssmFldr). (The "most 最近の とじ込み/提出する in folder" element of this will probably not be 演説(する)/住所d in this tutorial. We will only give DE48 a way to keep copying something, chosen more or いっそう少なく at 無作為の, from each of the source folders.

So. (土地などの)細長い一片 the 必要物/必要条件s 負かす/撃墜する a bit. Say, for now, that CopyFiles only needs to copy four とじ込み/提出するs. That it will be the same four とじ込み/提出するs each time CopyFiles is called. That they will come from 場所s we can hard-code into the 使用/適用.

Those 必要物/必要条件s can be met by the に引き続いて simple little thing, which is just four calls of the built in "copyfile" 手続き....

手続き TDE48f1.CopyFiles;
begin
 copyfile('C:\DE48DataRoot\pseudoroot\IVA152\Img152.jpg',
              sPathToAssmFldr+'Images\TmpImg01.jpg');
 copyfile('C:\DE48DataRoot\pseudoroot\IVA152\Img152.jpg',
              sPathToAssmFldr+'Images\TmpImg02.jpg');
 copyfile('C:\DE48DataRoot\pseudoroot\IVA152\Img152.jpg',
              sPathToAssmFldr+'Images\TmpImg03.jpg');
 copyfile('C:\DE48DataRoot\pseudoroot\IVA152\Img152.jpg',
              sPathToAssmFldr+'Images\TmpImg04.jpg');
end; 

An aside: CopyFile is 現実に a 機能(する)/行事. It returns "true" or "誤った". It can be used, as I did above, as a 手続き, and the returned value is just "throw away". The code really せねばならない be 改善するd along the に引き続いて lines...

....
  if (copyfile( SOURCE, DESTINATION )=誤った) then
     showmessage('An 無効の copy was requested');
...

To finish this 事業/計画(する): We'll need to 始める,決める up a system to make "DoIt" happen over and over. (Trivial.) For it to do something 現実に useful, the 事柄 of choosing as source the most 最近の とじ込み/提出する in the folder will have to be dealt with. To make this a "good" 使用/適用, we will have to build in ways for the 使用者 to have more or より小数の images in the 陳列する,発揮する, and to (easily- depending in part upon an ini とじ込み/提出する.) change the source folders visited. (We're about to 乗る,着手する upon those two challenges.) (And, to fully 会合,会う what was 始める,決める out as our goals, we also need to create the 第2位 .htm とじ込み/提出する, about which I've so far said little.)

Building in 柔軟性

While this 使用/適用 may not 利益/興味 a wide audience, the programming techniques I am about to explain have very wide applicability. Pretend for a moment that you do want the とじ込み/提出する 収穫ing 使用/適用!

Arrays will be an important part of programming for 柔軟性. For instance, as I hope you would すぐに 心配する, will there be an array of strings, 持つ/拘留するing the "where" of the source folders.

To make it 平易な to "tweak" the program, 近づく the beginning of the code we will 設立する a constant which tells all that follows the 最大限 索引 which will be 手配中の,お尋ね者 for any of those arrays. The に引き続いて goes just after the "Uses" 条項...

const vers='21Sept13';
      //Code started 21 Sep 13, NC
      kMaxArr=5;

In the third line, we 始める,決める kMaxArr to five. We are 説 that there won't be more than 6 of the things that 刈る up in the program in "始める,決めるs" (using that 称する,呼ぶ/期間/用語 in the general sense, not the Pascal sense.) We'll revisit this in a moment.

公式文書,認める, by the way, the "=" rather than the more usual (in Pascal) ":=" for assignment.

In passing: The first line of my "const" 条項 is just one of my 条約s: The constant "vers" 持つ/拘留するs a string, usually a date, to identify the 見解/翻訳/版 of this 版 of the code. The next line, just a comment, is there because it amuses me to know how old some of my 事業/計画(する)s are. It is the "kMaxArr" line that is "special" to DE48. "k" for "constant" ("c" already 存在 "taken" for other things.)

To the "私的な" section of the 宣言 of our TDE48f1 class (which you will have if you 指名するd the main form for this 事業/計画(する) DE48f1, which makes sense if you've called the 事業/計画(する) "DE48")... 追加する the new lines shown in...

  私的な
    { 私的な 宣言s }
    sImageFolder:array[0..kMaxArr]of string;
    sPathToImages:string;
    手続き DoIt;
    手続き FillMemo;

By setting kMaxArr to 5 earlier, we've 始める,決める the 行う/開催する/段階 so that the above creates...

sImageFolder[0];
sImageFolder[1];
sImageFolder[2];
sImageFolder[3];
sImageFolder[4];
sImageFolder[5];

We will also have a variable, which will never 持つ/拘留する more than kMaxArray, to tell anyone who needs to know just how many of the 利用できる array elements are in use at the 現在の time. In our 天然のまま example, if it were done with arrays, because we are 収穫ing four images, we'd need four array elements. But, as these things are usually numbered from 無 (and as we are doing "the usual") the number in the variable would be 3. We'll call the variable bMaxArrElInUse. ("(索引 of the) 最大限 Array Element In Use (at this time)".)

(追加する "bMaxArrElInUse:byte;" to the variable 宣言s at the start of the code, and "bMaxArrElInUse:=3;" to "FillVariousVariables", so that they are in place when we come to use them.)

Also in "FillVariousVariables", put the に引き続いて...

  sImageFolder[0]:='C:\DE48DataRoot\pseudoroot\IVA152\';
  sImageFolder[1]:='C:\DE48DataRoot\pseudoroot\IVA155\';
  sImageFolder[2]:='C:\DE48DataRoot\pseudoroot\IVA199\';
  sImageFolder[3]:='C:\DE48DataRoot\pseudoroot\IVA200\';

(Be sure to 含む the 終点 "\")

(If you were sure that all of the source folders for the images would be on a ありふれた path, you could, of course, 蓄える/店 that in a variable of its own.)

Now that we've 供給するd a filled "sImageFolder[]" array, we can make CopyFiles easier to read. And easier to read equals "いっそう少なく 有能な of hiding a bug". The new 見解/翻訳/版 is also, of course, more 柔軟な.

手続き TDE48f1.CopyFiles;
begin
 copyfile(sImageFolder[0]+'Img152.jpg',
              sPathToAssmFldr+'Images\TmpImg01.jpg');
 copyfile(sImageFolder[1]+'Img155.jpg',
              sPathToAssmFldr+'Images\TmpImg02.jpg');
 copyfile(sImageFolder[2]+'Img199.jpg',
              sPathToAssmFldr+'Images\TmpImg03.jpg');
 copyfile(sImageFolder[3]+'Img200.jpg',
              sPathToAssmFldr+'Images\TmpImg04.jpg');
end;

What else can we make more elegant?

It won't be すぐに obvious why I am doing it this way, but think about it later, and you should see the 推論する/理由... even if the 十分な 利益s don't arise until the 使用/適用 is 延長するd to find the newest とじ込み/提出する in each source folder.

I'm going to use a 機能(する)/行事 to 供給(する) the "Img152.jpg", "Img155.jpg", etc bits in the above. I'm calling it "sFileNSource", for "とじ込み/提出する NAME, Source とじ込み/提出する". And when the 機能(する)/行事 is called, a parameter will be passed.

機能(する)/行事 TDE48f1.sFileNSource(bWhich:byte):string;
begin
  事例/患者 bWhich of
    0:sFileNSource:='Img152.jpg';
    1:sFileNSource:='Img155.jpg';
    2:sFileNSource:='Img199.jpg';
    3:sFileNSource:='Img200.jpg';
      //(Should also have "el se" 条項 to catch inadvertent 洪水s
      //  which could easily arise during careless tweaking of program;
    end;//事例/患者
  end;

With sFileNSource 利用できる, our 手続き CopyFiles becomes even more elegant. (There's no need to understand the snippet below, if trying to do so doesn't amuse you. The previous, 天然のまま, code does the same 職業.)

手続き TDE48f1.CopyFiles;
begin
 copyfile(sImageFolder[0]+sFileNSource(0),
              sPathToAssmFldr+'Images\TmpImg01.jpg');
.....

(An aside: I chose the 指名する for CopyFiles without 十分な care. Seeing as Lazarus/Delphi/Pascal has the built-in 機能(する)/行事 copyfile (no "s"), it would be 同様に to use a more-different 指名する for our Copy-the-fileS 手続き.)

CopyFiles is, of course, now just one step away from becoming very elegant...

手続き TDE48f1.CopyFiles(bHowMany:byte);
var bCount:byte;
機能(する)/行事 sDestFN(bWhich:byte):string;
//There's no need to build in 柔軟性 in the
//  指名するing of these とじ込み/提出するs, they are "内部の",
//  in a 献身的な folder of sAssmFldr
  begin
    事例/患者 bWhich of
    0:sDestFN:='Images\TmpImg01.jpg';//This can also be done "cleverly"
    1:sDestFN:='Images\TmpImg02.jpg';// ... but why bother, here?
    2:sDestFN:='Images\TmpImg03.jpg';
    3:sDestFN:='Images\TmpImg04.jpg';
    //(Should also have "el se" 条項 to catch inadvertent 洪水s
    //  which could easily arise during careless tweaking of program;
    end;//事例/患者
   end;//sDestFN
begin
 for bCount:=0 to bHowMany do begin
 copyfile(sImageFolder[bCount]+sFileNSource(bCount),
              sPathToAssmFldr+sDestFN(bCount));
    end;//for
end;

An example of using an ini とじ込み/提出する

There are many things in this 使用/適用 which are, at the moment, hard-coded. Many of them should be made "settable" 経由で an ini とじ込み/提出する. We'll do what is necessary in two 事例/患者s, and leave changing the others to the student as an 演習, if 利益/興味d.

The 使用/適用 fetches images from a 始める,決める of "source" folders.

The 使用/適用 knows where source folders are from what is in さまざまな elements of the string array sImageFolder[]. (公式文書,認める that every value in those array elements should end with a "\".)

Those variables get filled with values during the one call of FillVariousVariables, 早期に in the program's 死刑執行, by simple hardcoded assignment 声明s.

We're going to 取って代わる....

  sImageFolder[0]:='C:\DE48DataRoot\pseudoroot\IVA152\';
  sImageFolder[1]:='C:\DE48DataRoot\pseudoroot\IVA155\';
  sImageFolder[2]:='C:\DE48DataRoot\pseudoroot\IVA199\';
  sImageFolder[3]:='C:\DE48DataRoot\pseudoroot\IVA200\';

... with something 冷静な/正味の.

It will...

Look to see if there is an .ini とじ込み/提出する in the folder the .exe とじ込み/提出する was in.

If so, it will open that とじ込み/提出する, and 試みる/企てる to fetch some data from it. If the ini とじ込み/提出する is not 設立する, the program still run okay.

The ini とじ込み/提出する is just another text とじ込み/提出する, but if the 権利 things are in it (more on this in a moment), your 使用/適用 will draw things from it.

So... First put "INIFiles" in the "uses" 条項 at the 最高の,を越す of the code.

Next get the system to start an OnFormActivate event handler for you. (反対する 視察官, select the form, go to Events tab, 二塁打-click on the OnFormActivate's edit box.)

改訂する the OnFormActivate 爆撃する to make it...

手続き TDE48f1.FormActivate(Sender: TObject);
var dfIniFile:TInifile;
begin
  dfIniFile:=TIniFile.Create('DE48ini.txt');
  with dfIniFile do begin
   sImageFolder[0]:=ReadString('SourcePaths','1','C:\DE48DataRoot\pseudoroot
\IVA152\');
   sImageFolder[1]:=ReadString('SourcePaths','2','C:\DE48DataRoot\pseudoroot
\IVA155\');
   sImageFolder[2]:=ReadString('SourcePaths','3','C:\DE48DataRoot\pseudoroot
\IVA199\');
   sImageFolder[3]:=ReadString('SourcePaths','4','C:\DE48DataRoot\pseudoroot
\IVA200\');
   end;//with...
  dfIniFile.解放する/自由な;
end;

Take OUT of the code you had 以前 the lines in FillVariousVariables which gave values to sImageFolder[0], sImageFolder[1], etc.

Run the 使用/適用 again. You should find that it runs 正確に/まさに as it did before.

Here's what's happening...

When the program comes to...

dfIniFile:=TIniFile.Create('DE48ini.txt');

...it looks for a とじ込み/提出する called DE48ini.txt. (It looks in the folder the 使用/適用's .exe is in, unless told to look どこかよそで, e.g. 'C:\Misc\DE48ini.txt').

In our 事例/患者, at the moment, it finds 非,不,無. It doesn't let this be a problem.

It then sees....

sImageFolder[0]:=
   ReadString('SourcePaths',
   '1',
   'C:\DE48DataRoot\pseudoroot\IVA152\');

...and, there 存在 no ini とじ込み/提出する, it ignores most of that, and 扱う/治療するs it as if it said...

sImageFolder[0]:=
   'C:\DE48DataRoot\pseudoroot\IVA152\');

.. which is the line we took out of our 天然のまま 見解/翻訳/版 of the program!

Now... what if there IS an ini とじ込み/提出する 現在の?

The 使用/適用 looks through the ini とじ込み/提出する, looking for a line that says....

[SourcePaths]

If it finds one, then in that section of the ini とじ込み/提出する, the 使用/適用 looks for a line that says....

1=

If it finds a line starting "1=", in the "[SourcePaths] section of the ini とじ込み/提出する, then the 使用/適用 will fill sImageFolder[0] with whatever (機の)カム after the "1=".

That's "all" there is to using ini とじ込み/提出するs to fill variables as a program is starting up!

Where do ini とじ込み/提出するs come from?

The simple way to 供給する an ini とじ込み/提出する, to, in our 事例/患者, change where the 使用/適用 looks for the images to copy, is to type one by 手渡す into a text editor. One for DE48, as it stands at this point in the tutorial, but to make the 使用/適用 look in a different place for the sources for the first two images, would be...

[SourcePaths]
1=C:\DE48DataRoot\DifferentSet\IVA189\
2=C:\DE48DataRoot\DifferentSet\IVA180\
3=C:\DE48DataRoot\pseudoroot\IVA152\
4=C:\DE48DataRoot\pseudoroot\IVA155\

However, there is another 大勝する 利用できる to you.

You can get your 使用/適用 to save a datafile (or over-令状 an 存在するing one) with code like the に引き続いて. Slotting the code into you code so that it 遂行する/発効させるs at the 権利 time is a little tricky, but not ロケット/急騰する science.

In DE48, I've used the crudest possible "解答": I just put the に引き続いて code in an OnFormDestroy handler. Because I have done it this way, the ini とじ込み/提出する will be created, if 非,不,無 存在するd before, or over-written (without 警告s) if one did 存在する before. Now... at the moment, over-令状ing the とじ込み/提出する is, to a degree, pointless. (It does 供給する an 平易な way to get a syntactically 訂正する .ini とじ込み/提出する, as a starting point for tweaking.) However, we will 追加する a little extra bit in a moment, and once we have done that, over-令状ing the previous ini とじ込み/提出する each time you 出口 makes sense. Here's the code so far...

手続き TDE48f1.FormDestroy(Sender: TObject);
var dfIniFile:TInifile;
begin
 dfIniFile:=TIniFile.Create('DE48ini.txt');
 with dfIniFile do begin
  WriteString('SourcePaths','1',sImageFolder[0]);
  WriteString('SourcePaths','2',sImageFolder[1]);
  WriteString('SourcePaths','3',sImageFolder[2]);
  WriteString('SourcePaths','4',sImageFolder[3]);
  end;//with...
 dfIniFile.解放する/自由な;
end;

Now, to illustrate a 事例/患者 where there's a point to re-令状ing the ini とじ込み/提出する at the end of each 死刑執行 of the 使用/適用, we're going to 追加する a feature 一般的に 設立する in 使用/適用s... DE48 will be made to remember where it was on the desktop the last time it was opened.

"The secret" is in some of the 所有物/資産/財産s of the form: 最高の,を越す, left, 高さ, and width.

追加する the に引き続いて to the FormDestroy handler. (公式文書,認める, by the way, the WriteInteger 手続き, which is very like the WriteString, but it 令状s integers, not strings. Duh.)

  WriteInteger('PosnAndSize','最高の,を越す'   ,DE48f1.最高の,を越す);
  WriteInteger('PosnAndSize','Left'  ,DE48f1.left);
  WriteInteger('PosnAndSize','高さ',DE48f1.高さ);
  WriteInteger('PosnAndSize','Width' ,DE48f1.width);

(All the 指名するs... "PosnAndSize", "最高の,を越す", "高さ" are 完全に up to you. (The 所有物/資産/財産 指名するs, "最高の,を越す", "高さ", etc after the DE48f1, are not... they are defined 所有物/資産/財産s.)

If you now run the 使用/適用 again and の近くに it, you will find new 入ること/参加(者)s in the ini とじ込み/提出する. Do it again, but move and re-size DE48's window on the desktop before you の近くに it, and the values of 最高の,を越す, etc, will change, if you look again at the ini とじ込み/提出する's contents.

We'll come to making the 使用/適用 USE the values in the ini とじ込み/提出する in a moment. But first a 警告: It can get やめる 混乱させるing, working with ini とじ込み/提出するs. Is what you are seeing in your text editor 現実に what is now in the ini とじ込み/提出する? It is 平易な to get 混乱させるd.

Also, beware: Save and changes you want to make in the ini とじ込み/提出する from your text editor AFTER の近くにing the 使用/適用 which will read it, or いつかs the 使用/適用 doesn't see those changes. (It may 簡単に be a 事柄 of the 使用/適用 overwriting the changes you made, as the 使用/適用 の近くにs... but I think it is more subtle than that.)

Anyway, onward... let's make our 使用/適用 答える/応じる to the values in the PosnAndSize section of the ini とじ込み/提出する.

平易な! Just 追加する the に引き続いて to the OnActivate handler. The numbers at the ends of the lines are what will be used if the ini とじ込み/提出する does not yet have an 入ること/参加(者) for that 所有物/資産/財産.

   DE48f1.最高の,を越す   :=ReadInteger('PosnAndSize','最高の,を越す'   ,10);
   DE48f1.left  :=ReadInteger('PosnAndSize','Left'  ,20);
   DE48f1.高さ:=ReadInteger('PosnAndSize','高さ',300);
   DE48f1.width :=ReadInteger('PosnAndSize','Width' ,500);

A frill...

Remember: This 使用/適用 is meant to be 収穫ing copies of images which are appearing in さまざまな folders 予定 to 装置s beyond the ken of DE48. The images "just appear". And then DE48 組み立てる/集結するs a web page to 陳列する,発揮する copies of the images.

A feature I will not be explaining in the tutorial... 結局, I will be selling an 改善するd DE48 with this feature... is that the images shown on the web page will be the newest image in each folder, when the folder was checked. So it makes sense to 含む the datestamp of the image in the web page 陳列する,発揮する. Not terrible difficult, though (一定の)期間ing out all the 詳細(に述べる)s may take a few words.

We're going to start some changes to the sFileNSource 機能(する)/行事. The 機能(する)/行事 will continue, 直接/まっすぐに, to return the 指名する of a とじ込み/提出する. But, in the parameters, I am 追加するing a "var" parameter, dtDateStamp, which will, during the 死刑執行 of the 機能(する)/行事 call, be filled with the datestamp on the とじ込み/提出する fetched. 井戸/弁護士席. It will, in the final 見解/翻訳/版 of this 使用/適用. For now the "datestamp" will be an 独断的な and unchanging number, hardcoded into the 内部の code of sFileNSource. However... even though that number is 独断的な, it will be 報告(する)/憶測d on the 生成するd web page.

To 遂行する these things, I created a 全世界の array, dtDateStamp[], and sFileNSource became....

機能(する)/行事 TDE48f1.sFileNSource(bWhich:byte; var
dtTmpDateStamp:TDateTime):string;
begin
  事例/患者 bWhich of
    0:begin
      sFileNSource:='Img152.jpg';
      dtTmpDateStamp:=14;
      end;
    1:begin
      sFileNSource:='Img155.jpg';
      dtTmpDateStamp:=15;
      end;
    2:begin
      sFileNSource:='Img199.jpg';
      dtTmpDateStamp:=16;
      end;
    3:begin
      sFileNSource:='Img200.jpg';
      dtTmpDateStamp:=17;
      end;
      //(Should also have "el se" 条項 to catch inadvertent 洪水s
      //  which could easily arise during careless tweaking of program;
    end;//事例/患者
  end;

... and in CopyFiles, we 追加する a line...

begin
 for bCount:=0 to bHowMany do begin
     copyfile(sImageFolder[bCount]+sFileNSource(bCount,dtTmpDateStamp),
              sPathToAssmFldr+sDestFN(bCount));
     dtDateStamp[bCount]:=dtTmpDateStamp;// <<<
    end;//for
end;

That leaves us in the position of 存在 able to 改善する FillMemo as illustrated by the fragment below....

meBuildTextFile.lines.追加する(sLineOfHTML('02','R'));
 meBuildTextFile.lines.追加する('<br (疑いを)晴らす=left><br (疑いを)晴らす=権利>');
 meBuildTextFile.lines.追加する('<p>The next two images had datestamps of: '+datetostr
(dtDateStamp[2])+
                 ' and '+datetostr(dtDateStamp[3])+'</p>');
 meBuildTextFile.lines.追加する(sLineOfHTML('03','L'));

Doing it over and over...

井戸/弁護士席, we're nearly there. The 使用/適用 does much of what I 手配中の,お尋ね者 it to do... if I click the "DoIt" button. And then it copies some とじ込み/提出するs from the source folders to the "scratch" folder used by the .htm page. It creates the .htm page we 手配中の,お尋ね者.

What it doesn't do, yet, is 遂行する/発効させる the "DoIt" over and over. Arranging this is 平易な!

Put a timer 構成要素 on your form. You should find it as the first 構成要素 on the "System" tab.

Make the OnTimer handler....

手続き TDE48f1.Timer1Timer(Sender: TObject);
begin
  buDoIt.enabled:=誤った;//not 必須の... see below.
  DoIt;
  buDoIt.enabled:=true;
end;

始める,決める the timer's "interval" 所有物/資産/財産 to 5000.

And run the program. It wasn't 必須の to 無能にする the DoIt button while the OnTimer handler was 遂行する/発効させるing "DoIt", but you should see the button's 明言する/公表する "flicker" every five seconds because of the new code. (Don't leave the 使用/適用 running for long, in this 明言する/公表する, will you? That would be a lot of とじ込み/提出する 令状ing (打撃,刑罰などを)与えるd on your disk.)

We're Done!

There you have it! A little bit of code which illustrates さまざまな techniques. I hope you will find them useful in your own 事業/計画(する)s.

I'm off to create the bigger, better 見解/翻訳/版 of this, so I will have a webpage with 最近の pictures from my cameras 利用できる to me! Don't 持つ/拘留する your breath for the 商業の 見解/翻訳/版, sorry. The fun part is 令状ing the "good enough" 見解/翻訳/版 to 会合,会う my need. That takes maybe 20% of the time it takes to 完全にする a 商業の 製品, and I just don't get enough people buying my shareware to encourage me to 急ぐ to spend the time on the CCTV 監視するing 使用/適用. But who knows... maybe someday...





            力/強力にするd by FreeFind
  場所/位置 search Web search
場所/位置 地図/計画する    What's New    Search This search 単に looks for the words you enter. It won't answer "Where can I download InpOut32?"

If you visit 1&1's 場所/位置 from here, it helps me. They host my website, and I wouldn't put this link up for them if I wasn't happy with their service. They 申し込む/申し出 things for the beginner and the 会社/団体.www.1and1.com icon

広告 from page's editor: Yes.. I do enjoy 収集するing these things for you. I hope they are helpful. However... this doesn't 支払う/賃金 my 法案s!!! Sheepdog ソフトウェア (tm) is supposed to help do that, so if you 設立する this stuff useful, (and you run a Windows or MS-DOS 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 Lazarus Tutorials main page
How to 接触する the editor of this page, Tom Boyd


Valid HTML 4.01 Transitional Page 実験(する)d for 同意/服従 with INDUSTRY (not MS-only) 基準s, using the 解放する/自由な, 公然と accessible validator at validator.w3.org. Mostly passes. There were two "unknown せいにするs" in Google+ button code. Sigh.


If this page 原因(となる)s a script to run, why? Because of things like Google パネル盤s, and the code for the search button. Why do I について言及する scripts? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....