Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
BASIC-PLUS
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Syntax and features== BASIC-PLUS is patterned closely on later versions of [[Dartmouth BASIC]], including its powerful <code>MAT</code> commands. On top of this, DEC added a number of unique flow-control structures. ===Editing=== Line numbers were positive integers from 1 to 32767.{{sfn|PLUS|1972|p=2-1}} Logical lines of code could be continued on multiple physical lines by using a [[line feed]] at the end of a line instead of the normal [[carriage return]] character.{{sfn|PLUS|1972|p=2-3}} For ease of external editing of the source file, later versions of BASIC-PLUS also allowed the {{code|&}} character as a line continuation character. Multiple statements could be placed on a single line using {{code|:}} as the statement separator.{{sfn|PLUS|1972|p=2-3}} The system allowed tabs to be used as inline whitespace, and was used to make loops more clear, as in modern languages.{{sfn|PLUS|1972|p=2-6}} Comments used either the {{code|REM}} keyword or the {{code|2=basic|!}} character,{{sfn|PLUS|1972|p=3-1}} as opposed to MS BASICs, which used {{code|REM}} and {{code|'}}. ===Standard statements=== The {{code|PRINT}} command divided the screen into regions 14 spaces wide, and the comma was used to move between these locations; {{code|PRINT 1,2,3}} would output 1, 2 and 3 in a spaced-out fashion,{{sfn|PLUS|1972|p=3-7}} while {{code|PRINT 1;2;3}} would leave a single space and produce "1 2 3".{{sfn|PLUS|1972|p=3-8}}{{efn|The space in front of the numbers was left for a possible minus sign, this was the standard in almost all BASICs}} {{code|INPUT}} allowed a prompt string to be specified, but used the semicolon to separate it rather than the comma; {{nowrap|{{code|INPUT "WHAT IS THE VALUE";A|basic}}.{{sfn|PLUS|1972|p=3-10}}}} Strings could be delimited by single or double quotes.{{sfn|PLUS|1972|p=5-2}} In addition to the {{code|CHR}} and {{code|ASCII}} functions that converted single characters to and from string format,{{sfn|PLUS|1972|p=5-12}} BASIC-PLUS also supported Dartmouth's {{code|CHANGE}} command. {{code|CHANGE}} iterated the string and returned each character's ASCII value as a slot in a numeric array. For instance, {{code|CHANGE 'HELLO' TO X}} would return an array with the five ASCII codes, 110, 105, 114, 114, 105, in elements 1 through 5, and the number 5, the length of the string, in element 0.{{sfn|PLUS|1972|p=5-5}} One could reverse the operation as well, {{code|CHANGE X TO A$}} would read the individual numbers in the X array and convert it to a string.{{sfn|PLUS|1972|p=5-7}} ===Statement modifiers=== BASIC-PLUS added the concept of "statement modifiers", [[JOSS]]-like conditions that could be applied to any statement. For instance, {{code|PRINT I IF I <> 10|lang=basic}} is the equivalent of {{code|1 = IF I <> 10 THEN PRINT I|lang=basic}}{{sfn|PLUS|1972|p=8-17}} The opposite was also provided, {{code|1 = PRINT I UNLESS I = 10|lang=basic}} was the equivalent of {{code|IF I <> 10 THEN PRINT I|basic}}.{{sfn|PLUS|1972|p=8-18}} {{code|FOR}} loops worked as in other versions of BASIC, and the {{code|NEXT}} command could not be used in an expression to exit early.{{sfn|PLUS|1972|p=3-19}} Instead, the {{code|UNTIL}} and {{code|WHILE}} keywords could be used to control early exits. For instance, {{code|1 = FOR I=1 UNTIL I=10|lang=basic}} continue looping until I=10, with the assumption that following code would set the value of I,{{sfn|PLUS|1972|p=8-14}} meaning it might not exit after 10 iterations but as soon as the code set I to 10.{{sfn|PLUS|1972|p=8-15}} Modifiers could also be used to build compact one-line loops, for instance, {{code|1 = X=X+1 WHILE X<100|lang=basic}} would loop until X was 100.{{sfn|PLUS|1972|p=8-20}} ===Variables, expressions and matrixes=== Variable names in the early versions of BASIC-PLUS could be a single letter or a single letter followed by a single digit.{{sfn|PLUS|1972|p=2-6}} With the inclusion of "Extend mode" in later versions, variable names could be up to 29 characters long, and dot (.) was added as a permitted character. Every variable name still had to begin with a letter.{{efn|Before the introduction of Extend mode, white space was not required between variables and other language elements: {{code|1=FOR I=STOP}} would be interpreted as {{code|1=FOR I = S TO P|2=basic}}.}} As in most versions of BASIC, the {{code|LET}} keyword, for variable assignment, was optional. It could set multiple variables to a single value, like {{code|1 = LET A,B,C=10|2=basic}}.{{sfn|PLUS|1972|p=3-3}} The language supported three data types; floating-point numbers, integers, and strings. Variables with no suffix were floating point (8 bytes, range 0.29{{x10^|-38}} to 1.7{{x10^|38}}, up to 16 digits of precision). Integer variables (16-bit, range −32768 to +32767) were indicated with a {{code|%}} suffix,{{sfn|PLUS|1972|p=6-1, 6-2}} string variables (variable length) were indicated with a {{code|$}} suffix.{{sfn|PLUS|1972|p=5-2}} The list of mathematical and logical operators was typical of most BASICs, with some extensions. For math, {{code|+}}, {{code|-}}, {{code|*}}, {{code|/}} and {{code|^}} were supported, along with {{code|**}} as an alternate form of {{code|^}} for [[computer terminal]]s that might not have that character. Standard logical comparisons were {{code|{{=}}}}, {{code|<}}, {{code|>}}, {{code|<{{=}}}}, {{code|>{{=}}}}, and {{code|<>}}. One interesting addition was the {{code|{{=}}{{=}}}} operator, for "approximately equal". This would return true if the two numbers would be printed the same, that is, their six most significant digits were the same.{{sfn|PLUS|1972|p=2-9}} Logical operators included the typical {{code|NOT A}}, {{code|A AND B}} and {{code|A OR B}}, along with {{code|A XOR B}}, {{code|A EQV B}} which return true if both A and B are true or both are false, and {{code|A IMP B}} which is false if A is true and B is false and otherwise always true.{{sfn|PLUS|1972|p=2-10}} The {{code|DIM}} statement could allocate one-dimensional and two-dimensional arrays of any of the three data types. The range of subscripts always began with 0 (but {{code|MAT}} statements did not set elements in row 0 or column 0).{{sfn|PLUS|1972|p=3-21}}{{sfn|PLUS|1972|p=5-3}} The language also included a number of {{code|MAT}} commands to work with the entire array (or MATrix). The {{code|MAT READ}} command would fill the matrix with values in a {{code|DATA}} statement,{{sfn|PLUS|1972|p=7-2}} {{code|MAT INPUT}} would fill the array with user-typed values, and {{code|MAT PRINT}} would print out the elements in a 1D or 2D format.{{sfn|PLUS|1972|p=7-3}} {{code|MAT}} could also be used to set default values in a matrix using associated keywords, for instance, {{code|1 = MAT A=ZER}} would fill the A array with zeros.{{sfn|PLUS|1972|p=7-5}} {{code|TRN}} would transpose an entire matrix, and {{code|INV}} would invert it.{{sfn|PLUS|1972|p=7-7}} Additionally, {{code|+}}, {{code|-}}, and {{code|*}} could be used on matrixes, performing the associated matrix operation.{{sfn|PLUS|1972|p=A-1}} ===File processing=== The {{code|DIM#}} "virtual DIM" statement could map "virtual data array(s)" or "virtual array(s)" to a disk file, which allowed arrays larger than the computer's available memory (or even its address space), and allowed use of array elements to read, write, and extend disk files (persistent storage). They called this arrangement "virtual data storage" and "virtual core", but it did not use the modern approach of allocating the arrays and a [[memory-mapped file]]. Instead, a single buffer was used to store 512 bytes of data at a time, and when an entry in the virtual array was accessed, the corresponding data was read, and old data written, as required. The {{code|CLOSE}} statement caused the buffer to be written back (if necessary) before closing the file. Because no additional sectors were cached, accessing data in the "wrong" order could multiply the number of disk accesses. Additional rules were imposed on virtual arrays, such that one datum could never span a record boundary: Each data type was aligned to a multiple of its size. Virtual strings were stored as fixed-length ASCIIZ data, with sizes restricted to 2, 4, 8, 16, 32, 64, 128, 256, or 512 bytes, and were accessed using {{code|LSET}} and {{code|RSET}}.{{sfn|PLUS|1972|p=9-17}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)