unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
TFlatButtonUnit;
type
TMember = packed record
Info : array[0..10] of array[0..10] of string;
end;
TForm1 = class(TForm)
FlatButton1: TFlatButton;
procedure FlatButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
member,testmember : TMember;
implementation
{$R *.DFM}
procedure TForm1.FlatButton1Click(Sender: TObject);
//var
// testmember : Tmember;
begin
testmember.Info[0,0] := 'asfadfdfsgdsgfdsgsdgfsdgsdfgsdgfsdgdsfg';
if member <> testmember then//여기서 타입이 틀리다는 메시지가 나옵니다..
member := testmember;
showmessage(member.Info[0,0]);
end;
end.
안녕하세요...
님의 코드에서
if member <> testmember then
이러한 비교는 의미가 없습니다....
이미 member와 testmember는 메모리가 따로 할당되어있기때문이죠...
이런한 비교를 사용하고 싶다면 포인터를 이용해야합니다...
포인터를 쓰면 복잡해지니까....
if member.Info[0, 0] <> testmember.Info[0, 0] then
이런식으로필드를 비교해서 사용하시면 됩니다...
그리고
member := testmember;
이 코드는 testmember의 내용을 member로 카피합니다....
메모리는 각각 따로 존재하구요...
기럼...
초보초보 wrote:
> unit Unit1;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
> TFlatButtonUnit;
>
> type
>
> TMember = packed record
> Info : array[0..10] of array[0..10] of string;
>
> end;
>
>
>
> TForm1 = class(TForm)
> FlatButton1: TFlatButton;
> procedure FlatButton1Click(Sender: TObject);
> private
> { Private declarations }
> public
> { Public declarations }
> end;
>
> var
> Form1: TForm1;
> member,testmember : TMember;
> implementation
>
> {$R *.DFM}
>
> procedure TForm1.FlatButton1Click(Sender: TObject);
> //var
> // testmember : Tmember;
> begin
>
> testmember.Info[0,0] := 'asfadfdfsgdsgfdsgsdgfsdgsdfgsdgfsdgdsfg';
>
> if member <> testmember then//여기서 타입이 틀리다는 메시지가 나옵니다..
> member := testmember;
> showmessage(member.Info[0,0]);
>
>
> end;
>
> end.
>