>>> Anytime a new scalar (i.e. non-array) variable is created, the addresses of 
>>> the array variables must all change to make room for the new scalar 
>>> variable. 

 

So BASIC copies all the arrays to a new memory address? That does not seem very 
efficient.

 

Jeff

 

From: M100 <m100-boun...@lists.bitchin100.com> On Behalf Of Ken Pettit
Sent: Monday, May 28, 2018 10:24 PM
To: m...@bitchin100.com
Subject: Re: [M100] interesting VARPTR bug

 

Steve,

John is correct.  Array variables are stored at a higher memory address than 
scalar variables.  Anytime a new scalar (i.e. non-array) variable is created, 
the addresses of the array variables must all change to make room for the new 
scalar variable.  So the return value from VARPTR for array variables is only 
valid for as long a there are no new scalar variables delcared.

Ken

On 5/28/18 4:37 PM, Stephen Adolph wrote:

sounds plausible.

 

for reference here is the code. I have 4 embedded ML programs that I want to 
select to run.

 

2 REM good command sequence
3 A$(0)="using good sequence":D$(0)="ó:@ð:@ð:¸ð:òð:4ð:°ð:1ð:¿ð77~2ÀüûÉ"
4 REM bad command sequence  add 7 after 4@
5 A$(1)="using bad sequence1":D$(1)="ó:@ð:@ð:¸ð:òð:4ð7:°ð:1ð:¿ð77~2ÀüûÉ"
6 REM bad command sequence 2 add 7 after 77
7 A$(2)="using bad sequence2":D$(2)="ó:@ð:@ð:¸ð:òð:4ð:°ð:1ð:¿ð77&~2ÀüûÉ"
8 REM bad command sequence 3 remove 7 from 77
9 A$(3)="using bad sequence3":D$(3)="ó:@ð:@ð:¸ð:òð:4ð:°ð:1ð:¿ð7~2ÀüûÉ"
10 CLS:PRINT"Send command + data to REXCPM"
11 INPUT"select command sequence (1-4)";S:IF S<1 OR S>4 THEN 10
12 S=S-1
20 PRINT A$(S):F=0:K=VARPTR(D$(S)):F=256*PEEK(K+2)+PEEK(K+1)
21 PRINTF
22 FORI=1TOLEN(D$(S)):IF ASC(MID$(D$(S),I,1)) <> PEEK(F+I-1) THEN 
BEEP:PRINT"bad!":END
23 NEXTI:PRINT"good!!"
30 INPUT"Enter command byte";L
40 INPUT"enter data byte";H
50 CALLF,0,256*H+L
60 PRINT"result = ";PEEK(64704)
70 PRINT"hit any key to repeat"
80 IFINKEY$=""THEN 80
90 GOTO10

 

On Mon, May 28, 2018 at 7:36 PM, John R. Hogerhuis <jho...@pobox.com 
<mailto:jho...@pobox.com> > wrote:

 

On Mon, May 28, 2018 at 4:29 PM Stephen Adolph <twospru...@gmail.com 
<mailto:twospru...@gmail.com> > wrote:

yes, I do have a dim but ..not sure it matters though. I think I tried with and 
without.

 

Hmm. Not sure how the basic variable allocator works. But if putting F=0 makes 
it work or not work I suspect that assigning F for the first time creates a new 
variable and caused the array to move.

 

DIM’ing either or both, or assigning a value like you did might resolve. 

 

Whether that’s a bug I don’t know. Maybe you just need to be careful not to 
allocate variables between when you take VARPTR and when you use it the 
address. 

 

— John 

 

 

Reply via email to