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 parameters differently.

From: fpc-pascal  on behalf of James 
Richters via fpc-pascal 
Sent: Tuesday, September 20, 2022 9:56:03 AM
To: 'FPC-Pascal users discussions' 
Cc: James Richters 
Subject: [fpc-pascal] mciSendString with long file names


I’m trying to get mciSendString() to work with long file names with spaces in 
them and I’m not having any success.

I know with winnows you need quotes around long file names, so I’m trying 
things like this:



Var MySoundFile:String;

mciSendString(PChar('play '+Ansistring(#34+MySoundFile+#34)),Nil,0,0);



But still it works if my file name has no spaces, but does not work if there 
are spaces.

I think maybe it’s my conversion to a PChar, but it works as long as there are 
no spaces, so I don’t know.



The name of my file is in a string because it comes from a record with a string 
variable in it.. part of another whole system that I don’t want to change just 
to get this to work.



Any one have any ideas how to get long file names with spaces to work?



James
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/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 right one, 
set the label printer to default)
CreateDC (we want something to draw our text to)

StartDoc(dc, @di); (our initial 'print')
StartPage(dc); (this in our case would be each label)

Some sample stuff to create a font you can use:

fillchar(lf, sizeof(lf), 0);
lf.lfWeight:=FW_NORMAL;
lf.lfHeight:=-MulDiv(12, GetDeviceCaps(dc, LOGPIXELSY), 72);
newfont:=CreateFontIndirect(@lf);
oldfont:=GetCurrentObject(dc, OBJ_FONT);
SelectObject(dc, newfont);

A little helper function.. not amazing but gets text mostly where you'd want it 
at column/row
procedure printxy(dc: HDC; x, y: byte; s: string);
begin
TextOut(dc, x*50, y*110, @s[1], length(s));
end;

EndPage(dc); (in our case end this label)
EndDoc(dc); (end the print job)

SelectObject(dc, oldfont); (cleanup)
DeleteObject(newfont);
DeleteDC(dc);

It'll take a bit of effort to read up on those functions and get them working 
right, but afterward you should have printing sorted for yourself as long as 
the windows api is supported.

--
Alexander Grotewohl
https://dcclost.com

From: fpc-pascal  on behalf of James 
Richters via fpc-pascal 
Sent: Wednesday, February 9, 2022 1:17 PM
To: 'FPC-Pascal users discussions' 
Cc: James Richters 
Subject: [fpc-pascal] Text Only printing on Windows.


Way back in the old Turbo Pascal days, it was super simple to send text to a 
printer…   I had written a program that printed text on labels in the

order the labels were needed.. the whole thing took me less than an hour to 
write and labels were spewing out of the printer.

I haven’t had a need to print anything since then, but now, I want to do the 
exact same thing.. print sequential text only labels from my FPC console 
program…

I can display the labels to the console window, or write them to a file… but 
I’m just staring at my code at a total loss on how to send these simple labels 
to my

USB label printer connected to a windows 10 64bit PC.  Is there no way to just 
send text to printers anymore?

I don’t want to go through the windows print dialog for every label, and I 
don’t want to create one huge document of all the labels and print them all at 
once..

I want my FPC console application to spit out the next in sequence single label 
each time I push the space bar, without dealing with any the print dialog or 
doing anything else.

This used to be so easy to do, but now it seems either very complicated or 
impossible.  Does anyone know of a way to just send pain text

to a USB printer with FPC ,preferably without Lazarus?



James
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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 users discussions 
Cc: Hairy Pixels 
Subject: [fpc-pascal] String error on Windows

Why isn't this syntax valid on Windows? Very confused.



{$mode objfpc}

program WindowsTest;

var
s: String;
begin
s += ';';//  Syntax error, ";" expected but "const char" found
end.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/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 assuming a lot but my guess is the code is a bit old 
and could use some refactoring to do away with the old Pascal "active loop."

--
Alexander Grotewohl
https://dcclost.com

From: fpc-pascal  on behalf of Bernd 
K. via fpc-pascal 
Sent: Saturday, October 23, 2021 6:46:21 AM
To: fpc-pascal@lists.freepascal.org 
Cc: Bernd K. 
Subject: Re: [fpc-pascal] My Linux service application consumes 10% CPU when 
idling - why?

Am 07.10.21 um 19:41 schrieb Bo Berglund via fpc-pascal:

> The question is: how to find what is still using CPU?

Have a look at the tool sysprof. This is a statistical sampling profiler
that can show you a call tree with percentages of CPU consumption. Thee
are also other sampling profilers around (oprofile, perf/hotspot,
google-gperftools, etc..) that all work by the same principle, you could
try which one suits you best. They should all be able to tell you where
exactly it spends how much of its CPU time. You don't need to instrument
the code, just compile it with dwarf debug info contained in the
executable (not as external debug file), maybe also reduce the
optimization level if, and it should be able to show you the call tree
along with time consumption of each function.

Bernd


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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( SaveAsFileName.lpstrFile, DefaulSaveAsFileName, Max_Path+1);

there is no buffer there to receive DefaultSaveAsFileName. (or more correctly 
the lpstrFile pointer will point to random memory).

So, you first create the buffer, StrPLCopy the default string into it, and then 
pass it to the Windows API.

On return, it uses that same buffer (Windows doesn't have to create the buffer 
because you did) and knows the maximum it can place into the buffer (because 
you provided that information).

Afterwards you can take that buffer (a C-string) and convert it to something 
Pascal-like again.

This is important because almost everything you do with the Windows API will be 
some variant of this procedure and you need to be able to repeat this every 
time you use it without bugs 

--
Alexander Grotewohl
https://dcclost.com

From: fpc-pascal  on behalf of James 
Richters via fpc-pascal 
Sent: Monday, June 21, 2021 1:56 PM
To: 'FPC-Pascal users discussions' 
Cc: James Richters ; 'Jean SUZINEAU' 

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

>I would prefer to use
> StrPLCopy( SaveAsFileNameBuffer, DefaulSaveAsFileName,
SizeOf(SaveAsFileNameBuffer));
>instead of
>  SaveAsFileNameBuffer:=Pchar(DefaulSaveAsFileName);

I'm curious what the difference is between StrPLCopy() and PChar()

I wonder if PChar() was my problem.. maybe I don't need the buffer, maybe I
just needed:
StrPLCopy( SaveAsFileName.lpstrFile, DefaulSaveAsFileName, Max_Path+1);
?

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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 greater than 
512 and allocate a bigger buffer as needed.
So maybe dynamically allocating the space would be better.

--
Alexander Grotewohl
https://dcclost.com

From: fpc-pascal  on behalf of James 
Richters via fpc-pascal 
Sent: Friday, June 18, 2021 1:56 PM
To: 'FPC-Pascal users discussions' 
Cc: James Richters 
Subject: [fpc-pascal] GetSaveFileNameA limited to 100 characters in default name


I’m using GetSaveFileNameA() in a windows console program to obtain a save-as 
directory and file name, I am passing  sending it a default file name with:



TFileName.lpstrFile:=Pchar(DefaultFileName);



DefaultFileName is an AnsiString that contains a full path and filename.



This all works fine as long as DefaultFileName is 100 characters or less,  if 
it’s 101 or more, then GetSaveFileNameA() never opens a dialog box and just 
returns False;



Does anyone know where the 100 character limit is coming from?



TFileName.lpstrFile is a PChar, and DefaultFileName is an AnsiString, Neither 
of which have a length limit that I know of…

I am doing a Writeln if Both DefaultFileName and TFileName.lpstrFile and they 
both match, nothing is being truncated.



James
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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

2021-05-18 Thread Alexander Grotewohl via fpc-pascal
https://www.freepascal.org/docs-html/rtl/baseunix/fpsigtimedwait.html

there we go :) i think this should do the trick. might need to rearrange some 
things though..

--
Alexander Grotewohl
https://dcclost.com

From: fpc-pascal  on behalf of Bo 
Berglund via fpc-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 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

As I tried to explain at the start of this thread my application runs as a
*systemd service* on Linux, so there is absolutely no keyboard input.

The main program looks like this after initializations etc:

  try
try
  bSTerm := False;
  bSInt := False;
  bsHup := False;
  {$IFDEF UNIX}
  fpSignal(SigTerm, SignalHandler(@handleSignal));
  fpSignal(SigInt, SignalHandler(@handleSignal));
  fpSignal(SigHup, SignalHandler(@handleSignal));
  {$ENDIF}

  Debug_Writeln('Enter eternal loop');
  FLogServ.StdLog('Enter eternal loop');

  While not (bSTerm or bSInt or bsHup) do
  begin
//Here is where the server runs as defined elsewhere
//Eternal loop to wait for system messages
Sleep(1); //To not hog the CPU
CheckSynchronize; //To get thread comm working
  end;

  Debug_Writeln('Exit eternal loop');
  FLogServ.StdLog('Exit eternal loop');
except
  on E: Exception do
  begin
FLogServ.ExceptionLog('Unhandled exception: ' + E.Message);
  end;
end;
  finally
ShutdownServer;
  end;

As you can see it sits in the eternal loop until the system sends a "signal" to
it to stop. So systemd does that if I issue a sudo systemctl stop myservice and
this works fine.
Could this tiny loop consume 6-7% CPU cycles?


--
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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
https://dcclost.com

From: fpc-pascal  on behalf of Travis 
Siegel via fpc-pascal 
Sent: Tuesday, May 18, 2021 5:29:10 PM
To: bo.bergl...@gmail.com ; FPC-Pascal users discussions 

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

I'm not positive, but I'm pretty sure the sleep command in linux does
not behave the same way it does in windows.

As you know, in windows, a sleep command (even if delivered with a
parameter of 0) gives up time slices to other programs on the system.
This does not appear to be the case on linux.

On linux, the sleep command simply suspends the process for the
specified amount of time, but so far as I can tell, does nothing for
unused cpu cycles.

I've done a little digging, but I can't find any way on linux to give
away unused cpu cycles.

Perhaps the linux task switcher doesn't allow for this capability?


On 5/18/2021 3:59 PM, Bo Berglund via fpc-pascal wrote:
> I have a pretty sizable console app written with Delphi 15 years ago but 
> ported
> to Linux using FreePascal (3.2.0) with Lazarus (2.0.12) as IDE. It runs as a
> systemd service on a Raspberry Pi3.
>
> Basically it is a scheduler, which checks every minute if there is a task to
> run, otherwise it waits for the next minute to pass.
>
> Meanwhile in another thread there is a TCP/IP socket server active for
> communicating with the app over the network. So it is listening for incoming
> connections.
>
> This is working seemingly OK, but today when I checked the RPi I found using 
> top
> that it was running 11% CPU, which is strange because it has nothing to do at
> the moment.
>
> I have tried to be as conservative as possible regarding wait loops etc so in
> such loops I always have a sleep() call, which in my Windows experience used 
> to
> stop excessive CPU usage.
>
> So I was surprised to find the high CPU usage and now I am at a loss on how to
> find *where* this is happening...
>
> Any ideas on how to proceed?
> Is there some Lazarus way to find this?
> (But I cannot really run the application in service mode from within 
> Lazarus...)
>
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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


From: fpc-pascal  on behalf of duilio 
foschi via fpc-pascal 
Sent: Monday, February 15, 2021 2:20:28 PM
To: FPC-Pascal users discussions 
Cc: duilio foschi 
Subject: [fpc-pascal] compiling on command line linux

Today I had to compile a program on my Linux server.

The program was written for windows and needed libraries synapse and lazutils, 
and they were missing from the server.

I copied  all the needed units from my PC into the linux work directory and it 
worked with the usual command

fpc programname.pp

Unfortunately now my work directory is messy with tens of units (belonging to 
libraries synapse and lazutils) unworthily mixed with my poor code.

I guess that the kosher way is to create directories lazutils and synapse 
somewhere in the server but ... where?

Where should libraries be copied in linux?

How to make them accessible to the compiler?

Sorry for being so ignorant... I know how to do it in Lazarus on windows, but 
fpc on linux is rather arcane to me :)

Thank you

Duilio




___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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 
Sent: Thursday, February 11, 2021 3:22:40 AM
To: fpc-pascal@lists.freepascal.org 
Cc: Alexander Bunakov 
Subject: [fpc-pascal] Windows Defender considers fp.exe a malicious program

Hello all,

As of trunk r48648, Windows Defender deletes fp.exe after compilation
because it considers it an infected file. It claims that fp.exe is
infected with Trojan:Win32/Fuerboos.E!cl and quarantines the file.

Anyone else is experiencing this? Any idea why is this happening?

--
Regards,
Alexander
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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 Jean 
SUZINEAU via fpc-pascal 
Sent: Friday, January 1, 2021 2:41:18 AM
To: fpc-pascal@lists.freepascal.org 
Cc: Jean SUZINEAU 
Subject: Re: [fpc-pascal] GetClipboardFormatName causing an Error 216

Le 01/01/2021 à 00:48, James Richters via fpc-pascal a écrit :

I’m not too familiar with PChars, but is there a way to set it to zero length?

I set it to #0 and it works ok with the #0 in there with Notepadd++ but I think 
it’s technically not correct.

For me, it's correct. C strings are just terminated with a null character, no 
notion of length, the length is not recorded in the string as in Pascal.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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

On 31/12/2020 01:09, James Richters via fpc-pascal wrote:
> Var
> FN : LPTSTR;
>
> Begin
>
> FN:='';
> Writeln(Format_ID);
> GetClipboardFormatName(Format_Id,FN,250);
>

Check the msdn help.
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclipboardformatnamea

FN must point to an existing buffer (allocated mem) that receives the
result.

FN : Array [0..255]of Byte;
GotLen := GetClipboardFormatName(Format_Id, LPTSTR(@FN[0]),250);

then "move()" the received bytes into a string, make sure to use
UniqueString() or similar

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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 James 
Richters via fpc-pascal 
Sent: Wednesday, December 30, 2020 7:09 PM
To: 'FPC-Pascal users discussions' 
Cc: James Richters 
Subject: [fpc-pascal] GetClipboardFormatName causing an Error 216

I'm trying to write a programs to get data from the windows clipboard that
was put into it with Notepad++ using vertical editing.
It uses a non-standard format and I'm trying to figure it out.
GetClipboardFormatName is supposed to get me the name of non-standard
formats,
but whenever I try to run it, I get a runtime error 216

I found some python code at: https://gist.github.com/adam-p/2514182 that I'm
trying to convert to FPC.
My fork is at:
https://gist.github.com/Zaaphod/7d94e1d712a5b9ac2bcb0bc79f039a63 Which shows
both the original python code and my FPC attempt

It works fine for standard formats:

Running "i:\programming\gcode\test\clipboard formats.exe "
Number of formats: 4
13 CF_UNICODETEXT
16 CF_LOCALE
1 CF_TEXT
7 CF_OEMTEXT

