Chipmunk Basic
配列変数を宣言したときに与えられる初期値
数値型:0(ゼロ)
文字型:ナル("")
10 'a program to solve ABCD*4=DCBA
20 '1) A isn't zero 2) all the numbers are different from each others.
100 FOR A=1 TO 9
200 FOR B=0 TO 9
250 IF B=A THEN 800
300 FOR C=0 TO 9
350 IF C=A OR C=B THEN 700
400 FOR D=1 TO 9
450 IF D=A OR D=B OR D=C THEN 600
500 IF (1000*A+100*B+10*C+D)*4=1000*D+100*C+10*B+A THEN PRINT A;B;C;D
600 NEXT D
700 NEXT C
800 NEXT B
900 NEXT A
1000 END
1 'akai tama(*) 4, shiroi tama(o) 3 ko ga haitte
2 'iru fukuro kara hitotsu zutu 2ko dashite, 2ko ga
3 'onaji iro de aru kakuritsu o keisan.
10 CLS
30 GOTOXY 0,0:PRINT "akai tama(*) 4, shiroi tama(o) 3 ko ga haitte"
40 PRINT "iru fukuro kara hitotsu zutu 2ko dashita toki, 2ko"
50 PRINT "ga onaji iro de aru kakuritsu o keisan.":?
60 ? "NOTE: Press Command + . to stop"
80 TRY=0:DOUSHOKU=0:RITU=0
90 dim iro$(6)
100 iro$(0) = "*"
110 iro$(1) = "*"
120 iro$(2) = "*"
130 iro$(3) = "*"
140 iro$(4) = "o"
150 iro$(5) = "o"
160 iro$(6) = "o"
170 IF macfunction("keydown",55)=1 AND (macfunction("keydown",47)=1 OR macfunction("keydown",65)=1) THEN GOTO 7000 :'command+.ga osaretaka
180 DIM TORU(6):dim irojun$(2)
200 FOR L=0 TO 1
300 tama = int(rnd(1)*7)
400 IF TORU(TAMA)=1 THEN 300
500 TORU(TAMA)=1 :'tama no toridashi o kiroku suru
700 irojun$(L) = iro$(tama)
900 NEXT L
1000 IROJUN$(2)=IROJUN$(0)+IROJUN$(1) :'iro no junjo o kiroku suru
1500 GOTOXY 0,5:print irojun$(2)
2000 TRY=TRY+1 :'jikken kaisuu ga +1 ni naru
2500 IF IROJUN$(2)="**" OR IROJUN$(2)="oo" THEN DOUSHOKU=DOUSHOKU+1
3000 RITU=DOUSHOKU/TRY :'kakuritsu o keisan
3500 GOTOXY 0,6
4000 PRINT "KAKURITSU=";RITU:GOTOXY 25,6:PRINT "KAISUU=";TRY
4500 ERASE TORU :'totta tama o fukuro ni modosu
5000 ERASE IROJUN$ :'konkai no irojun o kesu
6000 GOTO 170
6100 WEND
6900 'KEISAN KEKKA GA KIENAI YOUNI CURSOR O IDOU
7000 GOTOXY 0,10:END
8000 end
print"This program will tell you the sum of [1,2,3...n]."
input "input n:";n
sum=((n+1)*n)/2
print sum
end
10 n=0:sum=0:num=0
20 print"This program will tell you the sum of [1,2,3...n]."
30 input "input n:";n
40 for a=1 to n
50 num=num+1
60 sum=sum+num
70 next a
80 print "sum is "sum
90 end
sound -2,1,60,99,1,1 : sound -2,1,62,99,1,2 : sound -2,55,65,99,1,3
sound -2,1,58,99,1,1 : sound -2,1,62,99,1,2 : sound -2,55,64,99,1,3
sound -2,1,60,99,1,1 : sound -2,1,62,99,1,2 : sound -2,55,65,99,1,3
sound -2,1,58,99,1,1 : sound -2,1,62,99,1,2 : sound -2,55,64,99,1,3
say "hello world! I am Mac."
sound -2,55,64,99,2.5,3
rem / a program to show prime numbers /
rem / programmed by S.H in Oct 2000 /
clear:n1=0:n2=0 :' n1=start number, n2=end number
input"hajime no kazu wa? (n>1) ";n1
input"saigo no kazu wa? (n>1) ";n2
for x=n1 to n2
if x<=2 then goto print_sosuu:
for a=2 to (x-1)
if (x mod a)=0 then 500
next a
print_sosuu:
print x;" ";
500 next x
print
end
繰り返し表示される縞模様を根気強く見終わった後に、黒地に白の縞模様を見ると、縦縞の間に赤の補色=緑、横縞の間に緑の補色=赤が見える。さらに、頭を90度傾けて縦縞と横縞をあべこべにすると見える色も逆転するという実験です。MSXマガジンによると部屋を暗めにして目はモニターから数十cm以上離すと効果が出やすいそうです。
※MSXマガジン1991年2月号に掲載された錯視プログラムを移植したものですが、MSX BASICにあるSETPAGE命令がChipmunk Basicにないせいか、使用する色の調整がまずいせいか出来はいま一つです(私の目には横縞の間の赤は見えるけど縦縞の間の緑色がはっきり見えてこない)。
注意:このプログラムの利用によってあなたの心身に障害が生じても私(堀内悟)は責任を負いません。この条件を承諾した方以外はこのプログラムを実行しないでください。
' McCollough effect test ' ' programmed by Horiuchi Satoru in Jan 2001 ' with reference to MSX Magazine 1991 #2 max_width=0:max_height=0 max_width=graphics (-38) max_height=graphics (-39) call "hideMenuBar" Graphics 0 graphics window max_width,max_height ' ***** main program ***** paint_win_black pattern1 call "wait", 10 for a=0 to 14 paint_win_black pattern2 call "wait", 11 paint_win_black pattern3 call "wait", 11 next a paint_win_black call "wait",3 pattern1 ' ***** setting of each pattern ***** ' painting an entire window black sub paint_win_black() graphics color 255 graphics fillrect 0,0,640,480 end sub ' *** pattern 1 *** sub pattern1() graphics color 0 for i=0 to 9 graphics fillrect 16+(32*i),0,32+(32*i),480 next i for i=0 to 19 graphics fillrect 320,(32*i),640,16+(32*i) next i end sub ' *** pattern 2 *** ' akai tate shima sub pattern2() graphics color 34 for i=0 to 19 graphics fillrect 16+(32*i),0,32+(32*i),480 next i end sub ' *** pattern 3 *** ' midori no yoko shima sub pattern3() graphics color 225 for i=0 to 19 graphics fillrect 0,(32*i),640,16+(32*i) next i end sub end
nichirei=0 '*** Set dialog messages *** title1$="Enter your birthday" title2$="Enter the date of today" '***** main program ***** call wintitle, newname$ graphics window 0,14,512,370 graphics 0 :' open a graphics window graphics button "nichirei", 50, 50, 100, 50, Command$ 'ask two dates birthday$=inputbox ( prompt$, title1$, default$, 1) today$=inputbox ( prompt$, title2$, default$, 1) 'nichirei no keisan nichirei=hiduke_teisuu(today$)-hiduke_teisuu(birthday$)+1 print "Today is the "nichirei"th day in your life." moveto 50,300 graphics drawtext str$(nichirei) sub hiduke_teisuu(a$) month_col_num=0 :' the number of colums for month day_1st_col=0 :' the number of the starting colum of day month_col_num=0 :' the number of colums for month if (mid$(a$,7,1))="." then month_col_num=1:day_1st_col=8:else month_col_num=2:day_1st_col=9:endif year =val(mid$(a$,1,4)) month=val(mid$(a$,6,month_col_num)) day =val(mid$(a$,day_1st_col,2)) teisuu_pre=(year*365.25)+tsuki_keisuu(month)+day hiduke_teisuu=shuusei(teisuu_pre) end sub sub tsuki_keisuu(mm) select case mm case 1 : tsuki_keisuu=0 case 2 : tsuki_keisuu=31 case 3 : tsuki_keisuu=59 case 4 : tsuki_keisuu=90 case 5 : tsuki_keisuu=120 case 6 : tsuki_keisuu=151 case 7 : tsuki_keisuu=181 case 8 : tsuki_keisuu=212 case 9 : tsuki_keisuu=243 case 10: tsuki_keisuu=273 case 11: tsuki_keisuu=304 case 12: tsuki_keisuu=334 end select end sub sub shuusei(a) if a<>int(a) then a=int(a):else if month<=2 then a=a-1:else a=a shuusei=a end sub end