BASIC是1965年由美国人凯梅尼和库尔茨创立的。
许多公司和个人都为 Basic 语言作了扩展,从而产生了许多种扩展的Basic语言。比较常见的有:BASICA(IBM-PC)、GWBASIC(中国长城Great Wall)、等等。
BASIC是一种解释型的语言,而编译型的语言包括C语言、Pascal语言等等。
我们来回忆下BASICA怎么运行:
Win XP 下运行cmd,进入DOS方式。
进入bas目录,输入basica
进入BASICA的界面
按F2(Load),调用music.bas源文件
按F6(List),可以编辑music.bas源代码
可以编辑
输入:run,运行程序
运行music.bas界面。
测试后,在Windows XP环境下可以运行BASICA,且通过机内喇叭播放音乐。
附程序调用的music.bas源代码:
940 REM The IBM Personal Computer Music950 REM Version 1.10 (C)Copyright IBM Corp 1981, 1982960 REM Licensed Material - Program Property of IBM975 DEF SEG980 SAMPLES$ = "NO"990 GOTO 10101000 SAMPLES$ = "YES"1010 KEY OFF:SCREEN 0,1:COLOR 15,0,0:WIDTH 40:CLS:LOCATE 5,19,0:PRINT "IBM"1020 LOCATE 7,12:PRINT "Personal Computer"1030 COLOR 10,0:LOCATE 10,9:PRINT CHR$(213)+STRING$(21,205)+CHR$(184)1040 LOCATE 11,9:PRINT CHR$(179)+" MUSIC "+CHR$(179)1050 LOCATE 12,9:PRINT CHR$(179)+STRING$(21,32)+CHR$(179)1060 LOCATE 13,9:PRINT CHR$(179)+" Version 1.10 "+CHR$(179)1070 LOCATE 14,9:PRINT CHR$(212)+STRING$(21,205)+CHR$(190)1080 COLOR 15,0:LOCATE 17,4:PRINT "(C) Copyright IBM Corp 1981, 1982"1090 COLOR 14,0:LOCATE 23,7:PRINT "Press space bar to continue"1100 IF INKEY$ <> "" THEN 11001110 CMD$ = INKEY$:IF CMD$="" THEN 11101130 IF CMD$ = CHR$(27) THEN GOTO 18501140 IF CMD$ <> " " THEN 11101141 ON ERROR GOTO 11481142 PLAY "mf"1143 GOTO 11491148 RESUME 11491149 ON ERROR GOTO 01150 SCREEN 0,1:WIDTH 40:COLOR 15,1,1:CLS:DEFINT A-Z1160 LOCATE 15,7:PRINT " ------- selections -------"1170 LOCATE 16,7:PRINT " A-MARCH E-HUMOR I-SAKURA"1180 LOCATE 17,7:PRINT " B-STARS F-BUG J-BLUE "1190 LOCATE 18,7:PRINT " C-FORTY G-POP K-SCALES"1191 LOCATE 19,7:PRINT " D-HAT H-DANDY ESC KEY-EXIT"1200 COLOR 15,01210 FOR I=0 TO 15:FOR J=0 TO 81220 LOCATE 5+J,5+I*2:PRINT CHR$(219);CHR$(221);1230 NEXT:NEXT1240 FOR I=0 TO 12:FOR J=0 TO 41250 IF I=2 OR I=6 OR I=9 OR I=13 THEN 12701260 LOCATE 5+J,8+I*2:PRINT CHR$(32);CHR$(222);1270 NEXT:NEXT1280 FOR J=0 TO 91290 LOCATE 4+J,4:COLOR 4,0:PRINT CHR$(221);:LOCATE 4+J,36:COLOR 15,01300 PRINT CHR$(221);:COLOR 4,1:PRINT CHR$(221);1310 NEXT1320 COLOR 4,1:LOCATE 4,41330 FOR I=0 TO 32:PRINT CHR$(219);:NEXT1340 PRINT CHR$(221);:LOCATE 13,41350 FOR I=0 TO 32:PRINT CHR$(219);:NEXT1360 PRINT CHR$(221);:COLOR 0,7:DIM M(88),O(70)1370 FOR I=7 TO 88:M(I) = 36.8*(2^(1/12))^(I-6):NEXT1380 FOR I=0 TO 6:M(I) = 32767:NEXT1390 O(0) = 01400 O(39)=5:O(40)=7:O(41)=8:O(42)=91410 O(43)=10:O(44)=11:O(45)=13:O(46)=141420 O(47)=15:O(48)=16:O(49)=17:O(50)=181430 O(51)=19:O(52)=21:O(53)=22:O(54)=231440 O(55)=24:O(56)=25:O(57)=27:O(58)=281450 O(59)=29:O(60)=30:O(61)=31:O(62)=321460 O(63)=33:O(64)=35:O(65)=36:O(66)=371470 O(67)=38:O(68)=39:O(69)=40:O(70)=421480 GOTO 16301490 READ J,K1500 CMD$ = INKEY$:IF CMD$="" THEN 15401510 IF CMD$=CHR$(27) THEN RETURN1520 REM1530 REM1540 IF J = -1THEN RETURN1550 Q = O(J)1560 IF J>64 OR J<39 THEN 15901570 IF SCREEN(5,Q)<>32 THEN COLOR 0,7:LOCATE 11,Q:PRINT CHR$(14);:COLOR 15,0:GOTO 15901580 COLOR 15,0:LOCATE 7,Q:PRINT CHR$(14);:COLOR 0,71590 SOUND M(J),K:IF J=0 AND K=1 THEN 1600:SKIP NEXT FOR STACCATTO1595 SOUND 32767,11600 IF J>64 OR J<39 THEN 14901610 IF SCREEN(5,Q) = 32 THEN COLOR 15,0:LOCATE 7,Q:PRINT CHR$(32);:GOTO 14901620 COLOR 15,0:LOCATE 11,Q:PRINT CHR$(219);:GOTO 14901630 LOCATE 21,5:PRINT " ";1640 LOCATE 21,5:PRINT "ENTER SELECTION ==>";1650 IF INKEY$ <> "" THEN 16501660 CMD$=INKEY$:IF CMD$="" THEN 16601670 IF CMD$=CHR$(27) THEN 18501680 IF CMD$="A" OR CMD$="a" THEN S$= "MARCH ":RESTORE 4000:GOTO 17701690 IF CMD$="B" OR CMD$="b" THEN S$= "STARS ":RESTORE 4100:GOTO 17701700 IF CMD$="C" OR CMD$="c" THEN S$= "FORTY ":RESTORE 3700:GOTO 17701710 IF CMD$="D" OR CMD$="d" THEN S$= "HAT ":RESTORE 4300:GOTO 17701720 IF CMD$="E" OR CMD$="e" THEN S$= "HUMOR ":RESTORE 3500:GOTO 17701730 IF CMD$="F" OR CMD$="f" THEN S$= "BUG ":RESTORE 3200:GOTO 17701740 IF CMD$="G" OR CMD$="g" THEN S$= "POP ":RESTORE 3600:GOTO 17701750 IF CMD$="H" OR CMD$="h" THEN S$= "DANDY ":RESTORE 3900:GOTO 17701755 IF CMD$="I" OR CMD$="i" THEN S$= "SAKURA":RESTORE 4500:GOTO 17701757 IF CMD$="J" OR CMD$="j" THEN S$= "BLUE ":RESTORE 3300:GOTO 17701761 IF CMD$="K" OR CMD$="k" THEN S$= "SCALES":RESTORE 4400:GOTO 17701769 GOTO 16401770 PRINT " ";CMD$;"-";S$1780 READ D1800 READ S$:LOCATE 23,1+(40.5-LEN(S$))/21805 COLOR 15,4:PRINT S$;:COLOR 0,71810 GOSUB 14901820 S$=STRING$(39," "):LOCATE 23,1:COLOR 4,1:PRINT S$:COLOR 0,71830 GOTO 16301840 1850 IF SAMPLES$="YES" THEN CHAIN "SAMPLES",10001860 SCREEN 0,1:COLOR 7,0,0:CLS:3000 REM The IBM Personal Computer Music Scroll3010 REM Version 1.00 (C)Copyright IBM Corp 19813020 REM Licensed Material - Program Property of IBM3200 DATA -2,"La Cucaracha - Mexican Folk Song"3210 DATA 42,1,0,1,42,1,0,1,42,1,0,1,47,1,0,5,51,1,0,3,42,1,0,1,42,1,0,13220 DATA 42,1,0,1,47,1,0,5,51,1,0,5,30,1,0,1,30,1,0,1,35,1,0,3,47,1,0,13230 DATA 47,1,0,1,46,1,0,1,46,1,0,1,44,1,0,1,44,1,0,1,42,8,0,2,42,1,0,13240 DATA 42,1,0,1,42,1,0,1,46,1,0,5,49,1,0,3,42,1,0,1,42,1,0,1,42,1,0,13250 DATA 46,1,0,5,49,1,0,5,37,1,0,1,37,1,0,1,30,1,0,3,54,2,56,2,54,2,52,23260 DATA 51,2,49,2,47,83270 DATA -1,-13300 DATA -2,"Blue Danube Waltz by J.S.Strauss"3310 DATA 42,4,46,4,49,4,49,4,0,4,61,2,0,2,61,2,0,6,58,2,0,2,58,2,0,6,42,4,42,43320 DATA 46,4,49,43330 DATA 49,4,0,4,61,2,0,2,61,2,0,6,59,2,0,2,59,2,0,6,41,4,41,4,44,4,51,4,51,43340 DATA 0,4,63,2,0,2,63,2,0,6,59,2,0,23350 DATA 59,2,0,6,41,4,41,4,44,4,51,4,51,4,0,4,63,2,0,2,63,2,0,6,58,2,0,2,58,23360 DATA 0,6,42,43370 DATA 42,4,46,4,49,4,54,4,0,4,66,2,0,2,66,2,0,6,61,2,0,2,61,2,0,6,42,43380 DATA 42,4,46,4,49,4,54,4,0,4,66,2,0,23390 DATA 66,2,0,6,63,2,0,2,63,2,0,6,44,4,44,4,47,4,51,2,0,2,51,14,0,2,48,43400 DATA 49,4,58,163410 DATA 54,4,46,4,46,8,44,4,51,8,49,4,42,4,0,2,42,2,42,4,0,8,49,2,0,2,47,23420 DATA 0,6,49,2,0,23430 DATA 47,2,0,6,49,4,58,16,56,4,49,2,0,2,46,2,0,6,49,2,0,2,46,2,0,6,49,43440 DATA 56,16,54,4,49,2,0,2,47,2,0,6,49,2,0,2,47,2,0,6,49,4,58,163450 DATA 56,4,49,4,54,4,56,4,58,4,61,8,59,4,58,2,58,2,58,4,56,2,0,2,54,4,0,83460 DATA -1,-13500 DATA -2,"Humoresque by Dvorak"3510 DATA 47,3,0,2,49,1,47,3,0,2,49,1,51,3,0,2,54,1,56,3,0,2,54,13520 DATA 59,3,0,2,58,1,61,3,0,2,59,1,58,3,0,2,61,1,59,3,0,2,56,13530 DATA 54,3,0,2,54,1,56,3,0,2,54,1,59,3,0,2,56,1,54,3,0,2,51,13540 DATA 49,24,47,3,0,2,49,1,47,3,0,2,49,1,51,3,0,2,54,1,56,3,0,2,54,13550 DATA 56,3,0,2,58,1,61,3,0,2,59,1,58,3,0,2,61,1,59,3,0,2,56,13560 DATA 54,3,0,2,54,1,59,3,0,2,47,1,49,6,54,6,47,183570 DATA -1,-13600 DATA -2,"Pop! Goes the Weasel - Anonymous"3610 DATA 47,2,0,2,47,2,49,2,0,2,49,2,51,2,54,2,51,2,47,2,0,2,42,23620 DATA 47,2,0,2,47,2,49,2,0,2,49,2,51,6,47,2,0,2,42,2,47,2,0,2,47,2,49,23630 DATA 0,2,49,2,51,2,54,2,51,2,47,2,0,4,56,2,0,4,49,2,0,2,52,2,51,6,47,23640 DATA 0,4,59,2,0,2,59,2,56,2,0,2,59,2,58,2,61,2,58,2,54,2,0,4,59,2,0,23650 DATA 59,2,56,2,0,2,59,2,58,6,54,2,0,2,51,2,52,2,0,2,51,2,52,2,0,2,54,23660 DATA 56,2,0,2,58,2,59,2,0,4,56,2,0,4,49,2,0,2,52,2,51,6,47,23670 DATA -1,-13700DATA -2,"Symphony #40 by Mozart"3710 DATA 55,2,54,2,54,4,55,2,54,2,54,4,55,2,54,2,54,4,62,4,0,43720 DATA 62,2,61,2,59,4,59,2,57,2,55,4,55,2,54,23730 DATA 52,4,52,4,0,4,54,2,52,2,52,4,54,2,52,2,52,4,54,2,52,23740 DATA 52,4,61,4,0,4,61,2,59,2,58,4,58,2,55,2,54,4,54,2,52,23750 DATA 50,4,50,4,0,4,62,2,61,2,61,4,64,4,58,4,61,43760 DATA 59,4,54,4,0,4,62,2,61,2,61,4,64,4,58,4,61,43770 DATA 59,4,62,4,61,2,59,2,57,2,55,2,54,4,46,4,47,4,49,43780 DATA 50,4,52,2,50,2,49,4,47,4,54,4,0,4,65,83790 DATA 66,2,0,6,65,8,66,2,0,6,65,83800 DATA 66,4,65,4,66,4,65,4,66,43810 DATA -1,-13900 DATA -2,"Yankee Doodle - Anonymous "3910 DATA 50,3,50,3,52,3,54,3,50,3,54,3,52,3,45,3,50,3,50,3,52,3,54,3,50,63920 DATA 49,3,0,33930 DATA 50,3,50,3,52,3,54,3,55,3,54,3,52,3,50,3,49,3,45,3,47,3,49,3,50,63940 DATA 50,3,0,33950 DATA 47,5,49,1,47,3,45,3,47,3,49,3,50,3,0,3,45,5,47,1,45,3,43,3,42,63960 DATA 45,3,0,33970 DATA 47,5,49,1,47,3,45,3,47,3,49,3,50,3,47,3,45,3,50,3,49,3,52,3,50,63980 DATA 50,63990 DATA -1,-14000 DATA -2,"FUNERAL MARCH OF A MARIONETTE - GOUNOD"4010 DATA 37,1,0,2,30,1,0,5,42,3,42,3,41,3,39,3,41,3,0,3,42,3,44,3,0,3,37,1,0,24020 DATA 30,1,0,5,42,3,42,3,41,3,39,3,41,3,0,3,42,3,44,3,0,3,37,3,42,3,0,3,45,34030 DATA 49,6,47,3,45,3,0,3,49,3,52,6,50,3,49,3,0,3,53,3,56,6,54,3,53,3,50,34040 DATA 49,3,47,3,45,3,44,3,30,1,0,5,42,3,42,3,41,3,39,3,41,3,0,3,42,3,44,34050 DATA 0,3,37,1,0,2,30,1,0,5,42,3,42,3,41,3,39,3,41,3,0,3,42,3,44,3,0,34060 DATA 37,3,45,3,0,3,49,3,52,6,50,3,49,3,47,3,45,3,43,3,47,3,50,3,42,34070 DATA 41,3,42,3,44,3,0,3,45,1,0,2,44,9,42,14080 DATA -1,-14100 DATA -2,"STARS AND STRIPES FOREVER - SOUSA "4110 DATA 54,6,54,6,52,3,51,3,51,6,50,3,51,3,51,16,0,2,50,34120 DATA 51,3,51,6,50,3,51,34130 DATA 54,6,51,3,54,3,52,12,49,6,0,3,49,3,49,6,48,3,49,34140 DATA 49,6,48,3,49,34150 DATA 52,16,0,2,51,3,49,3,51,3,54,9,56,9,56,3,49,16,0,2,54,64160 DATA 54,6,52,3,51,3,51,6,50,3,51,3,51,16,0,2,50,3,51,3,51,6,50,3 ,51,34170 DATA 52,3,51,3,49,5,46,1,49,12,47,6,0,3,47,3,47,6,46,3,47,3,50,6,49,3,47,34180 DATA 59,15,0,3,47,3,49,3,51,3,54,1,0,2,47,3,49,3,51,3,54,1,0,2,42,3,44,54190 DATA 51,1,49,12,47,14200 DATA -1,-14300 DATA -2,"Mexican Hat Dance - Traditional "4310 DATA 52,2,57,2,0,2,52,2,57,2,0,2,52,2,57,6,0,4,52,2,57,2,59,2,57,2,56,44320 DATA 57,2,59,2,0,8,52,2,56,2,0,2,52,2,56,2,0,2,52,2,56,6,0,4,52,24330 DATA 56,2,57,2,56,2,54,4,56,2,57,2,0,6,64,2,63,2,64,2,61,2,60,2,61,24340 DATA 57,2,56,2,57,2,52,2,0,4,49,2,50,2,52,2,54,2,56,2,57,2,59,2,61,24350 DATA 62,2,59,2,0,4,62,2,61,2,62,2,59,2,58,2,59,2,56,2,55,2,56,2,52,24360 DATA 0,4,64,2,63,2,64,2,66,2,64,2,62,2,61,2,59,2,57,24370 DATA -1,-14400 DATA -2,"SCALES"4410 DATA 38,1,39,1,40,1,41,1,42,1,43,1,44,1,45,1,46,1,47,14420 DATA 48,1,49,1,50,1,51,1,52,1,53,1,54,1,55,1,56,14430 DATA 57,1,58,1,59,1,60,1,61,1,62,1,63,1,64,1,65,8,0,44440 DATA 65,8,64,1,63,1,62,1,61,1,60,1,59,1,58,1,57,14450 DATA 56,1,55,1,54,1,53,1,52,1,51,1,50,1,49,1,48,14460 DATA 47,1,46,1,45,1,44,1,43,1,42,1,41,1,40,1,39,1,38,84470 DATA -1,-14500 DATA -2,"Sakura - Japanese Folk Melody "4510 DATA 49,8,49,8,51,12,0,4,49,8,49,8,51,12,0,4,49,8,51,8,52,8,51,84520 DATA 49,8,51,4,49,4,45,16,44,8,40,8,44,8,45,84530 DATA 44,8,44,4,40,4,39,16,49,8,49,8,51,12,0,4,49,8,49,8,51,12,0,44540 DATA 40,8,44,8,45,8,49,8,51,4,49,4,45,8,44,164550 DATA -1,-1运行效果,一会儿录制视频,见西瓜视频。