But if I highlight some text in Notepadd++ using vertical editing, holding
down Shift and ALT while using the arrow keys to highlight a block of text,
and the copy that to the clipboard, I get the following:

Running "i:\programming\gcode\test\clipboard formats.exe "
Number of formats: 6
13 CF_UNICODETEXT
49882
Runtime error 216 at $774C246C
  $774C246C
  $76932F63
  $76932EB7
  $004017EC  main,  line 60 of i:/programming/gcode/test/clipboard
formats.pas
  $00408F67

Line 60 is:
   GetClipboardFormatName(Format_Id,FN,250);

It only gets run for non-standard formats.  As I understand it that's all it
us supposed to be used for.

It's pretty short program so I pasted it below.

Any ideas on what I'm doing wrong here?

James

-


uses
   Windows,strings;
Type
   BT = Record
  BT_ID: Byte;
  BT_Name: String;
   End;

Const
builtin_type: Array [0..22] of BT = (
{ 0} (BT_ID:2   ;BT_Name:'CF_BITMAP' ),
{ 1} (BT_ID:8   ;BT_Name:'CF_DIB'),
{ 2} (BT_ID:17  ;BT_Name:'CF_DIBV5'  ),
{ 3} (BT_ID:5   ;BT_Name:'CF_DIF'),
{ 4} (BT_ID:130 ;BT_Name:'CF_DSPBITMAP'  ),
{ 5} (BT_ID:142 ;BT_Name:'CF_DSPENHMETAFILE' ),
{ 6} (BT_ID:131 ;BT_Name:'CF_DSPMETAFILEPICT'),
{ 7} (BT_ID:129 ;BT_Name:'CF_DSPTEXT'),
{ 8} (BT_ID:14  ;BT_Name:'CF_ENHMETAFILE'),
{ 9} (BT_ID:15  ;BT_Name:'CF_HDROP'  ),
{10} (BT_ID:16  ;BT_Name:'CF_LOCALE' ),
{11} (BT_ID:18  ;BT_Name:'CF_MAX'),
{12} (BT_ID:3   ;BT_Name:'CF_METAFILEPICT'   ),
{13} (BT_ID:7   ;BT_Name:'CF_OEMTEXT'),
{14} (BT_ID:128 ;BT_Name:'CF_OWNERDISPLAY'   ),
{15} (BT_ID:9   ;BT_Name:'CF_PALETTE'),
{16} (BT_ID:10  ;BT_Name:'CF_PENDATA'),
{17} (BT_ID:11  ;BT_Name:'CF_RIFF'   ),
{18} (BT_ID:4   ;BT_Name:'CF_SYLK'   ),
{19} (BT_ID:1   ;BT_Name:'CF_TEXT'   ),
{20} (BT_ID:6   ;BT_Name:'CF_TIFF'   ),
{21} (BT_ID:13  ;BT_Name:'CF_UNICODETEXT'),
{22} (BT_ID:12  ;BT_Name:'CF_WAVE'   ));

