这样写case语句对吗?(20分)

  • 主题发起人 royal666
  • 开始时间
R

royal666

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TFrmMain.FormActivate(Sender: TObject);<br>begin<br>{<br>&nbsp; FrmMain.borderstyle:=bsnone;<br>&nbsp; FrmMain.width:=0;<br>&nbsp; FrmMain.height:=0; &nbsp;}<br>&nbsp; ShowWindow(Handle, SW_HIDE);<br>&nbsp; if paramcount=3 &nbsp;then<br>&nbsp; begin<br>&nbsp; &nbsp; Case Paramstr(3) of<br>&nbsp; &nbsp; ' ' : if MessageDlg(目标文件已存在,是否覆盖?',mtWarning,[mbYes,mbNo],0) = mrNo then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else DelAndCopyDir(Paramstr(1),Paramstr(2));<br>&nbsp; &nbsp; 'O' : DelAndCopyDir(Paramstr(1),Paramstr(2));<br>&nbsp; &nbsp; 'N' : exit;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>&nbsp; If ParamCount &lt; 2 then<br>&nbsp; &nbsp; Erreur('Use : CopyRep &lt;dir Source&gt; &lt;dir Destination&gt;')<br>&nbsp; else &nbsp;begin<br>&nbsp; &nbsp; &nbsp; if not DirectoryExists(ParamStr(1)) then Erreur('源文件不存在.');<br>&nbsp; &nbsp; &nbsp; if not DirectoryExists(ParamStr(2)) then Erreur('目标文件不存在.');<br>&nbsp; &nbsp; &nbsp; Label1.Caption := ParamStr(1);<br>&nbsp; &nbsp; &nbsp; Label2.Caption := ParamStr(2);<br>&nbsp; &nbsp; &nbsp; CopyDir(ParamStr(1),ParamStr(2));<br>&nbsp; &nbsp; end//;<br>&nbsp; else exit;<br>end;<br><br>
 
case selectorExpression of<br><br>&nbsp; caseList1: statement1;<br>&nbsp; ...<br>&nbsp; caseListn: statementn;<br>end<br><br>where selectorExpression is any expression of an ordinal type (string types are invalid) and each caseList is one of the following:
 
这样:Case Paramstr(3)[1] of<br>
 
beta is ok.
 
多人接受答案了。
 
顶部