跳轉到內容

Chipmunk Basic 袖珍手冊

75% developed
來自華夏公益教科書,開放的書籍,開放的世界
(從Chipmunk Basic 幫助重定向)

Chipmunk Basic 袖珍手冊,由Ron H Nicholson為 Mac OS X (Snow Leopard) 或更新版本的免費軟體直譯器提供,該直譯器用於名為 Chipmunk Basic (版本 3 版本 6 更新 6 補丁 0) 的BASIC 程式設計語言。一些語句僅在 GUI 版本中有效,其他語句透過命令列介面或兩者兼而有之。大多數命令和語句在其他支援的平臺(如 Linux 或 Microsoft Windows)上應該或多或少地以相同的方式工作。如果您使用高階語法檢查編輯器(如 OS X 的 TextWrangler 或 Windows 上的 Notepad++)編寫語句,則不需要以行號開頭。請參閱本頁底部附近的下載部分。
內建的幫助系統非常有限,但由於這是一個開放專案,它隨時可能得到擴充套件。本文件的某些部分和段落也涵蓋了完整參考的一部分。
請嘗試學習Chipmunk Basic 手冊頁和自述檔案或作者的網站。[1]
為了快速入門,請首先按以下順序閱讀以下主要部分,而各部分主要按字母順序排列,方便讀者使用。

命令 語句 函式 運算子 檔案 圖形 聲音 物件 特殊
basic
  • 在作業系統的提示符下,可以鍵入basic,可選地後跟路徑和/或檔名,以啟動(現有的)BASIC 程式,該程式預設情況下會顯示其提示符>
  • 程式名稱應具有.bas副檔名,以便在開啟對話方塊中顯示。
  • 另請參閱 - 語句 檔案
clear
  • 所有變數都被清除,如果適用(在等情況下)則被釋放。不要與語句cls混淆,cls用於清除計算機螢幕上的字元和圖片,並將游標置於左上角。
cont
  • 返回到發生 停止 或錯誤的地址之後的地址。
del FromLine { - ToLine }
  • 從當前 progfile 中刪除一行(或多行),例如:del 40-90 刪除第 40 到 90 行。
edit LineNumber
  • 內建編輯器使用類似 vi 的命令在一行上進行操作(使用 ctrl+c 撤銷錯誤的更改)。
i => 插入到鍵為止
x => 刪除一個字元
A => 追加到行尾
bye 或
exit 或
quit
  • 退出解釋並返回到您來自的級別。這些命令之一後,應該關閉開啟的檔案。
list { { from# } { - [[#LineNum|to#} }
  • 所有引數都是可選的,在螢幕上列出當前 prog 的行。
none => 整個程式,當然,如果沒有行編號,這是唯一的選擇
only from# => 從 from# 到最後
only - to# => 從第一個到 to#
both => 從 from# 到 to#
load String#Expr
  • 將上面表示式得出的名稱的儲存檔案移動到記憶體中,以便 執行
  • 注意:以 # 開頭的行被視為註釋。 編號行 最多為 2147483647(231 - 1)是有效的。
merge ProgFile
  • ProgFile 與記憶體中的程式合併。具有相同編號的行將被替換,不存在的行將被新增,因此合併的程式可以被執行,如果你願意,可以 儲存
new
  • 清除所有變數,關閉所有檔案,並將程式借用的記憶體返回給作業系統。
renum ProgFile { {start}, {increment}, {low_limit} , {high_limit} }
  • 重新編號當前檔案或 ProgFile(如果提供)。所有 行號引數 都是可選的。預設值為 10,10,1,結果為 10,20,30...
  • 使用 low_limits 和 high_limit,可以重新編號檔案的特定部分。所有相關的 go*-語句(在限制內)都會改變。
run {ProgFile) , {StartLine}
  • 從第一行或提供的行開始執行記憶體中存在的程式或命名的程式。
save (ProgFile)
  • 將駐留在 RAM 中的程式儲存到磁碟上

constants

[編輯 | 編輯原始碼]
常量可以是雙引號 (") 中的文字文字、遵循 IEEE 雙精度格式規則的數字,或者以下之一

非零 (<>0)

零 (0)

列印 3.141593

directory

[編輯 | 編輯原始碼]
files ' 列出當前目錄。
files path$, any$ ' 設定當前目錄。
errorstatus$ ' 之後將返回路徑。
open filename$ for input as #1
open "SFGetFile" for input as #3
while not eof(3) : input #3,a$ : print a$ : wend : close #3
open "SFPutFile" for output as #4
x = fgetbyte #3
' 從檔案中獲取一個位元組;
get
' 從控制檯或終端接收一個字元
input my_prompt$, y
' 在請求數字時設定您自己的提示。
input s$
' 提示輸入字串。
' 將整個輸入行放入 s$ 中。
input x
' 輸入一行。轉換為數字。
input #3, s$
' 從檔案輸入(必須先開啟)。
print "hello"
print "hello"; ' 列印時不帶回車符或換行符。
print 1+2
print #4,s$ ' 列印到檔案(必須先開啟);
print format$(x, "$###.##") ' 列印格式化的金額。
print { # FNUM, } using STRINGVAL ; VAR { [ , | ; ] VAR ... } '類似於上面的格式
gotoxy x,y ' 將游標定位在控制檯視窗中。(0 原點)
print fre ' GUI(圖形使用者介面)版本中的特殊變數
20971520 ' 如果您使用 CLI(命令列介面),則為 0
' 一如既往:YMMV(您的里程可能會有所不同)

serial-ports

[編輯 | 編輯原始碼]
open "COM1:" for input as #3 ' 需要 CTB 序列工具。
open "COM1:" for output as #4 ' 首先開啟輸入。
if not eof(3) then i = fgetbyte(3)'
open "COM3: 19200" for input as #5 ' 使用舊的序列驅動程式。

functions

[編輯 | 編輯原始碼]

函式是用於轉換或格式化資料的過程,以便顯示資訊。

abs 去除數字的符號。例如 abs(-1234)=1234

asc(A$) 顯示字元 A$ 的 ASCII 碼。反向操作為 chr$

chr$(n) 顯示 ASCII 碼為 n 的字元。反向操作為 asc。在 Mac OSX {3.6.6(b0)} 的終端版本和 GUI 版本之間,如果 n>127(即 DEL),則存在差異。
有關如何使用此函式的示例,請參見 XFA01
field$(my_str$, word_num) ' 從句子中擷取單詞。
field$(s$, n, seperator_char$) ' 空格為預設分隔符。
format$( , 字串表示式 )
返回根據格式字串表示式格式化的值的字串表示形式。後者的格式與使用 print語句相同。
a$ = inkey$ ' 輪詢鍵盤輸入。非阻塞。

此函式用於將數字轉換為字串,例如:print "this is my number:"+str$(123+2),輸出:this is my number:125。在前面的示例中,混合字串和整數將產生型別不匹配錯誤

一個更有趣的例子,在基於 Unix 的機器(如 Mac OS)上,使用 ls、awk、str$ 和 system$ 列出資料夾/Users/nmm/Desktop/中的前 3 個檔案。

10 FOR n=1 TO 3

20 PRINT system$("ls /Users/nmm/Desktop| awk '(NR=="+str$(n)+")")

30 NEXT n

ubound

[edit | edit source]

ucase$

[edit | edit source]

圖形

[edit | edit source]

顏色

[edit | edit source]
graphics color r,g,b ' 紅色、綠色、藍色值(範圍 0-100)
graphics color 100,100,100 ' 白色
graphics color 100, 0, 0 ' 紅色

繪圖

[edit | edit source]
moveto x,y ' 設定起點。
lineto x,y ' 繪製一條線到該終點。
pset x,y ' 繪製一個點。
graphics circle r
graphics rect x1,y1, x2,y2 ' 繪製一個矩形。
graphics fillrect x1,y1, x2,y2 ' 也可用於繪製填充橢圓。

圖形函式

[edit | edit source]
botton_down = mouse(0)
current_x = mouse(1)
current_y = mouse(2)
last_click_x = mouse(3)

圖形視窗

[edit | edit source]
graphics 0 ' 使視窗顯示。
' 重新整理圖形。
graphics window w,h ' 更改大小。
graphics window x,y, w,h ' 移動視窗。
graphics -1 ' 隱藏圖形視窗。
graphics drawtext s$ ' 繪製文字。

圖片

[edit | edit source]
graphics pict x, y, filename$ ' 顯示 PICT 檔案。
call "savepicture", fname$ ' 儲存 PICT 檔案。

精靈

[edit | edit source]
down ' 使用 ResEdit 建立您自己的精靈。
pendown
penup
sprite 1, 100,50, 128 ' 在 (100,50) 處繪製精靈 #1。
sprite n, x,y, rsrc_id ' 精靈是 ICN# 圖示影像,內建精靈 rsrc_id 為 128 到 142。
sprite n forward x ' 將精靈 #n 移動 x 畫素。
sprite n turn d ' 逆時針旋轉 d 度。
turnleft
turnright
up

使用者介面

[edit | edit source]
a$ = inputbox("prompt", "title", "default", 0) ' 彈出對話方塊並請求輸入。
graphics button title$, x,y,w,h,asc("t") ' 彈出按鈕,輸入字母 "t"。
graphics button "",-1 ' 清除所有按鈕。

物件

[edit | edit source]
OOP - 面向物件程式設計 - 這裡只是一些語法提示 -
class my_class [ extends super_class_name ]
{public|private} x as {integer|double|string}
... ' 等等
sub member_function_name() ' 定義公共成員函式。
this.x = ...
member_function_name = return_value
end sub
end class ' 結束類定義
dim a as new my_class ' 建立一個例項。
a.member_function_name() ' 呼叫成員函式。

運算子

[edit | edit source]

算術

[edit | edit source]
+

用數字相加 print 4 + 2 顯示 6
字串 一起使用時,加號表示連線。

NamF$="Jimmy " : NamL$="Wales" : print NamF$ + NamL$
結果是 Jimmy Wales
-

減法。 print 6 - 4 的結果為 2

乘法。 print 4 * 2 的結果為 8

/

除法。 print 8 / 2 將返回 4

^

指數。 print 2 ˆ 3 給出 8

取模

模運算,即計算左數除以右數後的餘數 7 mod 2 = 1

布林代數

[edit | edit source]
and

按位取消設定。 15 (=1111) and 5 (=0101) 得出 5

or

按位設定(包含)。 5 or 2 (0010) = 7 (0111)

xor

相似,但它是互斥的。 15 xor 6 (0110) = 9 (1001)

比較

[edit | edit source]
not

在比較變數或常量時取反。

if not fre then print "via CLI" else print "GUI" : endif
>

測試左邊的值是否大於右邊的值。

if fre > 32767 then print "Available memory should be enough for normal use"
<
if Age% < 18 then print “需要父母的同意才能結婚”
>=
if Speed >=50.1 then print "這個城市有超速罰款的風險"
<=
if dat_brn% <= 1995 then print "明年你就可以投票,也許更早"
<>

測試左邊的值是否不等於右邊的值。

if left$(namf$,5) <> "Admin" then print "Welcome, guest"
=

將值分配給變數或在比較欄位時測試是否相等。

Xmas$="Dec25-26"
if mo% = 7 or mo% = 8 then print "在北半球一定是夏季"

聲音

[edit | edit source]
sound 800, 0.5, 50 ' 播放持續半秒的聲音。
sound freq,dur,vol ' 赫茲、秒、音量 [0 到 100]
sound 0, rsrc_id ' 播放 snd 資源。
sound -2,voice,key,velocity,seconds [,channel] ' sound -2 需要 Quicktime 2.1 Midi

摩爾斯電碼

[edit | edit source]
morse "cq de n6ywu"
morse my_string$,20,40,13,700 ' 點、音量、每分鐘字數、赫茲

語音

[edit | edit source]
say "hello"
' 需要 Speech Manager 擴充套件
say my_string$, 196, 44, 1
' 速率、音調、聲音
say
' 讀取控制檯視窗
print macfunction("numSpeakers")
print macfunction("getSpeaker")
' 當前語音名稱

特殊

[edit | edit source]
Mac 特定函式
date$ time$ timer doevents
call "wait", 1 ' 等待一秒鐘。
fre ' 應用程式堆中的空閒記憶體

清除螢幕。

cls : print "Welcome to Chipmunk Basic"

輸入一些靜態整數、實數和/或文字(在雙引號(")之間)以填充陣列、變數等。

data ...{,...}* : read ... : restore ...
rem 在一個農場裡,有一些動物,它們有型別名稱,在房屋或籠子、馬廄等中的數量。
dim t%(3) : data "|7|15|15|(END)","animals|5|3","cat|3|0","dog|1|1"
data "horse|0|0","rabbit|0|2","chicken|0|9","(END)|15|15"
read a$ : s$=left$(a$,1) : d%=len(field$( a$, -1, s$ )) : g$=right$(a$,len(a$)-1) : e$=field$( g$, d%, s$ ) : d%=1
while d% < len(field$( a$, -1, s$ ))
  t%(d%-1)=val(field$( g$, d%, s$ )) : d%=d%+1
wend
for f%=3 to 7 : if field$( a$, f% - 2, s$ ) = e$ then exit for : end if
dim r$(3) : dim q$(t%(0),t%(1),t%(2)) :rem 模式和表
for f% = 0 to 3 : read r$(f%) : if r$(f%) = e$ then exit for : end if : next f% : m% = f% - 1
參見 弧度
dim ... : erase ...
特殊情況是在 SDBM 格式中定義資料庫。
dim DBSTRINGVAR as dbm$( STRINGEXPR )
使用 STRINGEXPR 中包含的檔名開啟一個 sdbm 資料庫檔案。如果不存在,則建立一個數據庫。
可以透過使用或儲存到 DBSTRINGVAR(STRINGKEY)命名的陣列字串變數來訪問此資料庫。
示例:mydb$(key$) = somevalstr$; : print mydb$(key$)
close DBSTRINGVAR
如果使用該變數名打開了一個 sdbm 資料庫檔案,則關閉該檔案。
end
  • 可選語句,明確顯示程式檔案的邏輯結束
for ...=... to ... step ... next ...
gosub ... return
goto ...
if ... then ... else ... endif
{let} ...=...
  • 說明性的或出於相容性原因,因為如果第一個詞是 變數 定義,則隱含了這一點。
peek( addr { , size_val } )
顯示記憶體位置addr處 1 個位元組或更多位元組的內容,具體取決於size_val(2、4 或 8)。要更改:poke
poke ADDR_EXPR, DATA_EXPR { , SIZE_VAL }
更改已定址位置的內容(參見 peek)
radians : degrees
  • 直譯器指令,指定對三角函式(如 cos、sin、tan 等)使用什麼單位。
rem
select case
stop 導致中斷,這在例如對應用程式進行更改、除錯、中止或僅繼續時很有用。
sub ... : end sub
while ...{=...} wend : exit while

子程式

[編輯 | 編輯原始碼]
參見 sub
在當前程式中的其他位置執行一個或多個編號行
10 print "Power(s) of two"
gosub 50 : print "Ok" : end
50 print "To quit type number <0 or >8"
input "FromExp",n% : if n%<0 then return
90 m%=2
for e%=n% to n%+7 : s% =m% ^ e% : : if s%>32767 then return
參見 gosub
執行命名子程式或自定義呼叫,包括引數。
sub mumble(param1, param2) ' 定義具有 2 個引數的子程式。
mumble = 7 + param1 ' 設定返回值
end sub
x = mumble(1) ' 呼叫子程式。額外的引數被設定為 0。


IOS (HotPaw Basic 1.5.6)
Chipmunk Basic 直譯器檔案(版本)
(3.6.6)
MacOS 10.13-14 (1.368.2116 beta)
OS X 10.9-12 (1.367.2627)
OS X 10.6+ Intel (3.6.6)
OS X 10.5/6 (3.6.5)
OSX 10.x (3.6.4)
Classic 9 (3.6.3)

樹莓派

[編輯 | 編輯原始碼]
armv6l 命令列可執行檔案 + 手冊頁 (3.6.7b6 beta)
2000/XP/7 (3.6.5b6)
其他 (3.6.5b3)
  • Shapedraw anoved.net,於 2019 年 9 月 3 日訪問
XFAT - 顯示 ASCII 字元表 0-127 (CLI) 或 0-255 (GUI)

輸出可能非常依賴於系統和/或版本。
以下是它在 3.6.6(b0) 上的 Mac's OSX 10.6.8 又名 Snow Leopard 上的外觀。
在 3.6.8(b2) 上的 macOS 11.2 (Big Sur) 上,它不幸地不再像這樣工作了;所有從 128 到 255 的字元都顯示“#”。

a-3 XFAT.bas rvup1.9.26.22 'eXample Formatted AscTable' Chipmunk BASIC v3.6.6(b0)
   0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31
 nul soh stx etx eot enq ack bel  bs  ht  lf  vt  ff  cr  so  si dle dc1 dc2 dc4 dc4 nak syn etb can  em sub esc  fs  gs  rs  us
0x00  01  02  03  04  05  06  07  08  09  0a  0b  0c  0d  0e  0f  10  11  12  13  14  15  16  17  18  19  1a  1b  1c  1d  1e  1f
  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63
 ' ' '!' '"' '#' '$' '%' '&' ''' '(' ')' '*' '+' ',' '-' '.' '/' '0' '1' '2' '3' '4' '5' '6' '7' '8' '9' ':' ';' '<' '=' '>' '?'
0x20  21  22  23  24  25  26  27  28  29  2a  2b  2c  2d  2e  2f  30  31  32  33  34  35  36  37  38  39  3a  3b  3c  3d  3e  3f
  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95
 '@' 'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O' 'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z' '[' '\' ']' '^' '_'
0x40  41  42  43  44  45  46  47  48  49  4a  4b  4c  4d  4e  4f  50  51  52  53  54  55  56  57  58  59  5a  5b  5c  5d  5e  5f
  96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
 '`' 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z' '{' '|' '}' '~' del
0x60  61  62  63  64  65  66  67  68  69  6a  6b  6c  6d  6e  6f  70  71  72  73  74  75  76  77  78  79  7a  7b  7c  7d  7e  7f
 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
 'Ä' 'Å' 'Ç' 'É' 'Ñ' 'Ö' 'Ü' 'á' 'à' 'â' 'ä' 'ã' 'å' 'ç' 'é' 'è' 'ê' 'ë' 'í' 'ì' 'î' 'ï' 'ñ' 'ó' 'ò' 'ô' 'ö' 'õ' 'ú' 'ù' 'û' 'ü'
0x80  81  82  83  84  85  86  87  88  89  8a  8b  8c  8d  8e  8f  90  91  92  93  94  95  96  97  98  99  9a  9b  9c  9d  9e  9f
 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
 '†' '°' '¢' '£' '§' '•' '¶' 'ß' '®' '©' '™' '´' '¨' '≠' 'Æ' 'Ø' '∞' '±' '≤' '≥' '¥' 'µ' '∂' '∑' '∏' 'π' '∫' 'ª' 'º' 'Ω' 'æ' 'ø'
0xa0  a1  a2  a3  a4  a5  a6  a7  a8  a9  aa  ab  ac  ad  ae  af  b0  b1  b2  b3  b4  b5  b6  b7  b8  b9  ba  bb  bc  bd  be  bf
 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
 '¿' '¡' '¬' '√' 'ƒ' '≈' '∆' '«' '»' '…' ' ' 'À' 'Ã' 'Õ' 'Œ' 'œ' '–' '—' '“' '”' '‘' '’' '÷' '◊' 'ÿ' 'Ÿ' '⁄' '€' '‹' '›' 'fi' 'fl'
0xc0  c1  c2  c3  c4  c5  c6  c7  c8  c9  ca  cb  cc  cd  ce  cf  d0  d1  d2  d3  d4  d5  d6  d7  d8  d9  da  db  dc  dd  de  df
 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
 '‡' '·' '‚' '„' '‰' 'Â' 'Ê' 'Á' 'Ë' 'È' 'Í' 'Î' 'Ï' 'Ì' 'Ó' 'Ô' '' 'Ò' 'Ú' 'Û' 'Ù' 'ı' 'ˆ' '˜' '¯' '˘' '˙' '˚' '¸' '˝' '˛' 'ˇ'
0xe0  e1  e2  e3  e4  e5  e6  e7  e8  e9  ea  eb  ec  ed  ee  ef  f0  f1  f2  f3  f4  f5  f6  f7  f8  f9  fa  fb  fc  fd  fe  ff
done
Break  in line 220
>list
100 rem Clear screen - make table of control characters and show your own app+int/vsn_id & first 32 codeNumbers
110 v$ = fn version$() : g% = instr(v$,"graphics") : option base 0
120 if g% = 0 then h$ = "app" else h$ = "a"+mid$(v$,g%+8,2)
130 cls : dim i$(32) : for j% = 0 to 32 : read i$(j%) : next j%
140 print h$;" XFAT.bas rvup1.9.26.22 'eXample Formatted AscTable' "+left$(v$,instr(v$,",")-1)
150 k% = -32 : gosub 240 : for j% = k%+32 to l%+32 : print i$(j%); : next j% : print : gosub 320
160 rem print all codelines until del (0x7f) in a loop & finish
170 while j% < 97 : gosub 310 : wend : if g% = 0 then 200
180 rem GUI-mode when 'graphics' is found in builtin FuNct 'version$()'
190 while j% < 225 : gosub 310 : wend
200 print "done"
210 rem Break so user can decide to change, continue, list, quit, restart etc. r1: added hexadecimal codePoints
220 stop
230 rem SubProcedure to show characterCodes
240 if k% = 64 then l% = k%+30 else l% = k%+31
250  for j% = k%+32 to l%+32 : print right$("   "+str$(j%),4); : next j% : if j% = 127 then print " 127"; : j% = j%+1
260  print : return
270 rem ASCII-characters contained in a line followed by a line containing their hexadecimal value
280 for j% = k%+32 to l%+32 : print " '";chr$(j%);"'"; : next j% : if j% = 127 then print i$(32); : j% = j%+1
290  print : gosub 320 : return
300 rem both codes and content
310 k% = j%-32 : gosub 240 : gosub 280 : return
320 for j% = k%+32 to k%+63 : if j% mod 32 = 0 then
330  print "0x";hex$(j%,2);
340    else
350    print "  ";hex$(j%,2);
360  endif
370 next j% : print : return
380 rem 'database' of special chars that are making a mess of your screen if printed as is
390 data " nul"," soh"," stx"," etx"," eot"," enq"," ack"," bel","  bs","  ht","  lf","  vt","  ff","  cr","  so","  si"
400 data " dle"," dc1"," dc2"," dc4"," dc4"," nak"," syn"," etb"," can","  em"," sub"," esc","  fs","  gs","  rs","  us"
410 data " del"

術語表

[編輯 | 編輯原始碼]

表示式

[編輯 | 編輯原始碼]
表示式是對 常量變數運算子 和/或 函式 的評估

十六進位制

[編輯 | 編輯原始碼]
十六進位制資料可以使用 0x 作為字首或 &h 輸入
例如 0x07ff &h241f

程式檔案中的前十位數字可以用於一些 語句 和簡單的內建編輯器。

限制 1 到 231 - 1 = 2147483647
行號超過九位數字的行在顯示器上不可見

冒號 (:) 後面的標籤可以用作替代,例如

x=7
foo: print x : x=x-1 : if x>0 then goto foo
文字字面量 位於雙引號之間,例如“ProgId42.bas”、“Hello, world”
變數 結尾為 $,例如 my_text$
Unix、Linux 和 Mac OS X,三個支援的作業系統中的三個。
如果 表示式 未被直譯器接受,則為值

變數名最多可以包含 31 個字元(字母、數字或下劃線 (_))。

過時的字首 fn 用於“def fn”,因此為了避免向下不相容,不要在開頭使用這兩個位元組。
如果在名稱末尾使用美元符號 ($),則該欄位將儲存一個長度最大為 254 位元組的 字串,這也是程式行最大長度。
字尾百分號 (%) 被解釋為 -32768 到 32767 之間的整數。
所有其他數字變數都被視為 IEEE 實數
  1. Chipmunk Basic 由 Ron Nicholson 編寫 - 包含一般資訊和連結的其他 Basic 方言的首頁

進一步閱讀

[編輯 | 編輯原始碼]
華夏公益教科書