basicの拡張子はbasです。save、loadでファイルの保存呼び出しを行います。
コメント:rem
10 rem コメント 20 print "hello world" 25 print "hello world again" >save "hello.bas" >list 10 rem コメント 20 print "hello world" 25 print "hello world again" >new >list >load "hello.bas" >list 10 rem コメント 20 print "hello world" 25 print "hello world again"
goto文
>list 10 rem コメント 20 print "hello world" 25 print "hello world again" 30 goto 20 >
変数
>new >10 x = 5 >20 print x >run 5
if文
>new >10 score = 80 >20 if score > 60 then print "ok" >list 10 score = 80 20 if score > 60 then print "ok" >run ok
ifとgoto文
>20 if socre > 60 then goto 30 else goto 40 >30 print "ok" >40 print "ng" >30 print "ok": end >run ng
ループ
>new >10 for i = 1 to 10 >20 print i >30 next i >list 10 for i = 1 to 10 20 print i 30 next i >run 1 2 3 4 5 6 7 8 9 10
サブルーチン
>new >10 print "hello" >20 gosub 100 >30 end >100 print "hello from subroutine!" >110 return >list 10 print "hello" 20 gosub 100 30 end 100 print "hello from subroutine!" 110 return >run hello hello from subroutine! >
サブルーチン
>new >10 input "your age? ", age >20 print "your are "; age; " years old!" >list 10 input "your age? ",age 20 print "your are ";age;" years old!" >ru Syntax error >run your age? 18 your are 18 years old! >
basicの数当てゲーム
10 answer = int(rnd(1)*10)+1 20 input "guess (1-10)? ",guess 30 if guess > answer then print "too high!" : goto 20 40 if guess < answer then print "too low!" : goto 20 50 if guess = answer then print "you got it!" : end >run guess (1-10)? 4 you got it!