DIM a AS STRING * 32
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)))
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"
DEF SEG = s
PRINT HEX$(CVI(MID$(a, o + &HA, 2)))
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...)
Return to Index
|Response Title||Author and Date|
|Here is one that does work.||Michael Calkins on May 21, 4:28 PM|