| 1 |
unit base2; |
| 2 |
{$IFDEF FPC} |
| 3 |
{$MODE DELPHI}{$H+} |
| 4 |
{$ENDIF} |
| 5 |
(***************************************) |
| 6 |
(* Copyright (C) 2009, SHIRAISHI Kazuo *) |
| 7 |
(***************************************) |
| 8 |
|
| 9 |
interface |
| 10 |
|
| 11 |
uses |
| 12 |
Classes, SysUtils; |
| 13 |
|
| 14 |
type |
| 15 |
EControlException=class(Exception) |
| 16 |
constructor create; |
| 17 |
end ; |
| 18 |
|
| 19 |
ERetry=class(EControlException); |
| 20 |
EContinue=class(EControlException); |
| 21 |
//EExitHandler=class(EControlException); |
| 22 |
|
| 23 |
EStop=class(EControlException); |
| 24 |
EExitFunction=class(EControlException); |
| 25 |
EExitSub=class(EControlException); |
| 26 |
EExitPicture=class(EControlException); |
| 27 |
EExitDo=class(EControlException); |
| 28 |
EExitFor=class(EControlException); |
| 29 |
|
| 30 |
type |
| 31 |
PAnsiString=^AnsiString; |
| 32 |
|
| 33 |
function NumericVariable(var x:double; a:double):PDouble; overload; |
| 34 |
function StringVariable(var s:Ansistring; const t:ansistring):PAnsiString; |
| 35 |
|
| 36 |
type |
| 37 |
StringArray=Array[0..1023] of AnsiString; |
| 38 |
PStringArray=^StringArray; |
| 39 |
|
| 40 |
type |
| 41 |
IntArray=array [0..255] of integer; |
| 42 |
PIntArray=^IntArray; |
| 43 |
type |
| 44 |
PExtended=^extended; |
| 45 |
ExtendedArray=array[0..65535] of extended; |
| 46 |
PExtendedArray=^ExtendedArray; |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
type |
| 51 |
TNval=class(Tobject) |
| 52 |
value:double; |
| 53 |
constructor create(x:double); |
| 54 |
end; |
| 55 |
|
| 56 |
TSVal=class(TObject) |
| 57 |
value:Ansistring; |
| 58 |
constructor create(const s:ansistring); |
| 59 |
end; |
| 60 |
|
| 61 |
TValList=class(TList) |
| 62 |
function itself:TValList; |
| 63 |
procedure addval(x:double);overload; |
| 64 |
procedure addval(s:ansistring);overload; |
| 65 |
destructor destroy;override; |
| 66 |
end; |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
implementation |
| 72 |
|
| 73 |
constructor EControlException.create; |
| 74 |
begin |
| 75 |
inherited create('') |
| 76 |
end; |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
function NumericVariable(var x:double; a:double):PDouble; inline; overload; |
| 81 |
begin |
| 82 |
x:=a; |
| 83 |
result:=@x |
| 84 |
end; |
| 85 |
|
| 86 |
function StringVariable(var s:Ansistring; const t:ansistring):PAnsiString;inline; |
| 87 |
begin |
| 88 |
s:=t; |
| 89 |
result:=@s |
| 90 |
end; |
| 91 |
|
| 92 |
|
| 93 |
{********} |
| 94 |
{TValList} |
| 95 |
{********} |
| 96 |
|
| 97 |
constructor TNval.create(x:double); |
| 98 |
begin |
| 99 |
inherited create; |
| 100 |
value:=x |
| 101 |
end; |
| 102 |
|
| 103 |
constructor TSVal.create(const s:ansistring); |
| 104 |
begin |
| 105 |
inherited create; |
| 106 |
value:=s; |
| 107 |
end; |
| 108 |
|
| 109 |
function TValList.itself:TValList; |
| 110 |
begin |
| 111 |
result:=self |
| 112 |
end; |
| 113 |
|
| 114 |
|
| 115 |
procedure TValList.addval(x:double);overload; |
| 116 |
begin |
| 117 |
add(TNVal.create(x)) |
| 118 |
end; |
| 119 |
|
| 120 |
procedure TValList.addval(s:ansistring);overload; |
| 121 |
begin |
| 122 |
add(TSVal.create(s)) |
| 123 |
end; |
| 124 |
|
| 125 |
destructor TValList.destroy; |
| 126 |
var |
| 127 |
i:integer; |
| 128 |
begin |
| 129 |
for i:=0 to count-1 do |
| 130 |
Tobject(items[i]).free ; |
| 131 |
inherited destroy; |
| 132 |
end; |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
end. |
| 138 |
|
| 139 |
|