PC-BASIC の紹介

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\ というフォルダにあります。

PCBASIC.INI

設定ファイルでは下記の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 との相違点

F-BASIC と非互換となる点についてまとめておきます。PC-BASIC 以外のコードを走らせるときに 参考になると思います。ほかにも見つかり次第、以下に追加していく予定です。

エラー番号

ERR 関数で返されるエラー番号は、PC-BASIC と F-BASIC で以下のように異なります。

番号PC-BASICF-BASIC
1NEXT witout FORNext Without For
2Syntax errorSyntax Error
3RETURN witout GOSUBReturn Without Gosub
4Out of DATAOut Of Data
5Illegal function callIllegal Function Call
6OverflowOverflow
7Out of memoryOut Of Memory
8Undefined line numberUndefined Line Number
9Subscript out of rangeSubscript Out Of Range
10Duplicate DefinitionDuplicate Definition
11Division by zeroDivision By Zero
12Illeagal directIllegal Direct
13Type mismatchType Mismatch
14Out of string spaceOut Of String Space
15String too longString Too Long
16String formula too complexString Formula Too Complex
17Can't continueCan't Continue
18Undefined user functionUndefined User Function
19No RESUMENO Resume
20RESUME without errorResume Without Error
21Unprintable errorUnprintable Error
22Missing operandMissing Operand
23Line buffer overflowFor Without Next
24Device TimeoutWhile without Wend
25Device FaultWend without While
26FOR without NEXTBubble Full
27Out of paper
29WHILE without WEND
30WEND without WHILE
50FIELD overflowBad File Number
51Internal errorBad File Mode
52Bad file numberFile Already Open
53File not foundDevice I/O Error
54Bad file modeInput Past End
55File already openBad File Descriptor
56 Direct Statement In File
57Device I/O errorFile Not Open
58File already existsBad Data In File
59 Device In Use
60 Device Unavailable
61Disk fullBuffer Overflow
62Input past endProtected Program
63Bad record numberFile Not Found
64Bad file nameFile Already Exists
65 Directory Full
66Direct statement in fileToo Many Open Disk Files
67Too many filesDisk Full
68Device UnavailableField Overflow
69Communication buffer overflowString Not Fielded
70Permission DeniedBad Record Number
71Disk not ReadyBad File Structure
72Disk media errorDrive Not Ready
73Advanced FeatureDisk Write Protected
74Rename across disks
75Path/File acces error
76Path not found
77Deadlock

まとめ

PC-BASIC はオープンソースソフトウェアとして現在も開発中で、PC-BASIC 2.0 では、 Windows、Mac 以外にも CentOS (Linux) などでも実行できるようになります。 こどもパソコン IchigoJam で BASIC が採用されるなど、BASIC の環境も復活しつつあることに加え、 これまでの膨大な BASIC プログラム資産を活用できることも BASIC の魅力になるでしょう。

最近みつけた PC-BASIC に関して、日本語の解説が見つからなかったので概要をまとめてみました。


Copyright © 2020 たかはしのんき. All rights reserved.