2 Feeding Origin 2 is software that supports calculation of nutrient requirement of livestock
3 and feed design based on Japanese feeding standard.
4 Copyright (C) 2017, Syuichiro Fukagawa.
6 This program is free software; you can redistribute it and/or modify it under the terms of
7 the GNU General Public License as published by the Free Software Foundation; either version 3
8 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 See the GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License along with this program.
13 If not, see <http://www.gnu.org/licenses/>.
16 Feeding Origin 2は、日本飼養標準に基づいた家畜の養分要求量の計算および飼料設計を支援するソフ
18 Copyright (C) 2017, 深川修一郎.
20 このプログラムはフリーソフトウェアです。あなたはこれを、フリーソフトウェア財団によって
21 発行されたGNU一般公衆利用許諾書(バージョン3か、それ以降のバージョンのうちどれか)が定める
22 条件の下で再頒布または改変することができます。
23 このプログラムは有用であることを願って頒布されますが、*全くの無保証* です。商業可能性の保証
24 や特定目的への適合性は、言外に示されたものも含め、全く存在しません。詳しくはGNU一般公衆利用
26 あなたはこのプログラムと共に、GNU一般公衆利用許諾書のコピーを一部 受け取っているはずです。
27 もし受け取っていなければ、<http://www.gnu.org/licenses/> をご覧ください。
29 *本日本語訳は、FSFより2007年6月29日に発行されたGNU GPL v3の原文から、八田真行氏が翻訳した
30 ものを基にしています。 < https://mag.osdn.jp/07/09/02/130237 >
40 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
41 ExtCtrls, StrUtils, LCLType ;
43 procedure ComEditKeyPress(SForm: TForm; Sender: TObject; var Key: char);
44 procedure ComEditKeyDown(SForm: TForm; Sender: TObject; var Key: Word; Shift: TShiftState);
45 procedure ComRGKeyDown(Sender: TObject; var Key: Word; NextCtrl: TObject);
46 procedure ComCBKeyDown(SForm: TForm; Sender: TObject; var Key: Word);
48 function LengthEdit(sSL : String; iL : Integer) : String ;
49 function KanjiLength( sSource : String ) : Integer ;
50 function FloatEdit( dOrg : Double ; iSS, iLL : Integer ) : String ;
54 procedure ComEditKeyPress(SForm: TForm; Sender: TObject; var Key: char);
56 if Key = chr(VK_RETURN) then
58 SForm.SelectNext(Sender as TWinControl, True, True ); // フォーカス移動(前進)
62 if (Key <> chr(VK_TAB)) and
63 (Key <> chr(VK_SHIFT)) and
64 (Key <> chr(VK_DELETE)) and
65 (Key <> chr(VK_BACK)) and
81 procedure ComEditKeyDown(SForm: TForm; Sender: TObject; var Key: Word; Shift: TShiftState);
84 96 .. 105, 110, 8, 9, 16, 37, 39, 46 : // 0~9,.,BS,Tab,Shift,<,>,Delete
88 if ( Shift = [ssShift] ) then
89 SForm.SelectNext(Sender as TWinControl, False, True ) // フォーカス移動(後進)
91 SForm.SelectNext(Sender as TWinControl, True, True ); // フォーカス移動(前進)
99 procedure ComRGKeyDown(Sender: TObject; var Key: Word; NextCtrl: TObject );
101 WinCtrl : TWinControl;
103 if ( Key = 13 ) then // Enter
105 WinCtrl := NextCtrl as TWinControl ;
111 procedure ComCBKeyDown(SForm: TForm; Sender: TObject; var Key: Word);
113 if ( Key = 13 ) then // Enter
116 SForm.SelectNext(Sender as TWinControl, True, True ) // フォーカス移動(前進)}
118 else if (Key >= 37) and (Key <= 40) then // <, ^, >, v
122 function LengthEdit(sSL : String; iL : Integer) : String ;
124 iSC, iCN, i : Integer ;
126 iSC := KanjiLength( sSL ) ;
138 function KanjiLength( sSource : String ) : Integer ;
140 iCNo, iNo, iCCode, iKCL : Integer;
141 wsConv, wsC1 : WideString;
144 wsConv := UTF8Decode( sSource ) ;
145 iCNo := Length( wsConv ) ;
150 wsC1 := MidStr( wsConv, iNo, 1 ) ;
151 iCCode := Ord(wsC1[1]) ;
152 if ((iCCode >= $0020) and (iCCode <= $00DF)) or ((iCCode >= $FF61) and (iCCode <= $FF9F)) then
153 iKCL := iKCL + 1 //半角文字です
155 iKCL := iKCL + 2 ; //全角文字です
158 KanjiLength := iKCL ;
161 function FloatEdit( dOrg : Double ; iSS, iLL : Integer ) : String ;
163 iCN, iNo, i : Integer ;
169 sWk := FormatFloat( '#,##0', dOrg ) ;
170 iCN := Length( sWk ) ;
174 sWk := FormatFloat( '#,##0.0', dOrg ) ;
175 iCN := Pos( '.', sWk ) - 1 ;
179 sWk := FormatFloat( '#,##0.00', dOrg ) ;
180 iCN := Pos( '.', sWk ) - 1 ;
184 sWk := FormatFloat( '#,##0.000', dOrg ) ;
185 iCN := Pos( '.', sWk ) - 1 ;
189 sWk := FormatFloat( '#,##0.0000', dOrg ) ;
190 iCN := Pos( '.', sWk ) - 1 ;
194 sWk := FormatFloat( '#,##0.00', dOrg ) ;
195 iCN := Pos( '.', sWk ) - 1 ;
200 if ( iCN < iLL ) then