Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing letters
#12
well, to break down the peek/poke/varseg/sadd method:

a string, like it infers, is a string of bytes. each character in a string is 1 byte (value - 0 to 255). now those strings are stored at an address segment, and an offset. actually, it's just memory (which qb allocates for strings), but each address segment is a marker of 16 bytes, and each offset can go from zero to 65536. think of it like a football field, where you have markers for 10 yards and individual yards. so in essence you get access to a span of 1,048,576 in which your 640k of dos memory is stored, your bios (dont mess with it), your video memory, your text screen buffer, etc, essentially all the near memory you can play with without going to ems, xms or protected mode.

got it? great. now forget everything i just said, that's just background info ramble. pretty much, every variable in qb has a segment and an offset that you can mess with directly. to access these, you use:

def seg = segment
poke offset, byte_value
byte_value = peek (offset)

to find the segment and address of a qb variable, you say:

segment = varseg(variable)

and to find the offset (of the first point):

offset = varptr (numeric_variable)
offset = sadd(string_variable$)

so let's say i want to edit the first character of a string:

$mystring = "b guy walks into a bar"
def seg = varseg(mystring$)
poke sadd(mystring$) + 0, asc("A") 'zero is the character position - 1
print mystring$

should print, since you changed the first character to "A", "A guy walks into a bar"

to edit the second character, change the zero to 1, to edit the third, 2, etc.

to sum it up, this just pokes directly into your memory instead of using qb's string statements. i hope i didnt confuse you by all that :lol:
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply


Messages In This Thread
Changing letters - by Lanzaa - 02-01-2003, 11:14 AM
Changing letters - by toonski84 - 02-01-2003, 11:26 AM
Changing letters - by Lanzaa - 02-01-2003, 08:00 PM
Changing letters - by Lanzaa - 02-03-2003, 06:16 AM
Changing letters - by toonski84 - 02-03-2003, 07:04 AM
Changing letters - by Lanzaa - 02-03-2003, 09:55 AM
Changing letters - by toonski84 - 02-03-2003, 03:22 PM
Changing letters - by Neo - 02-03-2003, 04:04 PM
Changing letters - by LooseCaboose - 02-04-2003, 02:02 AM
Changing letters - by toonski84 - 02-04-2003, 04:56 AM
Changing letters - by Lanzaa - 02-04-2003, 07:27 AM
Changing letters - by toonski84 - 02-04-2003, 08:14 AM
Changing letters - by Neo - 02-04-2003, 04:31 PM
Changing letters - by Lanzaa - 02-05-2003, 09:01 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)