Var
   i,j,Number_Of_Formats : Byte;
   Format_ID : DWord;
   FN : LPTSTR;
   Format_Name : String;

Begin
   FN:=StrAlloc (255);
   OpenClipboard(0);
   Number_Of_Formats := CountClipboardFormats();
   Writeln('Number of formats: ',Number_Of_Formats);
   format_id := 0;
   for i := 1 to Number_Of_Formats do
  Begin
 Format_Name := 'FAILED';
 Format_ID:=EnumClipboardFormats(Format_ID);
 For J:= 0 to 22 do
Begin
   If Format_ID = builtin_type[J].BT_ID then
  Format_Name := builtin_type[J].BT_Name;
End;
 If Format_Name = 'FAILED' Then
Begin
   FN:='';
   Writeln(Format_ID);
   GetClipboardFormatName(Format_Id,FN,250);
   Writeln(FN);

   If strpas(FN) <> '' Then
  Format_Name := StrPas(FN);
End;
 Writeln(Format_ID,' ',Format_Name);
 End;
CloseClipboard();
End.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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 using freemem like above would be..

--
Alexander Grotewohl
https://dcclost.com


From: fpc-pascal  on behalf of Marco 
van de Voort via fpc-pascal 
Sent: Wednesday, December 30, 2020 5:56:45 PM
To: FPC-Pascal users discussions 
Cc: Marco van de Voort 
Subject: Re: [fpc-pascal] Two versions of freemem() - are they equal


Op 2020-12-30 om 23:54 schreef Graeme Geldenhuys via fpc-pascal:
> Do both these method yield the same result, or is one better (performance,
> safer?) that the other?
>
>
> procedure FreeMem(p:pointer;Size:ptruint);
> procedure FreeMem(p:pointer);
They are the same.   TP required size for deallocation, Delphi and FPC
don't.  The overload with size is for TP compatibility.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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 the fpmmap docs you 
posted. My guess is the easiest answer is "distribute both 32 and 64 bit 
versions," but that doesn't help when you need to test the 32 bit one..

--
Alexander Grotewohl
https://dcclost.com

--
Alexander Grotewohl
https://dcclost.com

From: fpc-pascal  on behalf of Rainer 
Stratmann via fpc-pascal 
Sent: Friday, November 20, 2020 6:33:51 PM
To: fpc-pascal@lists.freepascal.org 
Cc: Rainer Stratmann 
Subject: [fpc-pascal] fpmmap problem 64 bit linux

A 32 bit freepascal program on a 32 bit Linux Debian system is working
properly. It uses fpmmap for getting the adress of a kms framebuffer.

The same 32 bit program on a 64 bit Linux Debian system *** is not working.
When it comes to the fpmmap it gives an error:

Sys_EINVAL
One of the record fields Start, length or offset is invalid.

https://www.freepascal.org/docs-html/rtl/baseunix/fpmmap.html

I figured out that it likely can only be the offset value since start and length
are always the same.

The offset value I got from a previous DRM function.

On the 32 bit System this offset value is $1000 (fits in 32 bit)
And on the 64 bit System this offset value is $1 (does not fit in 32
bit).

Can it be possible that the fpmmap function strips the offset value to 32 bit?
Is there another way to call fpmmap more directly?
What does fpmmap exactly?
Where can I research?


***
dpkg --add-architecture i386
apt-get update
apt-get install libc6-i386


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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, 2020 12:39:43 PM
To: FPC-Pascal users discussions 
Cc: Ryan Joseph 
Subject: Re: [fpc-pascal] Adding file to string to the RTL



> On Oct 6, 2020, at 2:12 AM, Michael Van Canneyt via fpc-pascal 
>  wrote:
>
> I added the following functions to the sysutils unit (rev 47056):

Great, thanks Michael.

I've always used AnsiString so why is UnicodeString preferable here?

So is the idea we need to specify an UTF-8 encoding for unicode otherwise it 
assumes ASCII format? I didn't specify the encoding with TStringList and I 
always seemed to get back what I wanted (maybe it sniffed the encoding from the 
file?).

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal