【discuz源码带后台】【分时ddx指标源码】【织梦表单源码】unit源码
1.SystemVerilog $unit ç¼è¯åå
ä»ç»
2.Incompatible types: 'Integer' and 'String'
3.ç¨delphiå计ç®å¨
SystemVerilog $unit ç¼è¯åå ä»ç»
SVä¸å¢å äºç¼è¯åå çæ¦å¿µï¼å°±æ¯ SVæºæ件ç¼è¯çæ¶åï¼ä¸èµ·ç¼è¯çæææºæ件ç¼è¯åå åå¨æ索顺åºä¸æ第ä¸ä½
举个æ å
è¿éæ们å建äºä¸¤ä¸ªå ï¼a_dpkåb_dpkï¼ï¼ä¸¤ä¸ªå ä¸çé½åªæä¸ä¸ªæå°å½æ°ï¼åæ¶moduleä¸ä¹æä¸ä¸ªæå°å½æ°ï¼ï¼æå°å½æ°ç¨äºæ示æå¨ä½ç½®ï¼
æå°ç»æå¦ä¸ï¼
image-
è¿è¡ç»æå¦ä¸ï¼
å¯ä»¥çå°æ¤æ¶æå°çæ¯å¨moduleä¸å¯¼å ¥çå
é£ä¹æ¥ä¸æ¥æ们æå¨moduleä¸å¯¼å ¥çå 注éæï¼å³æ import a_dpk::*; 注éæ
ä¸é¢è¿è¡ç»æï¼
æ¤æ¶ç»äºæå¯¼å ¥$unitç¼è¯åå åçå 容æå°åºæ¥äº
è¿ä¹å°±æ¯ä¸ºä»ä¹ ç¼è¯åå åå¨æç´¢è§åä¸æ第ä¸
é£ä¹ä¸ºä»ä¹ç¼è¯åå åå« $unit å¢ï¼æ们å¯ä»¥åæ代ç æ´æ¹ä¸ä¸
æ们æ b_dpk 注éæï¼ä½ä¾æ§å°å ¶å¯¼å ¥ï¼ççè¿è¡ç»æ
è¿éç´æ¥æ¾ç¤ºéè¯¯å¨ $unit ï¼æ许$unitåªæ¯ä¸ä¸ªå称ï¼å°±å¥½åä¸ä¾ä¸moduleå½å为 test_tb ä¸æ ·
æ ¼å¼ä¸ºï¼
è¿æ¯Cè¯è¨ä¸å¸¸ç¨çæå·§ï¼å¦æ第ä¸æ¬¡éå°å¯¼å ¥è¯å¥å°å ¶ç¼è¯å°$unitä¸ï¼å次åºç°åä¸ä¼ç¼è¯
ä¸é¢æ们å°ä¸ç¯ç¬è®°ä¸çå ç¨è¿ç§æ¹å¼ä»¿çä¸ä¸ï¼å ç»åºä¸ç¯ç¬è®°ä¸å çå 容
æ们å°æ件åå½å为 definitions.dpk ï¼å ¶ä¸åç¼ .dpk æ¯é便起ç
ä¸é¢æ¯æºç åæµè¯æ件
è¿è¡ç»æå¦ä¸
æ¬æ主è¦åè
Incompatible types: 'Integer' and 'String'
好åçè¿æ¨çé®é¢ï¼å 为没æçæï¼ææ没æ人åçï¼ä½ çæææ¯ æ ¹æ® açå¼ï¼memo1.Text := 'æ¨çåçå ¨é¨æ£ç¡®ï¼â
è¿é åºè¯¥è¿æ ·åï¼ï¼æºç ï¼ï¼
unit Unit1;
interface
uses
Windows,源码discuz源码带后台 Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
ListBox1: TListBox;
procedure FormCreate(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{ $R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
ListBox1.Items.Add('4');
ListBox1.Items.Add('对');
ListBox1.Items.Add('é');
ListBox1.Items.Add('å½æ°');
ListBox1.Items.Add('æ¢è¡');
ListBox1.Items.Add('ä¸æ¯');
ListBox1.Items.Add('èµ°äº');
ListBox1.Items.Add('é');
ListBox1.Items.Add('对');
ListBox1.Items.Add('delphi');
end;
procedure TForm1.ListBox1Click(Sender: TObject);
var
a:integer;
begin
a := ListBox1.ItemIndex;
case a of
0:memo1.Text := ListBox1.Items[a]+' æ¨çåçå ¨é¨æ£ç¡®ï¼';
1:memo1.Text := ListBox1.Items[a]+' æ¨çåçå ¨é¨æ£ç¡®ï¼';
2:memo1.Text := ListBox1.Items[a]+' æ¨çåçå ¨é¨æ£ç¡®ï¼';
3:memo1.Text := ListBox1.Items[a]+' æ¨çåçå ¨é¨æ£ç¡®ï¼';
4:memo1.Text := ListBox1.Items[a]+' æ¨çåçå ¨é¨æ£ç¡®ï¼';
5:memo1.Text := ListBox1.Items[a]+' æ¨çåçå ¨é¨æ£ç¡®ï¼';
6:memo1.Text := ListBox1.Items[a]+' æ¨çåçå ¨é¨æ£ç¡®ï¼';
7:memo1.Text := ListBox1.Items[a]+' æ¨çåçå ¨é¨æ£ç¡®ï¼';
8:memo1.Text := ListBox1.Items[a]+' æ¨çåçå ¨é¨æ£ç¡®ï¼';
9:memo1.Text := ListBox1.Items[a]+' æ¨çåçå ¨é¨æ£ç¡®ï¼';
end;
end;
end.
-------------------------------------------------
ä½ å¯ä»¥æ ¹æ®å ·ä½æ¡ä»¶ï¼case a of
-------------------------------------------------
ç¨delphiå计ç®å¨
è¿æ¯æºä»£ç ï¼
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
SpeedButton7: TSpeedButton;
SpeedButton8: TSpeedButton;
SpeedButton9: TSpeedButton;
SpeedButton: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
SpeedButton: TSpeedButton;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton: TSpeedButton;
SpeedButton: TSpeedButton;
SpeedButton: TSpeedButton;
SpeedButton: TSpeedButton;
StaticText1: TStaticText;
SpeedButton0: TSpeedButton;
SpeedButton: TSpeedButton;
SpeedButton: TSpeedButton;
GroupBox1: TGroupBox;
procedure SpeedButton1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure SpeedButtonClick(Sender: TObject);
procedure SpeedButtonClick(Sender: TObject);
procedure SpeedButtonClick(Sender: TObject);
procedure SpeedButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
restart: Boolean;
isfirst: Boolean;
fir_num,sec_num: String;
sign: integer;
result: real;
save: String;
implementation
{ $R *.dfm}
function count(sign: integer):real;
begin
case sign of
1: result:=strtofloat(fir_num)+strtofloat(sec_num); //为å å·æ¶
2: result:=strtofloat(fir_num)-strtofloat(sec_num); //为åå·æ¶
3: result:=strtofloat(fir_num)*strtofloat(sec_num); //为ä¹å·æ¶
4: begin
try
result:=strtofloat(fir_num)/strtofloat(sec_num); //为é¤å·æ¶
except
ShowMessage('é误!');
form1.close;
end; //é¤æ°ä¸º0æ¶,ååºå¼å¸¸å¤ç
end;
end;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
var
i: integer;
begin
if restart then //å¦ææ¯éæ°å¼å§è¾å ¥,åæ¸ é¤åæ¥çæä½æ°,并设置isfirst为True
begin
isfirst:=True;
fir_num:='';
sec_num:='';
restart:=False;
end;
if isfirst then //å¦ææ¯ç¬¬ä¸ä¸ªæä½æ°
begin
if (sender as TSpeedButton).Caption='.' then //å¦æè¾å ¥çæ¯å°æ°ç¹
begin
if (strlen(pChar(fir_num))<=0) then //å¦æ第ä¸ä¸ªæä½æ°å¹¶æªè¾å ¥
fir_num:='0.'
else
for i:= 1 to strlen(pChar(fir_num)) do
if fir_num[i]='.' then exit;
//å¦æ第ä¸ä¸ªä¸å·²å«æå°æ°ç¹èåè¾å ¥å°æ°ç¹,åéåº
end;
if (strlen(pChar(fir_num))>0) and (fir_num[1]='0') then //å¦ææé«ä½ä¸º0
begin
if ((sender as TSpeedButton).Caption='.') then
fir_num:='0.'
else
begin
if strlen(pChar(fir_num))>1 then //å¦ææ¯å°æ°,å继ç»è¾å ¥
fir_num:=fir_num+(sender as TSpeedButton).Caption
else
fir_num:=(sender as TSpeedButton).Caption;
//å¦æä¸æ¯å°æ°,åå»ææé«ä½ç0
end;
end
else
fir_num:=fir_num+(sender as TSpeedButton).Caption;
StaticText1.Caption:=fir_num;
end
else
begin
if (sender as TSpeedButton).Caption='.' then //å¦æ第äºä¸ªæä½æ°å¹¶æªè¾å ¥
begin
if (strlen(pChar(sec_num))<=0) then
sec_num:='0.'
else
for i:= 1 to strlen(pChar(sec_num)) do
if sec_num[i]='.' then exit;
//å¦æ第äºä¸ªä¸å·²å«æå°æ°ç¹èåè¾å ¥å°æ°ç¹,åéåº
end;
if (strlen(pChar(sec_num))>0) and (sec_num[1]='0') then //å¦ææé«ä½ä¸º0
begin
if ((sender as TSpeedButton).Caption='.') then
sec_num:='0.'
else
begin
if strlen(pChar(sec_num))>1 then //å¦ææ¯å°æ°,å继ç»è¾å ¥
sec_num:=sec_num+(sender as TSpeedButton).Caption
else
sec_num:=(sender as TSpeedButton).Caption;
//å¦æä¸æ¯å°æ°,åå»ææé«ä½ç0
end;
end
else
sec_num:=sec_num+(sender as TSpeedButton).Caption;
StaticText1.Caption:=sec_num;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
StaticText1.Caption:='0.'; //设置StaticText1åå§æ¾ç¤ºä¸º0.
restart:=False;
Isfirst:=True;
fir_num:='';
sec_num:='';
end;
procedure TForm1.SpeedButtonClick(Sender: TObject);
begin
if (fir_num<>'') and (sec_num<>'') then
//å¦æ两åæä½æ°é½ä¸ä¸ºç©º
begin
result:=count(sign); //è°ç¨å½æ°,è¿å计ç®ç»æ
fir_num:=floattostr(result);
sec_num:='';
StaticText1.Caption:=floattostr(result);
end;
sign:=(sender as TSpeedButton).Tag;
isfirst:=False;
restart:=False;
end;
procedure TForm1.SpeedButtonClick(Sender: TObject);
begin
if (sec_num<>'') then
//å¦æ第äºä¸ªæä½æ°ä¸ä¸ºç©ºåè¿åç»æ
begin
result:=count(sign);
fir_num:='';
fir_num:=fir_num+floattostr(result);
StaticText1.Caption:=floattostr(result);
sec_num:='';
end;
restart:=true;
end;
procedure TForm1.SpeedButtonClick(Sender: TObject);
begin
restart:=True;
fir_num:='';
sec_num:='';
self.StaticText1.Caption:='0.';
end;
procedure TForm1.SpeedButtonClick(Sender: TObject);
begin
Close;
end;
end.