Microsoft KB Archive/36349: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - "<" to "<")
Line 60: Line 60:
<pre class="codesample">PICTURE ON  ' Turn on recording of the picture in heap space.
<pre class="codesample">PICTURE ON  ' Turn on recording of the picture in heap space.
size&amp; = 0
size&amp; = 0
WHILE size&amp; &lt; 32700    'leave some margin
WHILE size&amp; < 32700    'leave some margin
     PSET(RND*400+100,RND*400+100)  ' Draw a pixel at a random location.
     PSET(RND*400+100,RND*400+100)  ' Draw a pixel at a random location.
     GetPictureSize size&amp;  ' SUBprogram returns current picture size.
     GetPictureSize size&amp;  ' SUBprogram returns current picture size.
Line 67: Line 67:
p$ = PICTURE$    'get picture into a BASIC string
p$ = PICTURE$    'get picture into a BASIC string
PICTURE ,p$      'draw the recorded picture
PICTURE ,p$      'draw the recorded picture
WHILE MOUSE(0) &lt;&gt; 1 : WEND    'wait for mouse click
WHILE MOUSE(0) <&gt; 1 : WEND    'wait for mouse click
END
END
' This SUBprogram returns the size of the picture currently recording:
' This SUBprogram returns the size of the picture currently recording:
SUB GetPictureSize( Size&amp; ) STATIC
SUB GetPictureSize( Size&amp; ) STATIC
     hPic&amp; = PEEKL( PEEKL(PEEKL(PEEKL(&amp;H904))) + &amp;H5C )
     hPic&amp; = PEEKL( PEEKL(PEEKL(PEEKL(&amp;H904))) + &amp;H5C )
     IF hPic&amp; &lt;&gt; 0 THEN    'return size of picture
     IF hPic&amp; <&gt; 0 THEN    'return size of picture
         size&amp; = PEEKW(PEEKL(PEEKL(PEEKL(hPic&amp;))))
         size&amp; = PEEKW(PEEKL(PEEKL(PEEKL(hPic&amp;))))
     ELSE    'no picture being recorded
     ELSE    'no picture being recorded

Revision as of 09:25, 21 July 2020

Knowledge Base


How to Avoid "String Too Long" Using PICTURE$ Function

Article ID: 36349

Article Last Modified on 1/8/2003



APPLIES TO

  • Microsoft QuickBasic Compiler for Macintosh 1.0



This article was previously published under Q36349

SUMMARY

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.

MORE INFORMATION

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

Keywords: KB36349