The returntype of FileCreate is a THandle, which is a System.THandle, which is a Longint, which is - 2147483648..2147483647
Quote from: Zvoni on September 17, 2024, 04:22:43 pmThe returntype of FileCreate is a THandle, which is a System.THandle, which is a Longint, which is - 2147483648..2147483647Dont know where you found that. Just search in files with Regular Expressions for " THandle[ ]*=", in the FPC directory rtl. There is quite a great variety of specifications.
See first posthttps://www.freepascal.org/docs-html/rtl/sysutils/filecreate.html
Note the transtyping. It is not a comparison to -1.
Code: Pascal [Select][+][-] F := FileCreate(LogFileName); if F=-1 then
The samples contained in the documentation are not necessarily meant to be completely usable or even compileable. They simply illustrate the principles of what is documented.
Or use the INVALID_HANDLE_VALUE constant:
But using filecreate() itself is alreafy a shortcut and nobody uses it - or should use it. What is wrong with rewrite()? Because that is the correct syntax to create a file.