Classic Computer Magazine Archive COMPUTE! ISSUE 70 / MARCH 1986 / PAGE 10

Saving IBM PC Screens

I'm writing a BASICA painting program for the IBM PC that does all the drawing with PUT commands. But I need to know how to save a picture to disk so my work isn't lost when I turn the computer off. I know you can store an entire screen in an array with a GET command like this:

10 DIM V(4001)
20 GET (0,0)–(639,199),V

How can I save the contents of this array to disk?

David Short

It's a simple operation in BASICA. The VARPTR function can tell you the memory location where any array is stored, and BSAVE can save the contents of any block of memory, including arrays or other variables. Since each element of the array occupies four bytes, you must save 16004 (4*4001) bytes of memory. Use VARPTR(V(0)) to find the location of the first element in the array. This statement saves the array V in a file called PICTURE:

30 BSAVE "PICTURE", VARPTR(V(0)), 16004

Here's a complementary program to load the same picture from disk and display it on the screen. Don't forget to DIMension the array before performing this operation.

10 DIM V(4001)
20 BLOAD "PICTURE",VARPTR(V(0))
30 PUT (0,0),V,PSET