PC-BASIC Documentation - GitHub Pages

Transcription

PC-BASICdocumentationVersion 2.0.4

1. PC-BASIC 2.0.4A free, cross-platform emulator for the GW-BASIC family of interpreters.PC-BASIC is a free, cross-platform interpreter for GW-BASIC, Advanced BASIC (BASICA),PCjr Cartridge Basic and Tandy 1000 GWBASIC. It interprets these BASIC dialects with ahigh degree of accuracy, aiming for bug-for-bug compatibility. PC-BASIC emulates the mostcommon video and audio hardware on which these BASICs used to run. PC-BASIC runsplain-text, tokenised and protected .BAS files. It implements floating-point arithmetic in theMicrosoft Binary Format (MBF) and can therefore read and write binary data files created byGW-BASIC.This is the documentation for PC-BASIC 2.0.4, last updated 2021-11-08 20:55:10.It consists of the following documents: 2Quick Start Guide, the essentials needed to get startedUser's Guide, in-depth guide to using the emulatorConfiguration Guide, settings and optionsLanguage Guide, overview of the BASIC language by topicLanguage Reference, comprehensive reference to BASICTechnical Reference, file formats and internalsDeveloper's Guide, using PC-BASIC as a Python modulePC-BASIC

Table of ContentsPC-BASIC 2.0.4 . 2Quick Start Guide. 14Installation. 15BASIC survival kit . 16Program location. 17External resources . 18User's guide . 19The working environment . 20Special keys. 21Keyboard shortcuts . 24Alternative keys . 25Clipboard operations. 25Emulator control keys . 25Compatibility . 26Programs and files . 27Accessing your drives . 29Compatible BASIC files . 30Packages . 31Cassette tapes . 31Security . 32Connecting to peripherals . 33Printing. 33Serial and parallel ports . 33Changing the interface. 34Emulation targets . 35Codepages . 36Fonts . 39Table of Contents3

Redirecting I/O . 40Command-line interface. 40Text-based interface . 41Configuration guide. 42Changing settings . 43Synopsis . 45Positional arguments . 46Options . 47Examples . 58Language guide . 60Working with programs . 61Control flow . 62Arrays and variables . 65Type conversion . 66String operations. 67Text and the screen . 68The printer . 69Keyboard input. 70Function-key macros . 71Calculations and maths . 72Mathematical functions . 72Random numbers . 72Devices and files. 73File operations . 73Devices . 73Graphics . 76Sound . 77Joystick and pen . 78Disks and DOS . 79Serial communications. 804PC-BASIC

Event handling . 81Error handling . 82User-defined functions . 83Date and time . 84Including data in a program . 85Memory and machine ports . 86Features not yet implemented . 87Unsupported features . 88Language reference. 89Metasyntax . 90Definitions . 91Literals . 92Variables . 94Types and sigils . 94Arrays. 95Conversions . 95Operators . 96Order of precedence . 96Mathematical operators . 97Relational operators. 98Bitwise operators . 98String operators . 99Functions . 101ABS .101ASC .101ATN .102CDBL .102CHR .102CINT .103COS .103Table of Contents5

CSNG .103CSRLIN.104CVI .104CVS .104CVD .105DATE ENVIRON .106EOF .106ERDEV .107ERDEV .107ERL .107ERR .107EXP .108EXTERR.108FIX .109FN6(function) . 105. 109FRE .110HEX .110INKEY .110INP .111INPUT .112INSTR .113INT .113IOCTL .114LEFT .114LEN .115LOC .116LOF .117LOG .118LPOS .118PC-BASIC

MID (function) . 119MKD .119MKI .119MKS .120OCT .120PEEK .121PEN(function). 122PLAY(function) . 123PMAP .124POINT(current coordinate) . 125POINT(pixel attribute) . 126POS .126RIGHT .127RND .128SCREEN(function). 129SGN .129SIN .130SPACE .130SQR .131STICK .131STR .132STRIG(function) . 132STRING .133TAN .133TIME (function) . 134TIMER(function) . 134USR .134VAL .135VARPTR.135VARPTR .136Table of Contents7

Statements. 137AUTO .137BEEP .138BEEP(switch). 138BLOAD .138BSAVE .139CALLand CALLS . 139CHAIN .140CHDIR .141CIRCLE.142CLEAR .143CLOSE .144CLS .145COLOR(text mode) . 146COLOR (SCREEN 1) .150COLOR (SCREEN 3—9).151COM .153COMMON.154CONT .155DATA .156DATE (statement) . 157DEF FN.DEFINT, DEFDBL, DEFSNG, DEFSTR8158. 159DEF SEG .159DEF USR .160DELETE.160DIM .161DRAW .162EDIT .164ELSE .164PC-BASIC

END .164ENVIRON .165ERASE .165ERROR .166FIELD .167FILES .168FOR .169GET(files) . 170GET(communications) . 171GET(graphics). 172GOSUB .173GOTO .174IF. 175INPUT(console) . 176INPUT(files) . 177IOCTL .178KEY(macro list) . 178KEY(macro definition) . 179KEY(event switch). 180KEY(event definition) . 181KILL .182LCOPY .183LET .183LINE .184LINE INPUT(console). 185LINE INPUT(files). 186LIST .187LLIST .188LOAD .189LOCATE.190Table of Contents9

LOCK .

common video and audio hardware on which these BASICs used to run. PC-BASIC runs plain-text, tokenised and protected .BAS files. It implements floating-point arithmetic in the Microsoft Binary Format (MBF) and can therefore read and write binary data files created by GW-BASIC. This is the documentation for. PC-BASIC 2.0.4, last updated. 2021-11 .