Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* re: Bug in Basic-Plus for RSTS V8.0? -- nope
@ 1987-12-16 17:57 Martin Minow THUNDR::MINOW ML3-5/U26 223-9922
  0 siblings, 0 replies; only message in thread
From: Martin Minow THUNDR::MINOW ML3-5/U26 223-9922 @ 1987-12-16 17:57 UTC (permalink / raw)


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.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1987-12-16 17:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1987-12-16 17:57 Bug in Basic-Plus for RSTS V8.0? -- nope Martin Minow THUNDR::MINOW ML3-5/U26 223-9922

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox