Path: utzoo!mnetor!uunet!husc6!bloom-beacon!think!ames!ucbcad!ucbvax!decvax!decwrl!thundr.dec.com!minow From: minow@thundr.dec.com (Martin Minow THUNDR::MINOW ML3-5/U26 223-9922) Newsgroups: comp.sys.dec Subject: re: Bug in Basic-Plus for RSTS V8.0? -- nope Message-ID: <8712161511.AA12833@decwrl.dec.com> Date: 16 Dec 87 17:57:00 GMT Organization: Digital Equipment Corporation Lines: 35 Gerald Vogt thinks he has found a bug in RSTS/E Basic-Plus. To simplify his sample program, he defines a record I/O field: 20 field 1%, 3% as a$, 20% as i$, 15% as q$ and assigns an element from the field to a variable: 70 in$(z%) = i$ The program fails when in$(z%) contains nothing when the file is closed. The problem, which should be discussed in the Basic-Plus documentation, is that a direct string assinment "foo$ = bar$" copies string pointers from the source to the destination. The contents are not duplicated. Thus, in Gerald's example, in$(z%) contains the address of i$ in the file buffer and the contents of in$(z%) change as the file changes. The program will work as Gerald wants if he changes his code to 70 in$(z%) = i$ + "" By concatenating a null string to the record field, Basic-Plus will allocate new memory and copy the contents of the string from the buffer. Gerald's solution: 70 in$(z%) = left(i$, 20%) does the same thing. Hope this helps. Martin Minow minow%thundr.dec@decwrl.dec.com The above does not represent the position of Digital Equipment Corporation.