文章編號: 65927 - 上次校閱: 2005年8月16日 - 版次: 2.1

使用插斷 15 十六進位的時間遞增小於 1 秒

在此頁中

全部展開 | 全部摺疊

結論

開啟計時器 (n) GOSUB 陳述式的解決方式是限制為 1 秒。

若要解決此限制 (以取得較小的時間間隔) 的三種不同方法如下:

  1. 使用時間間隔的 976 微秒的解析度的函式 86 十六進位 (或,十進位,134 函式的插斷 21) 的使用 BIOS 插斷 15 十六進位 (976 百萬分之一或.000976 的第二個)。
  2. 使用 BIOS 插斷 1A 十六進位 (十進位 26) 函式 0 解析度,以在大約 18.20648 刻度每秒 (或.05492549 秒為單位)。
  3. 播放 ON 陳述式用於在 30 秒的時間 (或.0333333).解析度
本文將告訴方法 1 上面。 若要尋找兩個其他文件說明方法 2 和 3,搜尋下列的實際單字此知識庫中:
基本計時器和增加第二個和較小
此資訊適用於 Microsoft QuickBasic 版本 4.00 4.00b,4.50 Microsoft 基本編譯器版本 6.00 和 6.00b 的 MS-DOS,並以 Microsoft 基本專業開發系統 (PDS) 7.00 和 7.10 的 MS-DOS 版本。

其他相關資訊

使用函式 86 十六進位的插斷服務常式 15 十六進位 (十進位格式: 函式 134 INT 21) 您可以延遲的 976 微秒為單位) 在間隔內執行程式。 此插斷函式只能在 IBM AT] 和 [PS/2 類別機器上正常運作並在電腦或 XT 類別電腦,這並不支援此函式上將會失敗。 如果在您的電腦上失敗,此插斷,可以使用方法 2 或 3 上面。

請注意插斷常式只為了 MS-DOS,而不支援在 OS/2 保護模式。

更多資訊有關在 MS-DOS 的插斷請參閱 「 進階 MS-DOS 程式,第二版 」,眷顧鄧肯柏,所發行的 Microsoft 按 (1988 年)。

範例程式碼

'| *******************************************************************
'|   The DELAY% function below uses an interrupt call to suspend the
'|   execution of the program for a given number of microseconds, in
'|   integrals of 976 microseconds.
'|   This program uses BIOS interrupt 15 hex with function 86 hex
'|   (or, in decimal, interrupt 21 with function 134).
'|
'|   NOTE : This interrupt only works on AT and PS/2 machines, and
'|          will fail on PC or XT class machines. The function will
'|          return a value of 1 when it fails to delay the program,
'|          and a value of 0 when it completes the call.
'|
'| *******************************************************************

DECLARE FUNCTION DELAY% (Integral AS LONG)

'|  Use the following $INCLUDE metacommand in Microsoft QuickBasic
'|  4.00/4.00b/4.50 or Basic Compiler 6.00/6.00B:
REM $INCLUDE: 'QB.BI'
'|  You must change 'QB.BI' to 'QBX.BI' above if you are using
'|  Basic PDS 7.00 or 7.10.

FUNCTION DELAY% (Integral&)
        '| Set up the register parameters used by INTERRUPT routine:
        DIM ToDOS AS RegType, FromDOS AS RegType

        '| Interrupt service 15 hex with function 86 hex will suspend
        '| the calling process for a specified interval in microseconds.
        DOSINT% = &H15
        ToDOS.Ax = &H8600

        '| Calculate the Microseconds to pause (Integrals of 976):
        MicroSeconds& = Integral& * 976

        '| The Delay value is a long integer and must be broken into
        '| the component high/low integer parts:
        ToDOS.Dx = VAL("&H" + HEX$(MicroSeconds& MOD &H10000))
        ToDOS.Cx = VAL("&H" + HEX$(MicroSeconds& \ &H10000))

        CALL INTERRUPT (DOSINT%, ToDOS, FromDOS)
        '| This interrupt service only works on a AT or PS/2 machine
        '| and will fail on PC/XT machines, and possible other machines.
        IF FromDOS.Flags AND 1 THEN
           ReturnDelay% = 1    '| Failed interrupt call
        ELSE
           ReturnDelay% = 0    '| Call Worked and should have delayed
        END IF
        '| Return the flag to the caller:
        DELAY% = ReturnDelay%
END FUNCTION
				

這篇文章中的資訊適用於:
  • Microsoft QuickBasic 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBasic 4.5 for MS-DOS
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b
  • Microsoft BASIC Professional Development System 7.0
  • Microsoft BASIC Professional Development System 7.1
關鍵字:?
kbmt KB65927 KbMtzh
機器翻譯機器翻譯
重要:本文是以 Microsoft 機器翻譯軟體翻譯而成,而非使用人工翻譯而成。Microsoft 同時提供使用者人工翻譯及機器翻譯兩個版本的文章,讓使用者可以依其使用語言使用知識庫中的所有文章。但是,機器翻譯的文章可能不盡完美。這些文章中也可能出現拼字、語意或文法上的錯誤,就像外國人在使用本國語言時可能發生的錯誤。Microsoft 不為內容的翻譯錯誤或客戶對該內容的使用所產生的任何錯誤或損害負責。Microsoft也同時將不斷地就機器翻譯軟體進行更新。
按一下這裡查看此文章的英文版本:65927? (http://support.microsoft.com/kb/65927/en-us/ )
Microsoft及(或)其供應商不就任何在本伺服器上發表的文字資料及其相關圖表資訊的恰當性作任何承諾。所有文字資料及其相關圖表均以「現狀」供應,不負任何擔保責任。Microsoft及(或)其供應商謹此聲明,不負任何對與此資訊有關之擔保責任,包括關於適售性、適用於某一特定用途、權利或不侵權的明示或默示擔保責任。Microsoft及(或)其供應商無論如何不對因或與使用本伺服器上資訊或與資訊的實行有關而引起的契約、過失或其他侵權行為之訴訟中的特別的、間接的、衍生性的損害或任何因使用而喪失所導致的之損害、資料或利潤負任何責任。
Retired KB Article依現狀不再更新的知識庫內容免責聲明
本文旨在說明 Microsoft 不再提供支援的產品。因此,本文係依「現狀」提供,不會再更新。
 

文章翻譯