跳至內容

BASIC 程式設計/BASIC 入門/控制結構/DO...LOOP

來自華夏公益教科書,一個自由的教科書

在上一章我們學習瞭如何將資料輸入程式。那麼現在你將學習如何一遍又一遍地重複一項功能。請記住,在一個 BASIC 版本中,單引號 (') 右側的任何內容都是註釋,如果它們造成問題,應刪除或用不同種類的 REMARK 替換。

CLS 'Clears screen for user

DO 'Starts the Looping process, anything between this and the LOOP command will be repeated.
  PRINT "You will get this message over and over." 'Displays the message "You will get this message over and over."
LOOP ' Shows where objects should stop being looped.

此迴圈將一直持續,除非被作業系統打斷。如果你希望有一個迴圈結束的條件,可以在 LOOP 後面輸入 WHILE 或 UNTIL 關鍵字。

華夏公益教科書