Microsoft KB Archive/36349
Article ID: 36349
Article Last Modified on 1/8/2003
- Microsoft QuickBasic Compiler for Macintosh 1.0
This article was previously published under Q36349
This article applies to Macintosh QuickBASIC Version 1.00 for the Apple Macintosh.
When collecting a large picture with the PICTURE ON...PICTURE OFF statements, the size of the picture may grow beyond the 32K maximum size allowed for a string variable. When the picture is assigned to a string variable with p$ = PICTURE$, a "String too long", error 15 message will appear if the recorded picture has exceeded 32,767 bytes.
The subprogram below allows you to monitor the current size of the picture that is being recorded. This allows you to stop recording and start a new picture when the size of the current picture approaches the limit for a BASIC string.
In the 64K ROM Macintoshes, QuickDraw pictures were limited to 32,767 bytes, but in the newer, 128K ROM (enhanced) Macintoshes, they are no longer restricted in size.
The following is a code example:
PICTURE ON ' Turn on recording of the picture in heap space. size& = 0 WHILE size& < 32700 'leave some margin PSET(RND*400+100,RND*400+100) ' Draw a pixel at a random location. GetPictureSize size& ' SUBprogram returns current picture size. WEND PICTURE OFF ' Turn off recording of the picture in heap space. p$ = PICTURE$ 'get picture into a BASIC string PICTURE ,p$ 'draw the recorded picture WHILE MOUSE(0) <> 1 : WEND 'wait for mouse click END ' This SUBprogram returns the size of the picture currently recording: SUB GetPictureSize( Size& ) STATIC hPic& = PEEKL( PEEKL(PEEKL(PEEKL(&H904))) + &H5C ) IF hPic& <> 0 THEN 'return size of picture size& = PEEKW(PEEKL(PEEKL(PEEKL(hPic&)))) ELSE 'no picture being recorded size& = 0 END IF END SUB
Additional query words: MQuickB