Page 1 of 1
Flag for PokeS() to suppress trailing zeroes...
Posted: Wed Sep 17, 2008 9:09 am
by blueznl
PokeS(*MemoryBuffer, Text$ [, Length [, Flags]])
Why not add a flag, for example #PB_Ascii | #PB_NoZero, so trailing zeroes are left out when we don't want them?
Posted: Wed Sep 17, 2008 10:08 am
by AND51
Yep, it'd be a good idea to implement such a feature. I often thought about an easy to use command that allows you to poke somewhere in the middle of a string, without cutting this string because of the stupid NULL.
Of course, there would be for example the way via pointers, but why not having a more comfortable way?
Re: Flag for PokeS() to suppress trailing zeroes...
Posted: Wed Sep 17, 2008 3:25 pm
by Demivec
blueznl wrote:
PokeS(*MemoryBuffer, Text$ [, Length [, Flags]])
Why not add a flag, for example #PB_Ascii | #PB_NoZero, so trailing zeroes are left out when we don't want them?
Wouldn't this do the same thing, except without the benefit of flags?
Code: Select all
CopyMemory(@Text$, *MemoryBuffer, Len(Text$))
Re: Flag for PokeS() to suppress trailing zeroes...
Posted: Wed Sep 17, 2008 3:32 pm
by tinman
Demivec wrote:Wouldn't this do the same thing, except without the benefit of flags?
Code: Select all
CopyMemory(@Text$, *MemoryBuffer, Len(Text$))
You lose the string conversion option (e.g. Unicode->ASCII) if you use CopyMemory(). Or is that what you mean by "without the benefit of flags"?
Re: Flag for PokeS() to suppress trailing zeroes...
Posted: Wed Sep 17, 2008 3:56 pm
by Demivec
tinman wrote:Demivec wrote:Wouldn't this do the same thing, except without the benefit of flags?
Code: Select all
CopyMemory(@Text$, *MemoryBuffer, Len(Text$))
You lose the string conversion option (e.g. Unicode->ASCII) if you use CopyMemory(). Or is that what you mean by "without the benefit of flags"?
Yes that is what I meant.
I guess you could include the "flags" for conversion by using:
Code: Select all
PokeS(*WorkBuffer, Text$ [, Length [, Flags]])
CopyMemory(*WorkBuffer, *MemoryBuffer, MemoryStringLength(*WorkBuffer [, Flags]))
The above suggestion would probably make this Feature Request sound much more desirable that jumping through all that convoluted code to accomplish the same thing.

Posted: Wed Sep 17, 2008 6:15 pm
by blueznl
CopyMemory(@Text$, *MemoryBuffer, Len(Text$))
Ah... not Unicode friendly!
I wrote my own little PokeS() variant to avoid writing that terminating zero in fields where there is not enough space, what's throwing me off-balance all the time is that you specify how many bytes to write, and then PureBasic sneakily

tries to help you and adds one or two zeroes
It's just a request, it's not on the top of my want list
