Interesting HEX$ trick for Interrupt procedures

by (Login burger2227)
R

I was working on a Interrupt bitmap viewer I found at Pete's QB site. It would load a Screen 13 bitmap fast, but failed with large images because the programmer had assigned the following trick to integer variables.

offset% = VAL("&H" + HEX$(320& * y%))

To transfer the memory offset to place a row of pixel attributes, Interrupt uses the DS register that cannot be more than a signed integer value. I changed all values to LONG as below and it worked. The example below uses the maximum 320 by 200 values and return different values:

offset& = 320& * 200& 'result over 32767 when y& = 200 max
PRINT offset&
offset& = VAL("&H" + HEX$(320& * 200&)) ' result is within Integer range (negative in this case)
PRINT offset&

So if you need to send offset values over Integer ranges, try this trick. Otherwise, QB gives an overflow error.

Ted



    
This message has been edited by burger2227 on Jan 22, 2010 5:35 PM

Posted on Jan 22, 2010, 5:33 PM

Respond to this message   

Return to Index


Response TitleAuthor and Date
Where did you find this program?Ben on Jan 23, 8:34 AM
 * Interrupts are just as good as ASM buddy on Jan 23, 11:24 PM