This also should work, but doesn't... (don't run included example)

by (Login MCalkins)
ASM Forum

 

DEFINT A-Z
DIM a AS STRING * 32
CLS
s = VARSEG(a) + ((VARPTR(a) AND &HFFF0&) \ &H10) + 1
o = &H10 - (VARPTR(a) AND &HF)
FOR i = 0 TO 8
MID$(a, o + i + 1, 1) = CHR$(VAL("&h" + MID$("A10900F7D0A30900CB", i + i + 1, 2)))
NEXT i
DO
LINE INPUT "number to invert (hex)? "; h$
IF LEN(h$) = 0 THEN EXIT DO
MID$(a, o + &HA, 2) = MKI$(VAL("&h" + h$))
'PRINT HEX$(s); ":0"
'SHELL "debug"
DEF SEG = s
CALL absolute(0)
PRINT HEX$(CVI(MID$(a, o + &HA, 2)))
LOOP

Same problem... The routine works. I can verify it by shelling to Debug. But the changes to the string are undone upon returning to QBASIC. I do not know why.

I am not certain if the segment and pointer manipulation might cause signed integer overflow problems. It doesn't when I run it, but I'm not sure if it's right. In any case, I wouldn't trust this whole method. I'm beginning to hate QBASIC, for its lack of unsigned math, and its voodoo evident in the last two examples. (By the way, I have found a few other bugs in QBASIC in the last year or two. I used to think it was bug free...)

Regards,
Michael



    
This message has been edited by MCalkins on May 21, 2009 4:54 PM

Posted on May 21, 2009, 3:01 PM

Respond to this message   

Return to Index

Response TitleAuthor and Date
Here is one that does work. on May 21, 4:28 PM

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement