BBS: Inland Empire Archive Date: 06-21-92 (12:19) Number: 1083 From: JEAN CREPEAU Refer#: NONE To: MARK REIF Recvd: NO Subj: Bsave/Bload Arrays Conf: (2) Quik_Bas
In a message to ALL, MARK REIF wrote:
MR=> I seem to have a problem BSAVEing and then BLOADing back to a
variable. I did a program to read a .PCX file, read a mouse button
push, then GET the area of screen asked for to an array. The I BSAVE
the array. In another progran I want to BLOAD the array, so I can PUT
the graphic back to the screen. But it seems something is not right. It
has a tendency to make you use the CNTL-ALT-DEL keys quit often. I
guess maybe possibly it is a VARPTR or VARSEG problem? The arrays are
DIM'd the same, and of the same type (integer). I am using Quick Basic
4.5
Be sure you use VARPTR and VARSEG at the last moment, because
QuickBASIC can move the pointers between instructions. This is incorrect:
DIM X(1000) AS INTEGER
XO=VARPTR(X(0))
XS=VARSEG(X(0))
[...]
DEF SEG=XS
BLOAD "...",XO
This is correct:
DIM X(1000) AS INTEGER
[...]
DEF SEG=VARSEG(X(0))
BLOAD "...",VARPTR(X(0))
Because every time you have a sentence that creates a new string
like X$=A$ or PRINT LEFT$(X$,1) or any other string transformation,
QuickBASIC can change all the pointers to be sure all the strings and
arrays will occupy contiguous memory. Also using the FRE() function changes
all the pointers also.
Jean
---
* Origin: INTERACESS Montreal (QC) Canada (514) 528-1415 (1:167/280)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET