BASIC-PLUS: Difference between revisions - Wikipedia


Article Images

Content deleted Content added

m

Line 28:

Any of these data types could be used in an array of one or two dimensions, using the {{code|DIM}} keyword.{{sfn|PLUS|1972|p=3-21}}{{sfn|PLUS|1972|p=5-3}} Additionally, the {{code|DIM#}} command could be used to define a "virtual DIM" who's elements resided in file. The program would first {{code|OPEN}} a file, which would assign it a number, and then the {{code|DIM#}} would refer to the data in that file and could be used like any other array. This was a very useful technique for saving memory, as data did not have to be encoded into the program itself.{{sfn|PLUS|1972|p=9-17}}

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 assocated keywords, for instance, {{code|1 = MAT A=ZER}} would fill the A array with zeros.{{sfn|PLUS|1972|p=7-5}} {{code|TRN}} would transform 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}}

The {{code|LET}} keyword, for variable assignment, was optional. It did have the ability to set multiple variables to a single value, like {{code|1 = LET A,B,C=10}}.{{sfn|PLUS|1972|p=3-3}} 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}} {{code|INPUT}} allowed a prompt string to be specified, but used the semicolon to separated it rather than the comma; {{code|INPUT "WHAT IS THE VALUE;A}}.{{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 the powerful {{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 five elements long.{{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}}

{{code|FOR}} loops worked as in later versions of BASIC, and the {{code|NEXT}} command could not be used in an expression.{{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 10}} continue looping until I=10, with the assumption that following code would set the value of I.{{sfn|PLUS|1972|p=8-14}}

BASIC-PLUS also allowed most control structures to be placed after other commands. For instance, {{code|PRINT I IF I < 10}} is the equivalent of {{code|1 = IF I >= 10 THEN PRINT I}}{{sfn|PLUS|1972|p=8-17}} The opposite was also provided, {{code|1 = PRINT I UNLESS I = 10}} was the equivalent of {{code|IF I <> 10 THEN PRINT I}}.{{sfn|PLUS|1972|p=8-18}} Using a conditional expression could make a loop, for instance, {{code|X=X+1 WHILE X<100}} would loop until X was 100. This offered a compact format for many common loop structures.{{sfn|PLUS|1972|p=8-20}}

==BASIC Plus 2==