全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:959
推到 Plurk!
推到 Facebook!

請問要如何設計一個可傳入參數的程式呢?

尚未結案
saam
初階會員


發表:61
回覆:75
積分:27
註冊:2003-03-03

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-04-17 17:06:55 IP:211.75.xxx.xxx 未訂閱
請問各位大大: 請問要如何設計一個可傳入參數的程式呢? 如 dir/w ,dir/w/p
hagar
版主


發表:143
回覆:4056
積分:4445
註冊:2002-04-14

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-04-17 17:19:25 IP:202.39.xxx.xxx 未訂閱
在 FormCreate Event 中 判斷 ParamCount, 然後讀取 ParamStr --- 每個人都是一本書
flyup
資深會員


發表:280
回覆:508
積分:385
註冊:2002-04-15

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-04-18 01:04:00 IP:61.225.xxx.xxx 未訂閱
依據 hagar 大大 提供訊息! // 提供這一個完整程式碼範例給你參考. // ----------------------------------------------------------- // You must store this code in a unit called Unit1 with a form // called Form1 that has an OnCreate event called FormCreate. unit Unit1; interface uses // The System unit does not need to be defined SysUtils, Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} // Include form definitions procedure TForm1.FormCreate(Sender: TObject); var cmd : string; i : Integer; begin // Before running this code, use the Run/parameters menu option // to set the following command line parameters : -parm1 -parm2 cmd := CmdLine; ShowMessage(cmd); // Show the execution command parameters // How many parameters were passed? ShowMessage('There are ' IntToStr(ParamCount) ' parameters'); // Show these parameters - note that the 0th parameter is the // execution command on Windows for i := 0 to ParamCount do ShowMessage('Parameter ' IntToStr(i) ' = ' ParamStr(i)); end; end. 執行檔可傳入參數說明: "C:\Program files\Borland\Delphi7\Projects\Project1.exe" -parm1 -parm2 There are 2 parameters Parameter 0 = C:\PROGRAM FILES\BORLAND\DELPHI7\PROJECTS\PROJECT1.EXE Parameter 1 = -parm1 Parameter 2 = -parm2 善用「注意力」,就是善於掌握「優先次序」—分清那些是重要的及不重要的。 「捨」才會「得」,集中焦距,才能發揮核心優勢。 發表人 - flyup 於 2003/04/18 01:06:48
saam
初階會員


發表:61
回覆:75
積分:27
註冊:2003-03-03

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-04-18 12:36:14 IP:211.75.xxx.xxx 未訂閱
感謝二位大大指導,惠我良多!
brucetsao
一般會員


發表:1
回覆:33
積分:11
註冊:2002-09-11

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-04-22 15:48:49 IP:61.219.xxx.xxx 未訂閱
在form procedure TSENDMAIL.FormCreate(Sender: TObject); begin application.ShowMainForm:=false; //不秀畫面 Tmp:=TStringlist.Create; if ParamCount()>=1 THEN //判斷parameter數 begin path:=paramstr(1) ; //讀parameter資料 //path:='c:\quasend.txt'; end else 去做事
Mr.Lo
一般會員


發表:0
回覆:1
積分:0
註冊:2004-04-18

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-05-26 19:06:34 IP:61.59.xxx.xxx 未訂閱
感謝大大指導,惠我良多!
系統時間:2024-05-17 16:24:57
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!