Re: [fpc-pascal] Adding file to string to the RTL

2020-10-06 Thread Alexander Grotewohl via fpc-pascal
Not 100% on this but I think the gist is that UnicodeString is compatible with AnsiString and a conversion is done on assignment. -- Alexander Grotewohl https://dcclost.com From: fpc-pascal on behalf of Ryan Joseph via fpc-pascal Sent: Tuesday, October 6,

Re: [fpc-pascal] fpmmap problem 64 bit linux

2020-11-20 Thread Alexander Grotewohl via fpc-pascal
It would seem C handles this at compile time with a define.. mapping mmap to mmap64. Which would almost seem to imply you'd end up with a 32 bit binary that would only work on 64 bit systems. I'm not really sure how this would work for Pascal. You could start by looking in the file listed in

Re: [fpc-pascal] Two versions of freemem() - are they equal

2020-12-30 Thread Alexander Grotewohl via fpc-pascal
The TP7 manual suggests it was possible to partially free the memory. If you had a pointer to the un-freed chunk, I wonder if that could also have been freed, or if was left in limbo. As the manual suggests, I bet everyone just used SizeOf() as the parameter, and I'm not so sure how useful

Re: [fpc-pascal] GetClipboardFormatName causing an Error 216

2020-12-30 Thread Alexander Grotewohl via fpc-pascal
The memory for FN is allocated at the top with StrAlloc() -- Alexander Grotewohl https://dcclost.com From: fpc-pascal on behalf of Martin Frb via fpc-pascal Sent: Wednesday, December 30, 2020 8:00 PM To: fpc-pascal@lists.freepascal.org Cc: Martin Frb Subject:

Re: [fpc-pascal] GetClipboardFormatName causing an Error 216

2020-12-30 Thread Alexander Grotewohl via fpc-pascal
Your FN:=''; is clobbering the pointer 'FN' with nonsense. Just leave that line out, it isn't necessary. Or do like FN^:=#0; if you want C-string like functions to report zero length.. -- Alexander Grotewohl https://dcclost.com From: fpc-pascal on behalf of

Re: [fpc-pascal] GetClipboardFormatName causing an Error 216

2020-12-31 Thread Alexander Grotewohl via fpc-pascal
yes, this type of thing is why we use Pascal. pchar is your little bucket of ram that FPC in a sense knows nothing about. set it to #0 and pray for the best, cause that's what you do.. -- Alexander Grotewohl https://dcclost.com From: fpc-pascal on behalf of

Re: [fpc-pascal] GetSaveFileNameA limited to 100 characters in default name

2021-06-21 Thread Alexander Grotewohl via fpc-pascal
It's best to think of these in two parts. The Windows API part and then the interfacing with Pascal part. SaveAsFileName.lpstrFile = long pointer to a (C) string filename buffer This buffer isn't created for you, you provide it and tell Windows it's size. If you were to just do StrPLCopy(

Re: [fpc-pascal] GetSaveFileNameA limited to 100 characters in default name

2021-06-18 Thread Alexander Grotewohl via fpc-pascal
The Windows API doesn't understand what an 'AnsiString' is and cannot resize it dynamically like FreePascal would do as it is used. You need to use something like buf: array[0..512] of char; TFileName.nMaxFile := sizeof(buf); But then you should also handle the possibility that the dir is

Re: [fpc-pascal] How to find where my app consumes CPU?

2021-05-18 Thread Alexander Grotewohl via fpc-pascal
-pascal Sent: Tuesday, May 18, 2021 6:29:17 PM To: fpc-pascal@lists.freepascal.org Cc: Bo Berglund Subject: Re: [fpc-pascal] How to find where my app consumes CPU? On Tue, 18 May 2021 21:40:15 +, Alexander Grotewohl via fpc-pascal wrote: >if it's waiting on keyboard input you might be bet

Re: [fpc-pascal] How to find where my app consumes CPU?

2021-05-18 Thread Alexander Grotewohl via fpc-pascal
if it's waiting on keyboard input you might be better off using select() for that instead of looping and checking for keyboard input each go around. sleep() might already do something similar with a zero timeout but even that would probably be insufficient -- Alexander Grotewohl

Re: [fpc-pascal] compiling on command line linux

2021-02-15 Thread Alexander Grotewohl via fpc-pascal
There's a command line parameter.. try something like fpc -FU~/.units.lnx yourapp.pp Of course you would have to remember to do that for EVERY compile (I set my text editor to do it) but you could probably add it to your fpc.cfg too. -- Alexander Grotewohl https://dcclost.com

Re: [fpc-pascal] Windows Defender considers fp.exe a malicious program

2021-02-12 Thread Alexander Grotewohl via fpc-pascal
Unfortunately from what I've read just using certain Windows APIs is enough to get an executable flagged. Probably nothing to be too concerned about. -- Alexander Grotewohl https://dcclost.com From: fpc-pascal on behalf of Alexander Bunakov via fpc-pascal

Re: [fpc-pascal] My Linux service application consumes 10% CPU when idling - why?

2021-10-24 Thread Alexander Grotewohl via fpc-pascal
In the end we have a black box with Indy that isn't going to be opened.. and from the sound of it, a dated method of manually checking for i/o (in this case likely with select() and a zero timeout..). Calling that and sleep() over and over millions of times.. I'm sorry to the OP if I'm

Re: [fpc-pascal] String error on Windows

2021-10-30 Thread Alexander Grotewohl via fpc-pascal
Because += is a mistake and hopefully it's irreparably broken. Does using just s:=s+';'; work? -- Alexander Grotewohl https://dcclost.com From: fpc-pascal on behalf of Hairy Pixels via fpc-pascal Sent: Saturday, October 30, 2021 11:09:49 PM To: FPC-Pascal

Re: [fpc-pascal] Text Only printing on Windows.

2022-02-09 Thread Alexander Grotewohl via fpc-pascal
Is this for a Dymo style printer? The easiest way you might do this nowadays is using the Windows API.. I'm sorry for the sort of pseudo-code but I'm stuck with examples my previous work owns so I have to paraphrase a bit: GetDefaultPrinter (so you don't have to enumerate and then find the

Re: [fpc-pascal] mciSendString with long file names

2022-09-20 Thread Alexander Grotewohl via fpc-pascal
I've only ever done this like: pcmd: string; pcmd:='open "'+filename+'" ... '+#0; mciSendString(@pcmd[1], ...); mciSendString does return errors.. duno if that'll be helpful. I originally used it in Virtual Pascal and had to make a partial header myself so the FreePascal one might take