請問點樣用Dev-Pascal整一個可以計時的timer??

2006-11-22 6:57 am
請問點樣用Dev-Pascal整一個可以計時的timer呢?? 而我希望呢個timer run緊個陣user可以照run其他野例如input或者計數。請大家幫幫忙吧!!! 可以的話請俾個program code我呀!!!
更新1:

先感謝子文ge幫忙, 但係你果篇文超越左我呢個中五傻仔ge智慧, 我睇左兩次都唔明......請問有無簡易d或者易明d ge方法呢...... 唔該大家!!!!

回答 (4)

2006-11-23 6:19 pm
✔ 最佳答案
Writing a Timer
The timer function takes the form.
pascal void TimerFunction(EventLoopTimerRef theTimer, void* userData)
The pascal keyword tells the compiler to use Pascal language parameter passing conventions. Timer functions require the Pascal language conventions. The userData argument is the data you supplied when you called InstallEventLoopTimer().
C++ programs that want timer functions to be member functions of a class must declare the timer to be a static function in the header file.
static pascal void TimerFunction(EventLoopTimerRef theTimer, void* userData);
You can give your timer function any name you want, but remember the name of the timer must match the name you supply to the function NewEventTimerUPP() when installing the timer.
What do you put in a timer? Generally you call a function from the timer. The following example calls the GameLoop() function for a GameApp class:
pascal void GameApp::GameLoopTimer(EventLoopTimerRef theTimer, void* userData) { GameAppPtr currentApp = (GameAppPtr)userData; currentApp->GameLoop(); }
Next (Starting a Timer)
Previous (Installing a Timer)

2006-12-01 09:02:51 補充:
如果有什麼不明白的,歡迎隨時與我聯絡:[email protected]下面那一位網友,發問者問的是用PASCAL去整TIMER,而不是要讀取時間,什麼 GetDate(Year, Month, Day, DayOfWeek);GetTime(Hour, Min, Sec, MiniSec)等等...完全是從網上隨便抄襲回來,想以長篇大論取勝,誤導別人,請自律﹗
2006-12-16 11:38 pm
上面的網友,人們答對了一半,你卻說其他人錯!
發問者是問怎樣用pascal寫timer,
不是用c++寫!

什麼 pascal void TimerFunction, EventLoopTimerRef theTimer, void userData等等...

完全是從網上隨便抄襲回來,

想以長篇大論取勝,

誤導別人,

請自律﹗
2006-12-10 11:18 pm
我仲係唔明@@''
2006-11-28 2:08 am
Hello! I am Chan Chris Ka Yin.
I found the following passage in yahoo.knowledge
It works in tpw 1.5 but not in dev-pascal
Let us solve that together so we can make the timer
P.S. I am working on the timer too


回答者 :IT_DoNT [小學級 1 級]
回答時間:2006-08-02 16:53:59
網友評價 :75% 25% 0% (目前有8人評價)
發問者評價:
檢舉
因為 GetDate 和 GetTime 兩個 Procedures 在 Turbo Pascal 1.5 for Windows 入面同其他 Dos 既 Pascal 所在既位置唔同
- Dos 版在 Dos 這個 Unit 入面
- Windows 版在 WinDos 這個 Unit 入面
所以 Windows 版既要在 uses 那行加多個 WinDos 先得
即係 uses WinDos, WinCrt;
咁 Dos 版就打 uses Dos;

==============================
Turbo Pascal for Dos
==============================

program Clock;
uses Dos;
var
Year, Month, Day, DayOfWeek: word;
Hour, Min, Sec, MiniSec: word;

begin
GetDate(Year, Month, Day, DayOfWeek);
GetTime(Hour, Min, Sec, MiniSec);
writeln('Today is ', Day, '/', Month, '/', Year);
writeln('This week remains ', 7 - DayOfWeek, ' days.');
writeln('And the time now is ', Hour, ':', Min, ':', Sec, '.', MiniSec);
end.

==============================
Turbo Pascal 1.5 for Windows
==============================

program Clock;
uses WinDos, WinCrt;
var
Year, Month, Day, DayOfWeek: word;
Hour, Min, Sec, MiniSec: word;

begin
GetDate(Year, Month, Day, DayOfWeek);
GetTime(Hour, Min, Sec, MiniSec);
writeln('Today is ', Day, '/', Month, '/', Year);
writeln('This week remains ', 7 - DayOfWeek, ' days.');
writeln('And the time now is ', Hour, ':', Min, ':', Sec, '.', MiniSec);
end.

==============================
Variables of Procedures
==============================

1. GetDate ( 年份 , 月份 , 日期 , 星期幾 );

2. GetTime ( 小時 , 分鐘 , 秒數 , 毫秒 );

** 所有 Variables 要宣告為 word


收錄日期: 2021-05-03 02:58:16
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20061121000051KK05041

檢視 Wayback Machine 備份