PC-BASIC は 2013年から開発されている BASIC で、マイクロソフトが 1983年に公開した GW-BASIC を現代のパソコン上で実行できるプログラミング環境です。 GW-BASIC についてはつい最近マイクロソフトからソースコードが公開されました。BASIC に関しては数多くの方言が存在するのですが、 私が 1980年代に使っていた F-BASIC と比較しながら、PC-BASIC の概要をお伝えしようと思います。
PC-BASIC のウェブサイト http://robhagemans.github.io/pcbasic/ に行きます。 右上に [Download] というメニューがあるのでこれをクリックします。
安定板 (STABLE RELEASES) と開発版 (DEVELOPMENT RELEASES) がありますが、今回は Windows 向けの安定板
(PC-BASIC 1.2.14 for Windows) を選択します。pcbasic-v1.2.14-win32.exe
というファイルが
ダウンロードされるので実行します。
ユーザーを選択する画面で [Next] を押します。
インストール場所を指定する画面で [Next] を押します。
スタートメニューのフォルダを指定する画面で [Install] を押します。
以下の完了画面が出ればインストール終了です。
スタートメニューから PC-BASIC 1.2 > Setting を選びます。すると PCBASIC.INI
という設定ファイルがメモ帳で開きます。
PCBASIC.INI
は %APPDATA%\pc-basic-1.2\
というフォルダにあります。
設定ファイルでは下記の3行を追加しました。
# PC-BASIC private configuration file. # Edit this file to change your default settings or add presets. # Changes to this file will not affect any other users of your computer. # All lines starting with # are comments and have no effect. # Thus, to use one of the example options below, you need to remove the # at the start of the line. [pcbasic] # Use the [pcbasic] section to specify options you want to be enabled by default. # See the documentation or run pcbasic -h for a list of available options. # for example (for version '1.2.14'): #allow-code-poke=False #altgr=True #append=False #aspect=4,3 #border=5 #caption=PC-BASIC #capture-caps=False #cas1= #cga-low=False ## choices: 1258, 437, 720, 737, 775, 806, 850, 851, 852, 853, 855, 856, 857, 858, 860, 861, 862, 863, 864, 865, 866, 868, 869, 874, 932, 934, 936, 938, 949, 950, Georgian-academy, Georgian-ps, Iransystem, Kamenicky, Mazovia, alternativnyj, armscii8a, big5-2003, big5-hkscs, iscii-as, iscii-be, iscii-de, iscii-gu, iscii-ka, iscii-ma, iscii-or, iscii-pa, iscii-ta, iscii-te, koi8-r, koi8-ru, koi8-u, mik, osnovnoj, pascii, ruscii, russup3, russup4ac, russup4na, viscii codepage=932 #com1= #com2= #config= #convert= ## choices: left, middle, right, none #copy-paste=left,middle #ctrl-c-break=True #current-device=Z #debug=False #dimensions= #double=False #exec= ## choices: cga, cgathin, freedos, mda, olivetti, tandy1, tandy2, unifont, univga, vga #font=unifont,univga,freedos font=unifont #fullscreen=False #help=False #input= ## choices: , none, cli, ansi, text, graphical #interface= #keys= #load= #logfile= #lpt1=PRINTER: #lpt2= #lpt3= #map-drives=False #max-files=3 #max-memory=65534,4096 #max-reclen=128 ## choices: rgb, composite, mono #monitor=rgb #mono-tint=255,255,255 #mount= #nobox=False #nokill=False #nosound=False #output= #pcjr-term= #peek= ## choices: left, middle, right, none #pen=left ## choices: close, page, line #print-trigger=close #quit=False #reserved-memory=3429 #resume=False #run= ## choices: smooth, native, crisp #scaling=smooth #serial-buffer-size=256 #shell=none #state= #strict-hidden-lines=False #strict-newline=False #strict-protect=False ## choices: advanced, pcjr, tandy #syntax=advanced syntax=tandy ## choices: 40, 80 #text-width=80 #utf8=False #version=False ## choices: vga, ega, cga, cga_old, mda, pcjr, tandy, hercules, olivetti #video=vga #video-memory=262144 #wait=False # To add presets, create a section header between brackets and put the # options you need below it, like this: # [your_preset] # border=0 # # You will then be able to load these options with --preset=your_preset. # If you choose the same name as a system preset, PC-BASIC will use your # options for that preset and not the system ones. This is not recommended.
実行はスタートメニューから PC-BASIC 1.2 > PC-BASIC を選びます。 Ok のあとに変な文字が出るのですが、上記の日本語の設定によって表示されてしまいます。 特に問題はないので、気にせず行きましょう。
よく使うコマンドを以下に示しておきます。詳しいドキュメントはこちらにありますが英語です。
F-BASIC と非互換となる点についてまとめておきます。PC-BASIC 以外のコードを走らせるときに 参考になると思います。ほかにも見つかり次第、以下に追加していく予定です。
ERR 関数で返されるエラー番号は、PC-BASIC と F-BASIC で以下のように異なります。
番号 | PC-BASIC | F-BASIC |
---|---|---|
1 | NEXT witout FOR | Next Without For |
2 | Syntax error | Syntax Error |
3 | RETURN witout GOSUB | Return Without Gosub |
4 | Out of DATA | Out Of Data |
5 | Illegal function call | Illegal Function Call |
6 | Overflow | Overflow |
7 | Out of memory | Out Of Memory |
8 | Undefined line number | Undefined Line Number |
9 | Subscript out of range | Subscript Out Of Range |
10 | Duplicate Definition | Duplicate Definition |
11 | Division by zero | Division By Zero |
12 | Illeagal direct | Illegal Direct |
13 | Type mismatch | Type Mismatch |
14 | Out of string space | Out Of String Space |
15 | String too long | String Too Long |
16 | String formula too complex | String Formula Too Complex |
17 | Can't continue | Can't Continue |
18 | Undefined user function | Undefined User Function |
19 | No RESUME | NO Resume |
20 | RESUME without error | Resume Without Error |
21 | Unprintable error | Unprintable Error |
22 | Missing operand | Missing Operand |
23 | Line buffer overflow | For Without Next |
24 | Device Timeout | While without Wend |
25 | Device Fault | Wend without While |
26 | FOR without NEXT | Bubble Full |
27 | Out of paper | |
29 | WHILE without WEND | |
30 | WEND without WHILE | |
50 | FIELD overflow | Bad File Number |
51 | Internal error | Bad File Mode |
52 | Bad file number | File Already Open |
53 | File not found | Device I/O Error |
54 | Bad file mode | Input Past End |
55 | File already open | Bad File Descriptor |
56 | Direct Statement In File | |
57 | Device I/O error | File Not Open |
58 | File already exists | Bad Data In File |
59 | Device In Use | |
60 | Device Unavailable | |
61 | Disk full | Buffer Overflow |
62 | Input past end | Protected Program |
63 | Bad record number | File Not Found |
64 | Bad file name | File Already Exists |
65 | Directory Full | |
66 | Direct statement in file | Too Many Open Disk Files |
67 | Too many files | Disk Full |
68 | Device Unavailable | Field Overflow |
69 | Communication buffer overflow | String Not Fielded |
70 | Permission Denied | Bad Record Number |
71 | Disk not Ready | Bad File Structure |
72 | Disk media error | Drive Not Ready |
73 | Advanced Feature | Disk Write Protected |
74 | Rename across disks | |
75 | Path/File acces error | |
76 | Path not found | |
77 | Deadlock |
PC-BASIC はオープンソースソフトウェアとして現在も開発中で、PC-BASIC 2.0 では、 Windows、Mac 以外にも CentOS (Linux) などでも実行できるようになります。 こどもパソコン IchigoJam で BASIC が採用されるなど、BASIC の環境も復活しつつあることに加え、 これまでの膨大な BASIC プログラム資産を活用できることも BASIC の魅力になるでしょう。
最近みつけた PC-BASIC に関して、日本語の解説が見つからなかったので概要をまとめてみました。