In a message dated 05-06-98, David Nyquist said to mark lewis about Pchar
Stuff
Hi Mark,
ml> i need routines to insert, remove, and replace characters. also
ml> need routines to strip leading and trailing characters...
DN>Well I've got a little unit which might be able to solve your problem.
[Note, I'm NOT the DN in the quotes!]
Some (most?) newer compilers have units supplied with them for converting
to/from PChar.
ml> working with PChars seems so much different that i'm seriously
ml> wondering about the benefits they offer. i already have 4 or 5
ml> projects on the burners mainly because of being able to use PChars
ml> to access the data but the above needed routines are really driving
ml> me bannanananananas...
DN>It's basically an array of characters. The size of the
DN>array is determined by a null pointer. So it can be as big
DN>as you want as long as it has that null pointer. And
DN>what's the best part is you can convert between Pchar and
DN>strings pretty easily.
A PChar string is not terminated by a null pointer, but by a NUL byte, which
is #0 in Speed Pascal/2 parlance. [The ASCII character NUL has been at code
point zero since it was the idle signal on teletypes.]
The simplest way to deal with PChar strings is to convert them to some more
sensible format that your compiler understands. However, if the length
exceeds 255 bytes you might be screwed if you are using an older compiler
that only understands TP-style strings.
If your compiler supports the ANSISTRING type, or some moral equivalent,
that might be the way to progress. Just convert them to an ANSISTRING.
The Speed Pascal/2 compilers have a CSTRING data type that handles this very
neatly. Just use this type instead of PChar. [Can any users of Virtual
Pascal/2 tell us whether it has this also?]
Alas, not all Pascal compilers have this kind of facility. This means you
might be safest writing yourself a unit that offers functions to handle
PChar arguments. The obvious functions wanted are equivalents of LENGTH(),
COPY(), etc. What else do you need to do?
Regards
Dave
___
* MR/2 2.25 #353 * Unable to locate Coffee -- Operator Halted!
--- Maximus/2 3.01
---------------
* Origin: DoNoR/2,Woking UK (44-1483-717905) (2:440/4)
|