[comp.sys.dec] BASIC-PLUS for RSTS/E: Feature, not bug.

mithomas@bsu-cs.UUCP (Michael Thomas Niehaus) (12/17/87)

In article <9900003@iaoobelix.UUCP>, vogt@iaoobelix writes:
 > I think I found a bug in BASIC-PLUS of RSTS V8.0. The following program
 > isn't working in the right way. I tried to read some records from a file
 > and to store them in an array. But after I read and stored all records,
 > the array was completely empty.
 > 
 > > 10 ON ERROR GOTO 1000
 > > 15 DIM IN$(100%)
 > > 20 FIELD #1%, 3% as a$, 20% as i$, 15% as q$
 > > 30 OPEN 'foobar' as file #1%, recordsize 38%
 > > 40 Z% = 0%
 > > 50 Z% = Z% + 1%
 > > 60 GET #15%, RECORD Z%
 > > 70 IN$(Z%) = I$
 > > 75 PRINT IN$(Z%)
 > > 80 GOTO 50
 > > 90 CLOSE #1%
 > > 100 PRINT IN$(I%)  FOR I% = 1% TO Z% - 1%
    ...
 > The outputs in line 75 are alright, but those in line 100 aren't.
 > Only blank lines appear there.
 > I found out that if you change line 70 to 'IN$(Z%) = LEFT$(I$, 20%)'
 > - which does nearly nothing different - it works correctly.
 > Does anybody know a patch for this bug? Or does anybody know how to
 > avoid this in an other way?

This is not a bug.  DEC calls it a feature.  I don't have the slightest idea
why, though.  When making an straight assignment from a file variable to a
local variable, a copy is not made.  It is more like the Pascal pointers.  
After the assignment, both variables point to the same area of storage (buffer).
To get around this use the statement:
     Prog_Var$ = File_Var$ + ""     ! to fool the compiler into thinking these
                                    ! are two unrelated variables
If I am not quite correct (it has been a while since I used BASIC-PLUS on     
RSTS/E) please tell me what I the correct answer is.  I do believe that I am
near, at least.

Michael Niehaus
UUCP: <Backbones>!{uunet,pur-ee,iuvax}!bsu-cs!mithomas