[fpc-pascal] Remove last character from pchar

James Richters james.richters at productionautomation.net
Thu Jun 10 20:19:22 CEST 2021


Pchars are just a pain, I do not use any Pchars.. instead I use AnsiStrings that I can manipulate in a way that is easy and then I just do Pchar(myvariable) whenever I need to use a function that needs a Pchar… like this:
 
Var 
   MessageBoxText:Ansistring;
 
..
..
windows.messagebox(0,pchar(MessageBoxtext)…..bla bla bla);  
 
 
There is probably a better way but for me conversion to Pchar is a small price to pay for easy string manipulation.  AnsiStrings take care of their own memory allocation and the Pchar conversion doesn’t require an actual Pchar variable to bother with managing.
 
James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20210610/af4e75cf/attachment-0001.htm>


More information about the fpc-pascal mailing list