Microsoft KB Archive/37308

From BetaArchive Wiki
Knowledge Base

Graphics GET and PUT Require Integer or LONG Array; Example

Article ID: 37308

Article Last Modified on 11/21/2006


  • Microsoft QuickBasic 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBasic 4.5 for MS-DOS
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b
  • Microsoft BASIC Professional Development System 7.0

This article was previously published under Q37308


Page 208 of the "Microsoft QuickBasic 4.0: Basic Language Reference" manual states the following:

Unless the array type is integer or long, the contents of an array after a [graphics] GET appear meaningless when inspected directly.

This statement also applies when saving the elements of the array to a file. Unless the array type is integer or long, the resulting picture, when read back from disk, will be distorted.

This information applies to Microsoft QuickBasic Versions 4.00, 4.00b, and 4.50, to Microsoft Basic Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2, and to Microsoft Basic PDS Version 7.00 for MS-DOS and MS OS/2.


The program below will display a picture, save it to disk, read it back from disk, and re-display the picture. If the "picture()" array is of integer type, the program will work as expected. If it is of single type, the resulting picture will be distorted.

The following is a code example:

CONST picSize = 16383
DIM picture(picSize) AS SINGLE   ' Change to INTEGER

SCREEN 3  ' SCREEN 3 is for Hercules. Use SCREEN 2 for CGA card.
FOR x = 1 TO 150 STEP 2.5          ' Draw a simple picture
  LINE (x + 300, x)-(300 - x, 300 - x), 7, B

GET (30, 0)-(450, 300), picture

OPEN "temp.pic" FOR OUTPUT AS #1   ' Save the picture
FOR i = 0 TO picSize
  PRINT #1, picture(i)

OPEN "temp.pic" FOR INPUT AS #1    ' Load the picture back
FOR i = 0 TO picSize
  INPUT #1, picture(i)

PUT (5, 5), picture                ' Display the picture

Additional query words: QuickBas BasicCom

Keywords: KB37308