L
loutian
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit162;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,uboolean;
type
tconvert=class(tboolean)
public
class function anystringtoboolean(const value:string):boolean;
end;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
{ Public declarations }
end;
var
Form1: TForm1;
implementation
class function tconvert.anystringtoboolean(const value:string):boolean;
begin
result:=(length(value)>0 and(value[1] in ['T','Y','y','t']));
end;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
messagedlg(tconvert.anystringtoboolean(edit1.text),mtinformation,[mbok],0);
end;
end.
unit uboolean;
interface
uses
sysutils;
type
tboolean=class
public
class function booleantostring(const value:boolean):string;
class function stringtoboolean(const value:string):boolean;
class function booleantoyesno(const value:boolean):string;
class function yesnotoboolean(const value:string):boolean;
end;
implementation
class function booleantostring(const value:boolean):string;
const
bools:array [boolean] of string=('false','true');
begin
result:=bools[value];
end;
class function booleantoyesno(const value:boolean):string;
const
yes_no:array[boolean] of string=('no','yes');
begin
result:=yes_no[value];
end;
class function stringtoboolean(const value:string):boolean;
begin
result:=comparetext(value,'true')=0;
end;
class function yesnotoboolean(const value:string):boolean;
begin
result:=comparetext(value,'yes')=0;
end;
end.
每次运行时,系统提示以下错误
[Error] uboolean.pas(9): Unsatisfied forward or external declaration: 'tboolean.booleantostring'
[Error] uboolean.pas(10): Unsatisfied forward or external declaration: 'tboolean.stringtoboolean'
[Error] uboolean.pas(11): Unsatisfied forward or external declaration: 'tboolean.booleantoyesno'
[Error] uboolean.pas(12): Unsatisfied forward or external declaration: 'tboolean.yesnotoboolean'
[Fatal Error] Unit162.pas(7): Could not compile used unit 'uboolean.pas'
我实在查不出哪里有问题,是不是程序有问题,请提示,谢谢
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,uboolean;
type
tconvert=class(tboolean)
public
class function anystringtoboolean(const value:string):boolean;
end;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
{ Public declarations }
end;
var
Form1: TForm1;
implementation
class function tconvert.anystringtoboolean(const value:string):boolean;
begin
result:=(length(value)>0 and(value[1] in ['T','Y','y','t']));
end;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
messagedlg(tconvert.anystringtoboolean(edit1.text),mtinformation,[mbok],0);
end;
end.
unit uboolean;
interface
uses
sysutils;
type
tboolean=class
public
class function booleantostring(const value:boolean):string;
class function stringtoboolean(const value:string):boolean;
class function booleantoyesno(const value:boolean):string;
class function yesnotoboolean(const value:string):boolean;
end;
implementation
class function booleantostring(const value:boolean):string;
const
bools:array [boolean] of string=('false','true');
begin
result:=bools[value];
end;
class function booleantoyesno(const value:boolean):string;
const
yes_no:array[boolean] of string=('no','yes');
begin
result:=yes_no[value];
end;
class function stringtoboolean(const value:string):boolean;
begin
result:=comparetext(value,'true')=0;
end;
class function yesnotoboolean(const value:string):boolean;
begin
result:=comparetext(value,'yes')=0;
end;
end.
每次运行时,系统提示以下错误
[Error] uboolean.pas(9): Unsatisfied forward or external declaration: 'tboolean.booleantostring'
[Error] uboolean.pas(10): Unsatisfied forward or external declaration: 'tboolean.stringtoboolean'
[Error] uboolean.pas(11): Unsatisfied forward or external declaration: 'tboolean.booleantoyesno'
[Error] uboolean.pas(12): Unsatisfied forward or external declaration: 'tboolean.yesnotoboolean'
[Fatal Error] Unit162.pas(7): Could not compile used unit 'uboolean.pas'
我实在查不出哪里有问题,是不是程序有问题,请提示,谢谢