PokeS without NULL-Termination
PokeS without NULL-Termination
Hi,
I'd like to have an optional PokeS-Parameter for writing a string without adding a terminating NULL-Char...
I'd like to have an optional PokeS-Parameter for writing a string without adding a terminating NULL-Char...
Undank ist der Welten Lohn
basically, you only need to use a copymemory
CopyMemory(@string,addr,Length)
CopyMemory(@string,addr,Length)
Code: Select all
Procedure x_pokes(addr.l,string.s,Length.l)
Protected n
;
; *** as pokes() but will not write a terminating zero if the string is too long to fit
;
n = Len(string)
If n < Length
PokeS(addr,string)
Else
CopyMemory(@string,addr,Length)
EndIf
EndProcedure
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
well, oh, strings in structs, probably? 
that's why i'd love to have fixed length strings as well...

that's why i'd love to have fixed length strings as well...
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
Blueznl, i've got this from current pb help:
Perhaps, what Andras resquests is another optional parameter for PokeS instruction to tell it what is the byte value which delimitates the string.Syntax
PokeS(*MemoryBuffer, Text$ [, Length])
Description
For advanced programmers only. Write a string (including the ending '0') to the specified memory address.
An optional length parameter (in bytes) can be specified that defines the length of the string itself, a zero will still be placed in memory after the poked string (ie. specifying 6 will write 7 bytes, 6 for the string, and the last byte will be zero)
Supported OS
Windows, AmigaOS, Linux
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
psycho, the problem is the zero
i'm pretty sure he's trying to fill up the string part of a struct... it's something i have ran into a few times before as well
all i want to do is:
structwhatever/fieldwhatever.c = "12345"
instead of overwiting a bunch of bytes with poke or copymemory
i'm pretty sure he's trying to fill up the string part of a struct... it's something i have ran into a few times before as well
all i want to do is:
structwhatever/fieldwhatever.c = "12345"
instead of overwiting a bunch of bytes with poke or copymemory
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: PokeS without NULL-Termination
Can I do a little resurrecting of this (antique) thread?
+1
When I *have* to use PokeS because I'm changing the type of the string to the desired format (i.e. going from unicode to an ascii structure), I have to do a bunny hop of pokeing into temporary memory, then copying the temporary memory (minus the 0) into the correct field.
+1
When I *have* to use PokeS because I'm changing the type of the string to the desired format (i.e. going from unicode to an ascii structure), I have to do a bunny hop of pokeing into temporary memory, then copying the temporary memory (minus the 0) into the correct field.
-
- Addict
- Posts: 1519
- Joined: Wed Nov 12, 2008 5:01 pm
- Location: Russia
Re: PokeS without NULL-Termination
I agree.
It should be possible, disable the terminating null byte.
It should be possible, disable the terminating null byte.
Re: PokeS without NULL-Termination
+1
I had to cook up my own PokeS just to get rid of that trailing zero...
I had to cook up my own PokeS just to get rid of that trailing zero...
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )