[fpc-pascal] FpcGui, MSEGui
Have you worked with both? Both are pure FreePascal GUIs, not depending of ant external library. What are the differences? Which one do you think is more mature, supported, fetaures, etc...? Just a little of flame is not bad ;-) -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Bookmark, TBookmarkStr, TBytes and BytesOf
Hello: Freepascal 3.2.0. Windows 7-32bits TMyObject=class private fDset:TDataset; function GetBookmark:TBookmarkStr; ... end; function TMyObject.GetBookmark:TBookmarkStr; Begin result:=FDset.Bookmark; end; I get this compiling error: Incompatible types: got "TBytes" expected "AnsiString" Nevertheless, /TbookmarkStr/ documentation example assigns bookmark property to a TBookmarkStr variable https://www.freepascal.org/docs-html/fcl/db/tdataset.bookmark.html I have considered to convert the TBytes to AnsiString, but instead to doing a research about AnsiString internals, or creating a function that copies bytes in a loop, I supposed that there was already a function to do that. I found BytesOf https://www.freepascal.org/docs-html/rtl/sysutils/bytesof.html The abstract is "Return the bytes in a string", when in fact, according with the text below, it does the opposite, returns the string in an array of bytes. Is there any function that move the bytes to an AnsiString? -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] function const default argument
Hello: Freepascal 3.2.0. Windows 7-32bits I have these functions: function F(const x:extended; const delta:extended=1E-8):extended; function G(const x:extended; const delta:extended=1E-8):extended; and I want to parametrize like this: const DefaultDelta:extended = 1E-8; function F(const x:extended; const delta:extended=DefaultDelta):extended; function G(const x:extended; const delta:extended=DefaultDelta):extended; But I get "Illegal expression" in the header function declaration. Const parameters don't accept const expressions? -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fcl-web: Trequest.RemoteAddr is empty (sometimes)
El 08/01/2021 a las 10:16, Luca Olivetti via fpc-pascal escribió: El 7/1/21 a les 16:59, Luca Olivetti via fpc-pascal ha escrit: El 7/1/21 a les 16:15, Luca Olivetti via fpc-pascal ha escrit: Hello, I need to tailor the content based on the remote ip address. I use the property RemoteAddr of a TRequest, but sometimes it is empty. I see that it is a header, what I didn't see (yet, I'll trace through the code later) is if it is sent from the remote host or is it filled based on the ip address of the connection. If the former, is there a more reliable way to obtain the connected ip address? If the latter is it a bug? I now see that it set in TFPHTTPConnection.ReadRequestHeaders: Result.RemoteAddress := SocketAddrToString(FSocket.RemoteAddress) In turn SocketAddrToString returns an empty string if the address is ipv6, but in my case it shouldn't be (the clients, firefox under windows 10 uses the ipv4 address of the server and most of the time I get the correct remote address, even from the same client). Besides, it seems that the server only listens on ipv4. I'm puzzled, I really can't see where this empty RemoteAddress could come from. Bye In windows 10 when you connect to localhost, it may connect with IPV6 and route to ipv4 with weird results. Try to connect using IP 127.0.0.1 http://127.0.0.1 You may also add in C:\Windows\System32\drivers\etc\hosts a line like localhost4 127.0.0.1 and then http://localhost4 You may also disable IPV6 service if you don't use it. I have, because it is seldom used, it looks like every device/system still works only with IPV4 -- Saludos Santiago A. ___ 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
El 06/10/2020 a las 01:08, Jean SUZINEAU via fpc-pascal escribió: In my own code I use BlockRead/BlockWrite, but I'm wondering if I've not seen this somewhere in RTL. https://github.com/jsuzineau/pascal_o_r_mapping/blob/TjsDataContexte/pascal_o_r_mapping/02_Units/uuStrings.pas <https://github.com/jsuzineau/pascal_o_r_mapping/blob/TjsDataContexte/pascal_o_r_mapping/02_Units/uuStrings.pas> Just nitpicking. Shouldn't "try" be after the "reset" and after the "rewrite"? Why don't you allow to write an empty string? function String_from_File( _FileName: String): String; var F: File; Longueur: Integer; begin Result:= ''; if not FileExists( _FileName) then exit; AssignFile( F, _FileName); try Reset( F, 1); Longueur:= FileSize( F); if 0 = Longueur then exit; SetLength( Result, Longueur); BlockRead( F, Result[1], Longueur); finally CloseFile( F); end; end; procedure String_to_File( _FileName: String; _S: String); var F: File; begin if '' = _S then exit; AssignFile( F, _FileName); try ReWrite( F, 1); BlockWrite( F, _S[1], Length( _S)); finally CloseFile( F); end; end; ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] stdcall without the ;
El 23/09/2020 a las 19:45, Luca Olivetti via fpc-pascal escribió: El 23/9/20 a les 17:38, Santiago A. via fpc-pascal ha escrit: El 23/09/2020 a las 13:54, Luca Olivetti via fpc-pascal escribió: Hello, I just compiled a lazarus project made in 2105 with fpc 3.2.0 and, while it works here, it fails when the customer runs it. What does "it fails" mean? Any error message? Sigfault? I'm not at the customer's site, but he told me that it does nothing, it shows nothing and it's not visible in the task manager. What's worse, I have an application exception handler that logs the first unmanaged exception to a file and the halts the program, well, the customer says the file doesn't exist, so I presume there's no unmanaged exception or the application doesn't even reach the handler. Bye Little information ;-) You could try a few things to get more data about what is the point where the program breaks: * Add some log information (write to a log file, not through exception) in the lpr file before it starts the application run. * Add to the main form in the create constructor and in the formcreate event some log information. If the programs doesn't starts at all, then probable you have any problem at binary level. That is usually hard the find. You could ask the customer to run it from cmd prompt. Sometimes it displays some informative message. Once I had the problem that 32bits worked fine in my PC, but failed in customer's system. The problem was that I was using firebird but the customer had installed 64bits version, so the client library fbclient.dll was 64bits and exe 32bits. I copied a 32bits fbclient.dll to the exe directory and everything worked fine. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] stdcall without the ;
El 23/09/2020 a las 13:54, Luca Olivetti via fpc-pascal escribió: Hello, I just compiled a lazarus project made in 2105 with fpc 3.2.0 and, while it works here, it fails when the customer runs it. What does "it fails" mean? Any error message? Sigfault? -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] String literals and code page of .pas source file
El 09/09/2020 a las 10:02, Bart via fpc-pascal escribió: On Wed, Sep 9, 2020 at 8:37 AM LacaK via fpc-pascal wrote: I am still confused how this CodePage aware stuff is expected to work and when implicit conversios are included (as far as I understand here ONLY declared/static codepage plays role) and when dynamic codepage is taken into account and when not? You are not the only one. Yeah. In fact, we could set up several self-help groups of codepage victims ;-) https://wiki.freepascal.org/Unicode_Support_in_Lazarus#Assign_string_literals_to_different_string_types is scaring. All the doubts, questions, and discussions prove that current system is counter-intuitive and confusing. I'm sorry, I don't want to bash, but code pages system must be revised almost from scratch, even breaking compatibility. It is a heavy lodge that FPC is carrying. The longer it takes to get rid of it, the worse. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Converting http date back to TDateTime
El 29/04/2020 a las 19:31, Zamrony P. Juhara via fpc-pascal escribió: Yes, it works if I remove timezone part from pattern as suggested by Santiago. This one works adatetime := scanDateTime( 'ddd, dd mmm hh:mm:ss', 'Tue, 28 Apr 2020 10:11:12 GMT'); So i guess, we must convert timezone information to local timezone manually. yes. In unit Dateutils https://www.freepascal.org/docs-html/rtl/dateutils/index-5.html You have a lot of handy functions: function UniversalTimeToLocal( UT: TDateTime <https://www.freepascal.org/docs-html/rtl/system/tdatetime.html> ):TDateTime <https://www.freepascal.org/docs-html/rtl/system/tdatetime.html>; function UniversalTimeToLocal( UT: TDateTime <https://www.freepascal.org/docs-html/rtl/system/tdatetime.html>; TZOffset: Integer <https://www.freepascal.org/docs-html/rtl/system/integer.html> ):TDateTime <https://www.freepascal.org/docs-html/rtl/system/tdatetime.html>; function LocalTimeToUniversal( LT: TDateTime <https://www.freepascal.org/docs-html/rtl/system/tdatetime.html> ):TDateTime <https://www.freepascal.org/docs-html/rtl/system/tdatetime.html>; function LocalTimeToUniversal( LT: TDateTime <https://www.freepascal.org/docs-html/rtl/system/tdatetime.html>; TZOffset: Integer <https://www.freepascal.org/docs-html/rtl/system/integer.html> ):TDateTime <https://www.freepascal.org/docs-html/rtl/system/tdatetime.html>; function UniversalTimeToLocal( UT: TDateTime <https://www.freepascal.org/docs-html/rtl/system/tdatetime.html> ):TDateTime <https://www.freepascal.org/docs-html/rtl/system/tdatetime.html>; function UniversalTimeToLocal( UT: TDateTime <https://www.freepascal.org/docs-html/rtl/system/tdatetime.html>; TZOffset: Integer <https://www.freepascal.org/docs-html/rtl/system/integer.html> ):TDateTime <https://www.freepascal.org/docs-html/rtl/system/tdatetime.html>; function GetLocalTimeOffset: Integer <https://www.freepascal.org/docs-html/rtl/system/integer.html>; Thank you Zamrony P. Juhara https://v3.juhara.com https://github.com/zamronypj Fano Framework https://fanoframework.github.io mod_pascal https://zamronypj.github.io/mod_pascal On Wed, Apr 29, 2020 at 16:40, Santiago A. wrote: ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org <mailto: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 -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Converting http date back to TDateTime
El 29/04/2020 a las 04:44, Zamrony P. Juhara via fpc-pascal escribió: No it does not work. Docs says literal string needs to be quoted with " Zamrony P. Juhara On Wed, Apr 29, 2020 at 9:37, Alexander Grotewohl wrote: ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org <mailto: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 This format works for me: 'ddd, dd mmm hh:nn:ss' Fpc 3.04, windows 7, 32bits, and fpc 3.04, Linux, 64bits. Some points: * "m" is allowed for minutes , nevertheless, I use for minutes "n", not "m". * I have suppressed the time zone information, I couldn't see how to set it in formatStrings, nevertheless, it ignores the GMT, or anything after time in input string with no error. * I think that the scanner ignores the character after weekday, it expects a separator, as long as it is not a "d" if will accept and skip anything. So the double quote after the three "d" of 'ddd", "dd is ignored and everything breaks. It's a little confusing. * The weekday and month depend on you local. * using non-ascii characters breaks things. In Spanish Wednesday is "Miércoles" (e with acute accent) and Tuesday is "Martes": "mar, 28 abr 2020" works, but "Mié, 29 Abr 2020" fails. I think that the problem is that é uses two bytes in UTF-8, but scan only deals properly with single byte characters -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] New Warnings with fpc >= 3.2.0
El 11/03/2020 a las 16:37, wkitt...@windstream.net escribió: On 3/11/20 11:35 AM, fredvs via fpc-pascal wrote: f (kind in tabulatorkindty) then Yes, I like it! But, sadly, the compiler no. "Error: Operator is not overloaded"... that's weird... i thought that construct was standard for arrays and similar... hummm... You should define type Set_Of_tabulatorkindty= set of tabulatorkindty; const AlltabValues:Set_Of_tabulatorkindty=[low(tabulatorkindty)..high(tabulatorkindty)]; then if (kind in AlltabValues) then is right Nevertheless, "kind" is of type "tabulatorkindty", so it is always in the range. The only case when it is not in the range is if it is uninitialized. And in Pascal, fields of objects are initialized (nil, or zero, or empty string etc), but uninitilized variables don't contain uninitialized values, contain garbage, dangerous garbage. So, in pascal, you don't test if a variable contains an uninitiliazed value, you initialize it before referring the variable. And before assigning a value, you verify it is in the range. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] New Warnings with fpc >= 3.2.0
El 13/03/2020 a las 15:49, fredvs via fpc-pascal escribió: Hello Santiago. What do you think? IMHO ---> kind := tabulatorkindty(-1); makes no sense. Why should you initialize a variable on purpose to an out-of-range value? If you need a sentinel value, or a non valid value, create one, like NIL for pointers or NaN for numbers or Nul in variants kind := tak_none Yeah. That is the way. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] New Warnings with fpc >= 3.2.0
El 11/03/2020 a las 11:15, fredvs via fpc-pascal escribió: ---> tabulatorkindty = (tak_left,tak_right,tak_centered,tak_decimal,tak_none); ? And then use: ---> if (kind <> tabulatorkindty(tak_none) ? Or do you have a other idea? Yes, for my taste that is the way to go. But you don't need to convert the type: if (kind <> tak_none) Nevertheless. I supposse you are reading from a format that stores tabulatorkindty value as an integer. In such cases I want to be in the safe side and control everything of external input data: function ToTabulartoryKind(intValue:Integer):tabulatorkindty; begin if (intValue>=ord(Low(tabulatorkindty))) and (intValue<=ord(high(tabulatorkindty))) then Result:=tabulatorkindty(intValue) else Result:=tak_none; //you could use set and IN operando but sometimes I've had problems with big integers end; I'd probable would add a value tk_invalid. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] specify variable name with string variable
El 08/07/2019 a las 22:43, James Richters escribió: ports that are defined by port numbers and pins in an ini file, Well, then they are dynamic. They are not hardcoded. I would use something like: TPortIdentifier=(Pin_1, pin_2, Port_x, Port_y...); TIOPort=object private FPortPin:boolean; FPortByte:boolean; procedure SetPortPin(value:boolean); procedure SetPortByte(value:byte); public OtherData:... // pin, port etc or other data PortAdress:PWord; // pointer to memory Name:string; constructor Init(aName:name;aPword:pWord); property PortPin:boolean read fPortPin write SetPortPin; property PortByte:byte read fPortByte write SetPortByte; end; TPortList=array[TPortIdentifier] of TIOPort; var PortList:TPortList; begin // fill the array with name and values from Ini file PorList[Pin_1].init('Pin-1',@); PorList[Pin_2].init('Pin-2',@); // call PortList[pin_1].PortPin:=true; PortList[pin_2].PortPin:=false; end. Or you can use a TFPGMap from the standard library fgl. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] specify variable name with string variable
El 07/07/2019 a las 21:58, James Richters escribió: This might sound silly, but is it possible to somehow specify a variable with a string containing the name of the variable? For example: Var MyVariable1 : Word; MyVariableName : String; Procedure ShowVariable(Variablename); Begin Writeln(Variablename,' = $', inttohex((Somehow get the value of the variable specified by the name here ) ,4)); End; Begin MyVariableName:= 'MyVariable1'; ShowVariable(MyVariableName); End. Is such a thing possible? What is it for? What about: procedure ShowVariable(const Variablename:string; const value:word); begin Writeln(Variablename,' = $'+inttohex(value ,4)); end; ShowVariable('myVar',myVar); And as far as I understand, you want to call ShowVariable('myVar',myVar), but not wasting time writing the name enclosed in quotes, let the program get the identifier name in runtime, or the other way around, let the program get the value from a name passed in runtime. Bad luck, Pascal is not a script language, it is not aware of identifier names in runtime there is no "eval". Thanks to that it gets rids of all the burden of having to keep in runtime structures to know the name, type and value of variable. It generate fast native programs. Nevertheless, there are ways, you can program that in Freepascal using classes, properties, RTII etc. It is more flexible and powerful. But obviously it has a price in complexity. Instead or using the standard operators and reference a simple variable, you must use a more convoluted syntax. As far as I see, you don't intend to let the program create new vars in runtime, you just want to write the identifiers of the vars you have hardcoded. Is it worth? (I hope it is not just for debugging) -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Getting multiple files from GetOpenFileNameA
El 23/05/19 a las 13:52, James Richters escribió: I have put together a program that demonstrates the issue I am having. I have re-structured it a bit to try to make it more clear where the problem is. While putting this together, I was able to get it to run fine with no problems if I did not try to put GetOpenFileNameA back to the directory of the last file I processed. Including a file sent in as a parameter. If I set Open_File.lpstrFile:=Pchar(Target_File+#0+#0); where Target_File is the complete path and file name of the last file I processed, If I select only one file, then the next time around it DOES work.. and will put me in the directory of Target_File and will show the filename of Target_File as a default, but if I select more than one file, the next time around, it crashes.. I have detailed the crash information in the sameple program comments. Another way I wish to run this is to leave Open_File.lpstrFile alone and use Open_File.lpstrInitialDir to put me in the directory of the last processed file, but not specify a default filename. I can’t get this to work correctly at all, but if I use Open_File.lpstrInitialDir without Open_File.lpstrFile then it does not crash, I am just not put in the directory I expect to be in. Any Advice or suggestions on any of this, or on how I could improve the structure or methods of this program are greatly appreciated. At the beginning you set Open_File.lpstrFile:=ret; That is right Open_File.lpstrFile points to "ret", and "ret" is an array of 10, a good buffer. The problem is here: Open_File.lpstrFile:=Pchar(Target_File+#0+#0); That is wrong. Now Open_File.lpstrFile doesn't point to "ret" anymore, now it points to a string with length(Target_File)+2. But Open_File.nMaxFile:=10, so the GetOpenFileNameA thinks there is plenty of room, so rises no error and overwrites whatever is after Target_File+#0+#0. instead of Open_File.lpstrFile:=Pchar(Target_File+#0+#0); write ret:=Pchar(Target_File+#0) You should initialize to "ret" in each loop, in fact, it should be initialized inside the procedure. and Open_File.lpstrFilter:='All Files (*.*)'+#0+'*.*'+#0; needs an extra #0; In addition, just for style, instead of Open_File.nMaxFile:=10 write Open_File.nMaxFile:=sizeOf(ret); And why are all those variables global if they are only used inside the procedure? And instead of this Filenum:=0; Repeat Inc(Filenum); If (Filenum'\' Then Target_File:=Target_File+'\'; Target_File:=Target_File+File_Stringlist[Filenum]; Process_File(Target_File); End; Until Filenum>=File_Stringlist.Count; Replace with Target_File:=IncludeTrailingPathDelimiter(File_Stringlist[0]); for file_num:=1 to File_Stringlist.count-1 do Process_File(Target_File+File_Stringlist[Filenum]); FOR is you friend -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Getting multiple files from GetOpenFileNameA
El 21/05/19 a las 23:17, James Richters escribió: I have it defined with the program variables: Here are all my Uses and Vars: Uses ptcgraph,sysutils,Windows,Commdlg,Classes,CRT; Var TFilename : TOpenFileNameA; ret: array[0..100] of char; OpenFileResult : Boolean; LoopX,filenum : Longint; filenamestr: ansistring; File_Stringlist: tstringList; Are all those variables global unit scope? Some points about design: 1) I think that file_StringList should be a parameter passed to the function GetFilesIntoStringlist and created by the caller. Procedure GetFilesIntoStringlist(var File_Stringlist:TStrings); 2) "TFilename" is a bad name for a variable. First, it is clashes with a system type name. Second, starting it with "T" looks like a type name. Rename to CurrentFileName, or OpenFileForWin, or something like that. Try this way. Instead of adding each char to the string, that means reallocating, use the standard function StrPas Loopx:=0; Repeat Filenamestr:=StrPas(@TFileName.lpstrFile[loopX]); Writeln(Filenamestr); File_Stringlist.add(Filenamestr); inc(Loopx,length(Filenamestr)+1); Until TFileName.lpstrFile[loopx]=#0; Write the simplest project with this function that raises the error and we can run and reproduce. Nevertheless, if you get random errors it is some kind of memory error, probably overwrite in some place. It doesn't look the problem is here. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] XML - Indent, text content, special char
El 27/04/19 a las 13:29, Gabor Boros escribió: Hi All, I have an existing XML file. After load(, modify) and save this file some mandatory formatting things lost from it. I need same indent as before, same text contents and not replace every special chars. If you need the same indent or special chars, XML is not the right format for you. Consider it -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Public key algo pascal only
El 06/04/19 a las 19:26, José Mejuto escribió: El 05/04/2019 a las 19:08, Виктор Матузенко escribió: Hi, try this https://github.com/delphi-pascal-archive/Pascal-RSA Hello, Thank you. It is a bit "monster" but maybe I can split the necessary code. Thank you again. There is no simple solution for a complex problem. RSA implies a lot of backend: several symmetric ciphers (AES, Blowfish..., that are complex by their own. You don't want to use Caesar cypher), acceptable random generator, big integer arithmetic, prime numbers, several hash algorithms. And the library is leaving aside all PKI stuff: certificates, authorities etc. And forget about memory protection etc I think it is a minimal RSA lib. In fact, maybe it's too simple. As far as I've seen it only has MD5 and SHA1 hash algorithms, many environments require at least sha256. But if it is only for internal use (you are in charge of both ends of communication) and not for critical top secret, it could be enough. I don't think you will find anything much more simpler. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Rest in peace Martin Schreiber
El 27/12/18 a las 00:49, Graeme Geldenhuys escribió: Hi everybody, Today I became aware of very sad news. Martin Schreiber, author of the MSEide+MSEgui project, has unexpected succumbed of cardiac arrest on 29 November 2018. He was an avid FPC and Pascal Language supporter, and very knowledgeable in his field. He will definitely be missed by many. Our hearts and prayers go out to his family and friends. Rest in peace Martin Schreiber. Regards, Graeme Oh my! what a sad and unexpected news! My condolences to his friends and family. How old was he? -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Candidate for crowd-funding
El 19/12/18 a las 09:02, denisgolovan escribió: Hi all I decided to start a separate thread for asking about potential candidate for crowd-funding. My personal wish-list is: - support for array calculations / automatic loop parallelization via SSE, AVX, etc. Both static and dynamic arrays should supported. Once implemented vector operations on arrays (ala APL) might be done using operator overloads. - Custom/separate allocators for dynamic arrays (to avoid manually patching compiler). - Coroutines. Portable library or in-compiler support. - Interprocedural optimizations (something akin to LTO) - inline assembler function support - proper macro language perhaps Could someone comment if those goal are attractive to somebody else? I mean both donators and potential "implementors". BTW, is it possible to state the specific project when donating? Mine: - Debugger: Watch values of properties of classes/objects even when they have a getter and/or are string Those above, for me, would improve Lazarus 1%. More than any improvement in package management, IDE or changes in language. For me, they are must. These below would be a good improvement - Debugger: Setting values of properties of classes/objects even when they have a setter and/or are string (not as important as watching, but very important as well) - Debugger: Watch values of variables in nested procedures. - Debugger: better dealing with generics Amazing enough, there is no project in then foundation related to improve debugger. Am I the only one who thinks that poor debugger is a stopper? -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Can't determine which overloaded function to call
El 05/12/18 a las 08:46, Jonas Maebe escribió: On 05/12/18 07:51, LacaK wrote: helps, but why is it not needed in Win32? Why for Win32 "integer"-"integer" is considered as "integer" so compiler can determine which overloaded function to call and for Win64 compiler compiler can NOT determine which overloaded function to call? It is because as documented at https://www.freepascal.org/docs-html/ref/refsu4.html (remarks under table 3.2), FPC evaluates integer expressions using the native integer type of the platform. On Win32 this is 32 bit, while on Win64 this is 64 bit. On the other hand, "integer" is always 32 bit in Delphi mode. This means that on Win32, there is an exact match for overload selection in your test program, while on Win64 there is not and the int64 -> integer and int64 -> single type conversions have the same priority. do (LongInt -> Integer) and (Longint -> single) have the same priority? -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Can't determine which overloaded function to call
El 04/12/18 a las 13:21, LacaK escribió: Hi *, this code compiles for target Win32 but does not compile for Win64/x86-64. Why? Is there workaround? (Error: Can't determine which overloaded function to call) Thank you For me, in win32 works fine try this r1.Offset(a-Integer(1),b-Integer(1)); or r1.Offset(Integer(a-1),Integer(b-1)); -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Windows programming tutorials for FPC
ou the events each control has, when you click them, it creates am empty function and brings to front the editor to let you write the real code. It is an over simplification, but hope it has helped a little. But well, as I said, everybody has his own epiphany. Good luck -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Order of Precedence: FPC/Delphi vs Java
El 06/10/18 a las 20:48, Graeme Geldenhuys escribió: On 03/10/18 20:05, Santiago A. wrote: I don't know why you want to compare two floats, but you'd better use currency type. I fully understand that. We do financial calculation up to 6 decimal places, so can't use Currency data type. 6 decimals, no currency that's a problem ;-) Our real issue was the different results using the same calculation. I thought order of precedence would apply in all cases, but couldn't fully understand the outcomes we received. But after reading Florian and Bernd's replies I now understand. The other issue was that our application is 32-bit, where 64-bit would not have had this issue. With 64 bits, reaching a 6 decimals error is more difficult, but it is still an issue. In your example you have done a couple of operations and you have got an error of 1E-11. After a hundred of operations, you could reach the fatal 1E-6. Once I had a problem like that, or integers, or floats. The best is rounding a lot in intermediate results, rounding before comparing and specify clearly the order: i.e. if you add a list of items with a discount, you can get different results if you apply the discount to each item and sum, than if you sum the items and apply the discount to the total. will the difference be less then 1E-6? Depend on the numbers, and how many items you sum. So you must specify : "Discount will be applied to each item". 64bits is a lot of precision, but don't be overconfident, even in such case errors can skyrocket with divisions with small divisors and/or a lot of operations. Comparing to zero is always dangerous, you'd better round the number to 6 decimals before comparing. -- ---- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Order of Precedence: FPC/Delphi vs Java
El 03/10/18 a las 10:40, mailingli...@geldenhuys.co.uk escribió: I have this simple little test. My expected answer for all the calculations are 0 (zero), but both FPC and Delphi give different results. Java is the only one that seems consistent regarding the results. Can anybody explain this, especially the first 3 very small negative numbers that Delphi and FPC produces? I know not all floating point values can be stored exactly (or something like that), and when doing calculations, it might do a auto data type conversion. But is any of that taking place here? I don't know why you want to compare two floats, but you'd better use currency type. Float is for calculus, but comparing float1=float2 (or float1>float2) is rolling the dice. Obviously, the more precision, the less errors. But an accurate, intuitive result, is not guaranteed. People who play with maths may use something like function equal(const f1,f2:Extended; const Error:extended=1E-6):boolean; begin Result:=(abs(f1-f2)But for most applications, using a function like "equal" (and "less", "lessOrEq" etc) everywhere is a burden that makes not sense. I think that every programing language should include a fixed precision type. Freepascal has at least currency, that is four decimals, use it. What does java does? I don't know. Perhaps it just rounds the output, try System.out.println(ans==0.0). Perhaps it uses a high precision that *in this case* gets always 0. But the question is that floating point representation can't store accurately many numbers. To begin with, 0.1 in base 10, is periodic number in binary 0.0001...001..001... so it has to truncate it, and when you truncate, the result depends of the order of operations, no matter the language or precision. So, it is matter of probability to get 1. or 1.0001 or 0., if you expect 1, psychologically 1.0001 looks better result than 0.. Dephi or Freepascal are doing nothing wrong. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Hint converting to int64
El 11/09/18 a las 12:30, Mark Morgan Lloyd escribió: On 11/09/18 10:15, Santiago A. wrote: Hello:FPC: 3.0.4 (Realease from Lazarus 1.8.4 SVN: 57972)OS: Windows7 32bits / Linux 64Bits I have this code and I get a hint -- var Entity:Longword;FullParagraph:string; pIni:Integer; begin Entity:=Entity*10+ord(FullParagraph[pIni])-48; // <=== Hint end; --- Hint: Converting the operands to "Int64" before doing the add could prevent overflow errors.I can't see why it mentions int64, there are integer and longword variables, but no Int64 one. There is you know. https://www.freepascal.org/docs-html/current/ref/refsu4.html#x26-250003.1.1 -- var Entity:Longword; FullParagraph:string; pIni:Integer; begin Entity:=Entity*10+ord(FullParagraph[pIni])-48; // <=== Hint end; --- Do you mean that Entity is promoted to int64 in a 32bits system? -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Hint converting to int64
Hello: FPC: 3.0.4 (Realease from Lazarus 1.8.4 SVN: 57972) OS: Windows7 32bits / Linux 64Bits I have this code and I get a hint -- var Entity:Longword;FullParagraph:string; pIni:Integer; begin Entity:=Entity*10+ord(FullParagraph[pIni])-48; // <=== Hint end; --- Hint: Converting the operands to "Int64" before doing the add could prevent overflow errors. I can't see why it mentions int64, there are integer and longword variables, but no Int64 one. I have replaced it by Entity:=Entity*10+LongWord(ord(FullParagraph[pIni]))-48; That is, I have casted the result of "ord()" to longword. But I get the same hint. What should I do to remove the hint? -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Assigning open array
Hello: I'm not very sure how open arrays are copied program Project1; Type TMyRecord=record somedata:string; ArrayInt:array of integer; end; TRecordList=array of TMyRecord; procedure foo(out aList:TRecordList); var TmpList:TRecordList; begin SetLength(TmpList,1); tmpList[0].somedata:='s'; SetLength(tmpList[0].ArrayInt,1); tmpList[0].ArrayInt[0]:=5; SetLength(aList,0); aList:=copy(TmpList,0,1); end; var MyList:TRecordList; begin foo(MyArray); writeln(MyList[0].somedata); // prints s writeln(MyList[0].ArrayInt[0]); // prints 5 readln; end. I looks like working fine. MyArray.ArrayInt[0] is still 5. But I wonder whether it is really right or just luck. Open arrays are pointers, so, when tmpList gets out of scope then tmpList.arrayInt is freed. I want to be sure that that my example is not working just because it happens that the memory that used TmpList[0].arrayInt[0] hasn't been overwritten. Does the copy function at the end of foo just copies the reference and, after tmpList gets out scope, it points nowhere? or does it clone arrayInt? or does it have some kind of reference counter like with strings? -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Syntax changes suggestions
El 21/07/18 a las 22:43, Ben Grasset escribió: Shouldn't the attribute tags just be put wherever it's easiest for the compiler to deal with them? No, of course the shouldn't. They should be put put where it is easier for programmer, or more readable, or coherence, or common sense, or other reasons. How difficult is to implement for the compiler is a limit if our skills or state of art of compilers imposes, not a feature. Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Syntax changes suggestions
El 17/07/2018 a las 10:11, Marco van de Voort escribió: In our previous episode, Sven Barth via fpc-pascal said: interested in why it is not supported. At least Delphi Tokyo (10.2) does not support it. If I remember the discussion correctly it came to light that some users would need "try ? finally ? except ? end" while others would need "try ? except ? finally ? end" and even some "try ? finally ? except ? finally ? end" or the like. With differences in opinion like this the idea was dropped, cause this flexibility exists already, namely by using separate blocks. And since the feature is implementable as an IDE macro (generating a nested try except/finally) it doesn't make Ooccam's razor of usefulness to begin with. The Occam's razor is that if it is so usefull that a macro is used a lot, why not make it part of the languages avoiding depending on external tools? -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Syntax changes suggestions
El 16/07/2018 a las 21:27, Marco van de Voort escribió: In our previous episode, Sven Barth via fpc-pascal said: function) In such cases, you don't declare it "auto". Just as you don't free a pointer in the function you declare it if you pass the instance to another code that stores it beyond the life time of the function But you don't necessarily know that the function you call does that (think third party code). And people *will* use this and don't think about the consequences. So a system with automatic reference counting is safer and that is what is planned, if at all. Moreover the use case, dynamically instantiated classes with very local scope is rare. You must be kidding. You use local scope objects everywhere. The TStreams family is a clear example. source/rtl/objpas/classes/classes.inc // function CollectionsEqual(C1, C2: TCollection; Owner1, Owner2: TComponent): Boolean; procedure stream_collection(s : tstream;c : tcollection;o : tcomponent); var w : twriter; begin w:=twriter.create(s,4096); try w.root:=o; w.flookuproot:=o; w.writecollection(c); finally w.free; end; end; var s1,s2 : tmemorystream; begin result:=false; if (c1.classtype<>c2.classtype) or (c1.count<>c2.count) then exit; if c1.count = 0 then begin result:= true; exit; end; s1:=tmemorystream.create; try s2:=tmemorystream.create; try stream_collection(s1,c1,owner1); stream_collection(s2,c2,owner2); result:=(s1.size=s2.size) and (CompareChar(s1.memory^,s2.memory^,s1.size)=0); finally s2.free; end; finally s1.free; end; end; // // auto version // function CollectionsEqual(C1, C2: TCollection; Owner1, Owner2: TComponent): Boolean; procedure stream_collection(s : tstream;c : tcollection;o : tcomponent); var w : twriter;auto; begin w:=twriter.create(s,4096); w.flookuproot:=o; w.writecollection(c); end; var s1,s2 : tmemorystream; auto; begin result:=false; if (c1.classtype<>c2.classtype) or (c1.count<>c2.count) then exit; if c1.count = 0 then begin result:= true; exit; end; s1:=tmemorystream.create; s2:=tmemorystream.create; stream_collection(s1,c1,owner1); stream_collection(s2,c2,owner2); result:=(s1.size=s2.size) and (CompareChar(s1.memory^,s2.memory^,s1.size)=0); end; // With "Auto", you save a lot of "try finally free" that add nothing to algorithm You can argue against "auto" in the grounds of "Aesthetic symmetry ", "it's not explicitness pascal way", "it's not worth", "confusion mixing styles/paradigms" or other arguments I haven't thought. I asked expecting those arguments I hadn't thought about. There may be valid arguments against, but when I read "local scope for classes is rare", I know I am in the grounds of a irrational resistance. In such cases, a "For the sake of brevity, my vote is simply "no" to all your suggestions." is the best answer. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Syntax changes suggestions
El 16/07/2018 a las 13:59, Michael Van Canneyt escribió: On Mon, 16 Jul 2018, Santiago A. wrote: I have some suggestions of change to freepascal syntax, just to debate (All are backward compatible) - Declaring variables inside blocks, and loop variables - Autofree pointers - Try except finally blocks - Private declarations in implementation some of them can be found in https://www.codeproject.com/Articles/1252167/Delphi-Language-Progression-Suggestions Some can be considered regressions, not progression. autofree pointers will be available with management operators, I suppose. probably try except finally blocks is still doable. But declaring variables inside code blocks makes for really bad readability and - worse - possibly error prone code. What to do with scope rules ? Var C : integer; begin C:=1; // C is integer // New block, hence new scope for var c:string in List do begin ... // C is string end; It is a local variable to the block, the scope is the from the declaration to the end of the block. Nevertheless, I think that declarations should be at the beginning of the block, before any executable statement, so the scope is the block. Ada, has the structure - if a>b then Declare s:string=''; begin <...> end; end if; -- I just say that the nearer the variable to the place you use it, the better. Particularly in the case of FOR loops it makes a lot of sense. In fact, the variable shouldn't make sense before or after the loop. Why not declare it just in the loop? Ada does it. I don't think Ada is a language of dirty hacks. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Syntax changes suggestions
El 16/07/2018 a las 15:02, Sven Barth via fpc-pascal escribió: Santiago A. mailto:s...@ciberpiula.net>> schrieb am Mo., 16. Juli 2018, 13:41: I have some suggestions of change to freepascal syntax, just to debate (All are backward compatible) - Declaring variables inside blocks, and loop variables -> reduces readability -> no interest I think the opposite. The nearer the declaration to the code where you use it, the better. - Autofree pointers Might come, though not in that way (take your example: what if you pass the instance to some other code that stores it beyond the life time of the function) In such cases, you don't declare it "auto". Just as you don't free a pointer in the function you declare it if you pass the instance to another code that stores it beyond the life time of the function - Try except finally blocks This had been proposed some time ago and was declined after quite some discussion (either here or on fpc-devel). - Private declarations in implementation Again this reduces readability and thus no interest. Once again, I think the opposite. It's not very readable a class where you have to skim through 100 lines of private declaration that you don't care, because you can do nothing with them. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Syntax changes suggestions
I have some suggestions of change to freepascal syntax, just to debate (All are backward compatible) - Declaring variables inside blocks, and loop variables - Autofree pointers - Try except finally blocks - Private declarations in implementation some of them can be found in https://www.codeproject.com/Articles/1252167/Delphi-Language-Progression-Suggestions **declaring variables inside blocks, and loop variables** var Number1,number2:Integer; f:textFile; begin <...> while not eof(f) do begin Readln(f,number1,number2); if number1>number2 then begin var swapnum:Integer;// declaring in a block. Even initializing it, var swapnum:Integer:=Number1; swapnum:=number1; number1:=number2; number2:=swapnum; end; end; <...> end; --- for var i:integer:=1 to 100 do begin <...> end; --- **autofree pointers** procedure foo; var s:TStringList; auto;// you add "auto", like absolute begin s:=TStringList.create; <..> // s is freed automaticallyat the end of block, without try finally end; That combined with declaring inside blocks would make things less verbose avoiding a lot of try finally. **try except finally blocks** instead of -- try try <...> except <...> end; finally <...> end; -- just write -- try <...> except <...> finally <...> end; **Private declarations in implementation** In the implementation, being able to implement a private method without declaring it in the interface part. You just write: - implementation procedure TMyClass.MyPrivateMethod; begin <...> end; - And if it is not declared in the interface part, it is assumed as private. It is a private method, nobody is aware of it outside of the implementation, it can't be used in derived classes, it unnecessary in the interface, and needn't to be declared. The same could be applied for private vars. : -- implementation var TMyClass.privateVar: Integer; -- I suppose this is more difficult with variables than with methods, because of reserving memory etc, but it would be handy. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Loss of precision when using math.Max()
El 03/07/2018 a las 14:33, Wolf escribió: PS.: while composing this mail, Santiago wrote: Pascal needs to break backward compatibility to advance, that is, in fact, a new language. But if pascal is struggling to survive, let alone a new language if you are not mozilla, google... In which direction should Free Pascal move - lower type (range, overflow, memory) checking demands, with the implied additional sources for bugs, but also better speed and shorter code, a la C, or should Free Pascal rather take the lead and move towards safer, and more trustworthy, code, a la Rust? Well, I am more for safer. But the problem is not that Pascal is not safer enough (some parts could be improved, but it has a good mark) it is about new features that need convoluted workarounds or libraries and should be part of the language syntax. For instance: Some functional programing, closures, anonymous functions, concurrency, a clear use of character sets, different types of pointers. And there are things that I would change in the current syntax, but I suppose it is a matter of taste. This is a topic for fpc-other ;-) -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Loss of precision when using math.Max()
El 03/07/2018 a las 01:26, Jim Lee escribió: On 07/02/18 15:13, Wolf wrote: Not so long ago, Florian was proudly bragging about "Pascal does not allow you to shoot yourself in the foot <http://www.toodarkpark.org/computers/humor/shoot-self-in-foot.html>" What about this little program: program Project1; var a,b: byte; begin a:=1; b:=a*(-1); writeln(b); // result: 255 end. The result is obviously correct, given how the variables are declared. But there are no compiler warnings / errors that the assignment b:=a*(-1) is fishy, to put it mildly. And if you are serious about strong typing, it ought to be illegal, with a suitable complaint from the compiler. Who is shooting whom in the foot? Wolf Should the compiler balk at this as well? program Project1; var a,b,c: byte; begin a:=5; b:=6; c:=a-b; writeln(c); // result: 255 end. Without the implicit conversion of signed/unsigned values, the utility of the language is greatly diminished. Let's be honest, compared to C and many other languages (included C++, that is a suicide without extra-language analyzer tools), Pascal is very type secure. For instance, many languages allow assigning a float to an integer without any problem. Moreover without being clearly specified by language definition what the compiler should do, truncate or round. Pascal needs to break backward compatibility to advance, that is, in fact, a new language. But if pascal is struggling to survive, let alone a new language if you are not mozilla, google... -Jim ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Loss of precision when using math.Max()
El 01/07/2018 a las 10:27, C Western escribió: On 29/06/18 21:55, Sven Barth via fpc-pascal wrote: More confusingly, if a single variable is used, the expected Max(Double, Double) is called: function Max(a, b: Double): Double; overload; begin WriteLn('Double'); if a > b then Result := a else Result := b; end; function Max(a, b: Single): Single; overload; begin WriteLn('Single'); if a > b then Result := a else Result := b; end; var v1: Double; v2: Single; begin v1 := Pi; v2 := 0; WriteLn(v1); WriteLn(Max(v1,0)); WriteLn(Max(v1,0.0)); WriteLn(Max(v1,v2)); end. Prints: 3.1415926535897931E+000 Single 3.141592741E+00 Double 3.1415926535897931E+000 Double 3.1415926535897931E+000 If this is not a bug, it would be very helpful if the compiler could print a warning whenever a value is implicitly converted from double to single. Well, pascal is a hard typed language, but not that hard in numeric issues. I think it is a little inconsistent that it implicitly converts '0.0' to double but '0 to single. Nevertheless, I think it is a bug. It doesn't choose the right overloaded function But the main is this: you have several overload options for max 1 extended, extended 2 double, double 3 single, single 4 int64, int64 5 integer, integer When it finds (double, single), why does it choose (single, single) instead of (double, double)? The natural behavior should be to widen to the greater parameter, like it does in expressions. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] round(2.5)=2
El 12/06/2018 a las 23:12, Klaus Hartnegg escribió: Am 11.06.2018 um 10:01 schrieb Michael Schnell: - the way of rounding is defined by the CPU hardware, even old Turbo Pascal executables do banker's rouding on modern hardware. No, it does not depend on the hardware, but on the setting of $N. Turbo Pascal with $N+ rounds like FreePascal. But the default is $N-. In this mode Turbo Pascal always rounds up. var a : real; begin a := 35; writeln (round(a*1.1)); end. FreePascal: 38 Turbo Pascal: 39 And when the compiler precalculates a constant expression, it always rounds up as well, regardless of $N. Nobody expects that increasing a number by 10% will depend on whether the resulting number will be close to an even integer. That feels completely erratic. I don't feel it is completely erratic. If instead of 35 it were 135 would you mind if the result were 1100038 or 1100039? When you round small numbers, relative rounding errors skyrocket, that is a fact of life. Any software must be aware of this and live with it. This behaviour does have advantages in the special case of adding up many rounded numbers, but it ruins the graphics output of my software. It should at least be configurable. And in {$mode tp} it should behave like Turbo Pascal, because that's what this mode is made for. - SetRoundMode is not only dangerous, but does not help, anyway, as there is no mode defining the "intuitive " "non-banker rouding" method. That's why I'm looking for a better solution. The the only *reliable* solution appears to be compiling a modified version of FreePascal. I think that is even more dangerous. Who knows how many internal freepascal will fail when you change rounding. It would be better to review software to check why it needs always round floor for 0.5 Klaus ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Sqlite error sqlite3_extended_errcode SIGSDEV (better format)
El 14/03/2018 a las 19:26, Luca Olivetti escribió: > El 14/03/18 a les 18:50, Santiago A. ha escrit: > >> I downloaded the last version of sqlite3.dll and now it works. Was my >> dll corrupted or was too old and hadn't such entry?. Nevertheless, I >> think this check of nil should be done, or check the version and rise >> "Not valied for this version". A SIGSDEV may drive you nuts. > > According to https://sqlite.org/changes.html, sqlite3_extended_errcode > was added in version 3.6.5 in 2008. > > Bye Yeah, my version is a little outdated ;-). I searched sqlite3.dll in this computer and I found more than fifteen instances, it looks like each application installs its own instance of the dll. So there are a lot of versions. I'm replacing a Delphi5 small utility, so probably it was one of the oldest. Nevertheless, it wouldn't be a bad idea to check the minimal version after loading the lib. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Sqlite error sqlite3_extended_errcode SIGSDEV (better format)
Hello: I had problems with Sqlite3 it raised SIGSDEV exception, but I think it worked with FPC 2.6.4 from Lazarus 1.6. (not sure because It is a new PC, but with 1.8.0) . Finally I have found where the problem is. The problem is in sqlite3conn.pp: procedure TSQLite3Connection.checkerror(const aerror: integer); Var ErrMsg : String; ErrCode : integer; begin if (aerror<>sqlite_ok) then begin ErrMsg := strpas(sqlite3_errmsg(fhandle)); ErrCode :=sqlite3_extended_errcode(fhandle); // <== here is the problem raise ESQLDatabaseError.CreateFmt(ErrMsg, [], Self, ErrCode, ''); end; end; The problem is that sqlite3_extended_errcode is not a regular function, is a pointer to a function, and it is nil. So I added: if assigned(sqlite3_extended_errcode) then ErrCode :=sqlite3_extended_errcode(fhandle); else ErrCode := 0; Why is sqlite3_extended_errcode nil? It is assigned in sqlite.inc as a pointer to a function of sqlite3.dll. pointer(sqlite3_extended_errcode) := GetProcedureAddress(LibHandle,'sqlite3_extended_errcode'); I downloaded the last version of sqlite3.dll and now it works. Was my dll corrupted or was too old and hadn't such entry?. Nevertheless, I think this check of nil should be done, or check the version and rise "Not valied for this version". A SIGSDEV may drive you nuts. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Sqlite error sqlite3_extended_errcode SIGSDEV
Hello: I had problems with Sqlite3 it raised SIGSDEV exception, but I think it worked with FPC 2.6.4 from Lazarus 1.6. (not sure because It is a new PC, but with 1.8.0) . Finally I have found where the problem is. The problem is in sqlite3conn.pp: procedure TSQLite3Connection.checkerror(const aerror: integer);Var ErrMsg : String; ErrCode : integer;begin if (aerror<>sqlite_ok) then begin ErrMsg := strpas(sqlite3_errmsg(fhandle)); ErrCode := sqlite3_extended_errcode(fhandle); // <== here is the problem raise ESQLDatabaseError.CreateFmt(ErrMsg, [], Self, ErrCode, ''); end;end; The problem is that sqlite3_extended_errcode is not a regular function, is a pointer to a function, and it is nil. So I added: if assigned(sqlite3_extended_errcode) then ErrCode := sqlite3_extended_errcode(fhandle); else ErrCode := 0; Why is sqlite3_extended_errcode nil? It is assigned in sqlite.inc as a pointer to a function of sqlite3.dll. pointer(sqlite3_extended_errcode) := GetProcedureAddress(LibHandle,'sqlite3_extended_errcode'); I downloaded the last version of sqlite3.dll and now it works. Was my dll corrupted or was too old and hadn't such entry?. Nevertheless, I think this check of nil should be done, or check the version and rise "Not valied for this version". A SIGSDEV may drive you nuts. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Range checks
El 27/01/18 a las 15:10, C Western escribió: The following innocuous looking code generates a range check error: {$R+} function Count: qword; begin Result := 0; end; var i: Integer; begin for i := 0 to Count-1 do WriteLn(i); end. I can (more or less) see why, but it means that I can't (for example) compile the Cocoa widget set in 64 bit with bounds checking on, as then qword seems to be used as a count for, for example, NSarray. Am I missing something? The problem is that count is qword, so the operation is qword until it needs to convert it for i:=0 to integer(qword( qword(count) - qword(1)) do try this: for i := 0 to *integer*(Count)-1 do -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] any existing units/libraries for sorting?
El 03/01/2018 a las 16:09, Dennis escribió: > I have a list of records (each with a few fields). What do you mean with list? A TList? You can use sort method -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Modern Compiler Construction using Pascal
El 01/01/2018 a las 19:17, Yves Cloutier escribió: > Hi there, > > I'd be interested to know if any modern compilers have been written in > Pascal (other than the Pascal Compiler). > > It's unfortunate that that most Pascal books out there are rather > dated. I did recently purchase The first version of nim language https://nim-lang.org/ was written in Pascal. Here are the sources https://github.com/nim-lang/Nim/tree/ea1f1ec6d4d6c776eb0f81c2bebdd4cb4c817ebe/nim Many times, when compiler is mature, the compiler is re-written in the target language itself. Freepascal compiler is written in Freepascal. First version of compiler must be written in other language, (of course, the are not compilers for the language ), usually a language that generates binary, compiling is very demanding to rely on virtual machines Probably that is why there are not Java compilers written in Java, or Python or Perl compilers written in Python or Perl . As usual, the most popular language will be most used language: C, C++ -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] FORTRAN from FreePascal
El 19/11/2017 a las 11:06, Adriaan van Os escribió: > Mark Morgan Lloyd wrote: > >> That obviously applies to all languages, I've never come across >> something which can represent 1/3 or pi exactly. > > If you do read what is written in the link - that is not the issue. > The issue is how to interpret floating-point constants and how to > convert single-precision floating-point to decimal. In BCD, that > conversion is exact. No. It is not. n := 1 - (1/3) - (1/3) - (1/3); n:=1.00 - 0.33 - 0.33 - 0.33; n is never zero, no matter what representation you pick, unless you have infinite digits. The problem is that periodic numbers can't be stored without infinite digits. And the second problem is that depending upon the base, binary, decimal, hex, have different periodic numbers and, unfortunately, 1/10, in base 10, is periodic number in binary. So you are right 0.10 can't be represented with an exact value in floating-point, but it can be represented with exact value in BCD (nevertheless, you can represent 1/10 with an exact constant but not 1/3) . But internal operations won't be executed in BCD but using the floating-point processor representation, so, the aftermath is the same. Once I played with fraction representation, just for fun TFraction=record Negative:boolean; IntPart:Integer; Numerator:Integer; Denominator:Integer; end; Except for irrational numbers pi, e, etc, it had full precision. Obviously it was too slow. And, by the way, BCD is also too slow for numeric operations. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Windows API SendMessage()
El 10/08/17 a las 13:11, James Richters escribió: You need to use PostMessage if you want to your program to work correctly. SendMessage waits reply and you don't have a message pump in your console application, thus a hang happens. Thank you... PostMessage() works to turn off the display, but for some strange reason it can't turn it back on. I set a 20 second delay, and precisely at 20 seconds my monitor light turns green, but then the monitor goes back to sleep before the screen can be displayed. I'm guessing the signal is being sent to turn on the monitor, but not to get windows out of power save mode... I also see using -1 to turn the display back on is an un-documented feature.I can get the display back on with a keystroke or moving the mouse, but I'm wanting the program to turn the display back on without user input. Can anyone think of any other way I could make my console I have found this: https://stackoverflow.com/questions/25011141/turn-off-on-monitor-cant-turn-on It's in c++, but it looks that since w.8, you must simulate a mouse move. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Static local variables available?
El 20/07/2017 a las 15:50, Sven Barth via fpc-pascal escribió: > > Am 20.07.2017 13:01 schrieb "Bo Berglund" <bo.bergl...@gmail.com > <mailto:bo.bergl...@gmail.com>>: > > > > On Thu, 20 Jul 2017 11:11:50 +0200, Maciej Izak > > <hnb.c...@gmail.com <mailto:hnb.c...@gmail.com>> wrote: > > > > >2017-07-20 11:03 GMT+02:00 Bo Berglund <bo.bergl...@gmail.com > <mailto:bo.bergl...@gmail.com>>: > > > > > >> So since I don't really want to use a global, is it possible to > > >> declare a local variable static in the sense that it retains its > > >> values across calls to the procedure? > > >> If so how is it done? > > >> > > > > > >procedure foo; > > >{$PUSH} > > >const{$J+} > > > s : string =''; > > >{$POP} > > > > Thanks, > > but it looks a bit involved, probably better to use an object field > > variable instead only accessible from the internal methods. > > If you don't want to use $push/$pop then you can also simply enable > $J+ for the whole unit. But this will also mean that global constants > are writable. > Well, I'm an old dog so I prefer old fashion ways. A variable that retains its value is, from memory point of view, a global variable. I mean, the memory is never freed, it's not freed when it goes out of scope. So, the problem is what to do to limit the visibility to the procedure. What about the old interface/implementation ways? You can't limit the visibility to the procedure, but you can limit the visibility to the implementation, so it is globally invisible. unit hiddenVar; interface procedure foo; procedure resetFoo; implementation var HiddenValue:integer; procedure foo; begin writeln(HiddenValue); inc(HiddenValue); end; procedure resetFoo; begin HiddenValue:=0; end; initialization resetFoo; end. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Convert to int64 note
El 14/07/2017 a las 17:19, ja...@productionautomation.net escribió: >> If you declare Last_GS as int64, you should not get the warning. > I declared both Last_GS and G_End as int64, leaving Max_Program_to_Display as > a word and still get the warning. If I also make Max_Program_to_Display > int64, then I do not get the warning. I believe it's due to the -1. If > Max_Program_To_Display was a 0 then subtracting 1 from it would be out of > range from a word for that portion of the formula, even though the end result > would fit in Last_GS Using your way, (Max_Program_To_Display-1) is calculated first. Since the variable is type word, it would make word calculation, with word range. In such case, if Max_Program_To_Display is zero, you would get an underflow (and with no bounds checks, you could get $ that would be even worse). >> Last_GS:=G_End-(longint(Max_Program_To_Display)-1); > This aso fixes the warning if I leave all my variables alone. If I > understand this correctly in this case longint() is a function that returns a > longint variable to be used in the calculation, so when it does the -1 it's > ok it that part of the formula ends up being negative. > > So now my question is, which is the best method to use? My thinking with > declaring Max_Program_To_Display as a word was that this value has no meaning > if it is negative, and actually a word is way too generous for this value, a > byte would be overkill. If negative has no sense, I would declare it word, or byte and cast it to a signed integer if you need for internal calculations as have been said. Declaring it word, you have made the compiler to give you heads-up about a potential problem, then you can decide to check before if Max_Program_To_Display is zero or double check there is nothing wrong there. Other way it would have passed unnoticed and could bite you latter in unexpected ways and points of execution, making you hunt for a long time a weir bug. I wouldn't worry too much about declaring it word or byte. I think that because of performance, the compiler may align in a word (compiler gurus will tell better). In fact, I would forget about internal format and declare a new type in the range of valid values i.e type TMaxprogram=0..53; and let the compiler decide what internal format to use. In the conversion I would use "integer" instead of "longint" Last_GS:=G_End-(integer(Max_Program_To_Display)-1); "Integer" is the optimal integer format for that architecture, probably "longint", but I would use "integer" anyway. My two cents. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Convert to int64 note
El 14/07/2017 a las 1:13, ja...@productionautomation.net escribió: > I've been trying to get my programs to compile without any warnings or notes, > but I keep getting this one: > > promill.pas(2137,42) Hint: Converting the operands to "Int64" before doing > the subtract could prevent overflow errors. > > I get it a lot, but this is the line the above example is from: > > Last_GS:=G_End-(Max_Program_To_Display-1); > > Can someone please explain that this hint means and how I would convert the > operands to "Int64" as recommended? > > James > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal What's the type of each variable? -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Food for thought - language string improvement
El 10/07/2017 a las 11:17, denisgolovan escribió: > Just my 50 cents. > > Even though I avoid using debugger at all cost, > I am willing to donate some money should someone start a crowd-funding effort > to get "modern" debugging support in Lazarus. > That would definitely improve Lazarus/FPC public image. > It is not a matter of public image, it's a matter of usability, a "must have", a stopper. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Food for thought - language string improvement
El 10/07/2017 a las 1:32, Graeme Geldenhuys escribió: > Hi, > > I've give a short reply here, in case others deem this off-topic. I > always seem to end up in hot water about such stuff here. I can send > you more details in private if need be. > > On 2017-07-09 22:16, Michael Van Canneyt wrote: >> Would it be possible to give examples ? >> Maybe there are things that can be done in Lazarus, and Pascal ? > > Some IDE examples I have already raised in recent weeks in the Lazarus > forum. The Java IDE's are *way* more clever about what code you wrote > and makes very intelligent suggestions when it discovers errors, or > possible improvements (eg: because you are using a newer Java version > that might have an improved solution). In Eclipse, Ctrl+1 will list > the options, give you a tooltip hint of how the changed code will look > (before any changes are made). Make your pick and press enter. Those > could be fixing errors, improved language features, pull in missing > import lines, implement getters and setters, define missing classes, > field variables or local variables etc. The list of what is on offer > is massive. > > Purely on the language side of things I love the fact that there > is no *.h or an "interface section" in my code - why must C/C++ and > Object Pascal duplicate that information. If I want to see a purely > "interface" view of my code, the IDE doesn't that as standard in the > unit Outline window. > > As I said, just a short list here, but I can list many more if you > want - both IDE features and language features. > > Regards, > Graeme > My main complain to Freepascal is debugger. Being unable to debug any field of an object is unacceptable in a modern professional environment (hint, properties with getter, let alone with strings). It's ridiculous to use writeln() or creating dummy variables to debug as if I were in 1980. You can add to the IDE as many bells and whistles as you want, but without a serious debugger, no way. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Bug in documentation for Random?
El 05/04/2017 a las 18:09, Bart escribió: > http://www.freepascal.org/docs-html/current/rtl/system/random.html > > "Random returns a random number larger or equal to 0 and strictly less than L" > > However random(a negative number) returns a number <= 0 and > L > > > program r; > begin > randomize; > writeln('Random(-10) = ',Random(-10)); > end. > > C:\Users\Bart\LazarusProjecten>test > random(-10) = -1 > C:\Users\Bart\LazarusProjecten>test > random(-10) = -4 > > Maybe my understanding of English ("strictly less than") is not > correct, so I ask here before posting as a bugreport. I've never used negative values, so this is just a guess: random(+10) will output numbres 0..9 random(-10) will output numbres -9..0 so, it is equivalent to -random(10) -- Saludos Santi s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] FreePascal Windows - Force files to write to disk
El 21/03/2017 a las 15:39, James Richters escribió: > I should note that these systems are all using Samsung SSDs in them, perhaps > there is some SSD weirdness going on? Yes, I think so. SSD is special. The SSD technology like any flash memories have a limited number of rewrites, so there are strategies to rewrite as less as possible. In the case of SSD they are even more aggressive, because they are expensive .Some of these strategies are implemented in the OS in driver level, but some in firmware of the device. So, it is possible that OS can't completely force the real write. > I also notice it's not just this > one file that is affected, but EVERY SINGLE FILE I create with freepascal, Only with freepascal? Try it for a file generated from command line echo "test" > filetest.txt And do the same checks... edit notepad++... turnoff power etc > configured a certain way. I really need these tiny files to survive power > failures. Power failures are always a problem for persistent storage. Caching is a trade-off between speed and security. In the case of SSD there is a third point: Minimize the real writes on disk. So, if you want security against power failures, SSD is not the best idea. By the way. What about a SAI? ;-) -- Saludos Santiago A. s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] FreePascal Windows - Force files to write to disk
El 22/02/2017 a las 13:17, James Richters escribió: > The error I get is when trying to open the file to read it. It’s > something like read past end of file, because the corrupted file is > just one long line, once I read that, the second read is past the end > of file. I can do checking to get the file length and avoid the > error, but that doesn’t solve the real issue, which is that the data > that is supposed to be in the file is just gone. > Just two lines of research ;-) A) While you are reading the file you call the procedure that writes it. B) The is a bug, not in writing the part, but in the reading code: Somewhere when you read the file, you don't close it, so the file remains open. Usually it's not a big issue, you can open the file several times, and when you close the program everything is closed. But some times, when a parameter is changed you rewrite it while it is still open and everything gets messed. So this two events must happen, the program has executed the part of code that lets the file open and next a parameter is changed. > > > The thing is, even if windows forced a restart while my program was > running this file should have been closed at the time, because if > someone was standing there editing the variables, they would see the > restart notification and close the program first, or be able to tell > me they had a power failure. > > > > As a temporary measure, I’m just writing out the file twice so at > least I have a backup, but I don’t see why the backup would not be > corrupted by this same issue, so that’s probably pretty useless. > Yes, I think that's the way to go. 1) Before writing, read it and if it's ok make a backup of the file 2) Write the file. 3) Read again what you have written to check whether it's ok. 4) Make a second backup. That way, when you load parameters you have two backups to recover. And maybe a clue of what's going wrong. Beside, I would add a timestamp inside the file. In addition, you could use flush and {$I-} -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] FreePascal Windows - Force files to write to disk
El 21/02/2017 a las 22:12, James Richters escribió: > > > > Thanks for any advice on this > My first action would be to guarantee that the file is closed with a try...finally. AssignFile(BitFile,'BitSave.pax'); ReWrite(BitFile); try finally CloseFile(BitFile); end; Second: Do you have the file opened with an editor, or things like that, while running the program?. Third: Check that all variables have valid values and that values are converted to string properly to be printable. Fourth: Do you use somewhere {$I+} {$I-}? I also had some problems with that with old programs. Fourth: What's the type BitFile? BitFile: TextFile; BitFile: File; Maybe using writeln with non-textfile files may cause problems. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpc and voip ?
El 17/01/2017 a las 16:48, José Mejuto escribió: > > Maybe you may think in Opus http://opus-codec.org/ as it is open, > royalty free (mp3 is not free, you must pay royalties for the encoder > side) and source code is C89 so it must be compilable (libopus) in > almost any platform without a titanic effort. mp3 is not free? According with https://en.wikipedia.org/wiki/MP3#Licensing.2C_ownership_and_legislation It's royalty free in European Union. And, in USA, still valid patents will expire along 2017. After 31 December 2017 will be completely royalty free in USA also. Don't know rest of the world. Can it be worse than in USA? -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How to translate C macro
El 02/01/2017 a las 21:57, Darius Blaszyk escribió: > Hi all, > > Could someone suggest how to translate the following code to pascal? > > #define prev(X) ( *( (void **) ( ((void *) (X)) - 32 ) ) ) > . > prev(ptr) = prev(last); > > I tried converting the macro to an inline function but I get the error > message: Error: Argument cannot be assigned to. > > The following does work but is a bit verbose. So therefore I would > prefer a clean solution if possible. I never have used macro's in FPC, > are they capable of doing the same as mentioned above? > > ( ppointer ( (pointer (ptr)) - 32 ) )^ := ( ppointer ( (pointer > (last)) - 32 ) )^; If I have understood right, it could be something like this, dec(ptr,32); dec(Last,32); ptr^:=Last^; but maybe I have missed some indirection. You could show a little of code to see what do you intend to do. Change the 32th backward element of an array of pointers? -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] FPC clean room project
El 02/01/2017 a las 6:23, Mr Bee escribió: > Hi all, > > There's someone accusing that Free Pascal (and some parts of Lazarus) > is just a reverse engineering of Delphi. Even he said some codes of > FPC/Laz are taken from Delphi (and Kylix). This is a serious allegation. > > I know that isn't true. Or is it? ;) > > Can anybody elaborate on this? I'd like to debunk the allegation but I > don't know where to start and the evidence for it. Well, I think it's evident that Freepascal and lazarus tries to be delphi compatible, and that means that must look close to delphi to imitate it's behavior and syntax. Is that reverse engineering? Well, I'm not a lawyer, I don't know where "finding a similar solution for the same problem" ends and "Reverse engineering" starts. Nowadays it looks like painting a line is patented. Nevertheless, as someone has pointed, Embarcadero hasn't make any legal movement. Maybe because it thinks there is no legal base; or maybe because it doesn't care that much and thinks it's not worth the bad publicity. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Generic way to pre-maturely exit TCustomApplication without memory leaks
El 13/10/2016 a las 15:07, Graeme Geldenhuys escribió: > On 2016-10-13 13:48, Sven Barth wrote: >> That won't help with Halt() however as that will "jump" directly to the >> unit finalization, ignoring any and all exception handlers along the way. > > Wow, that's a bit harsh. Overriding the whole meaning of the > try..finally language feature. Then I would recommend NOT using Halt() > for anything - its nasty. I only use it in the interpreting command line parameters phase. If there is an error, I display help and halt. And probably even in this cases I shouldn't, it's a dirty hack. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Generic way to pre-maturely exit TCustomApplication without memory leaks
El 13/10/2016 a las 10:09, Graeme Geldenhuys escribió: > I would also rewrite that with a try..finally as in: > ph := TH.Create(nil) > try > ph.Initialize; > ph.ProcessOptions; > ph.Run; > finally > ph.Free; > end; May be I'm wrong, but I think that Halt(n) is a nuclear bomb, it closes the application almost on the current instruction, "finally" and "except" blocks are not executed. Nevertheless, Finalization blocks are executed. Anyway, I think that when the application is closed all the allocated memory is freed, memory leaks survive as long as the application is running. So wondering about what's in memory after a halt makes no sense, everything is freed. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] LowerCase vs. UnicodeLowerCase
El 11/10/2016 a las 14:15, Marcos Douglas escribió: > > But what I do, for years, is import my units using an order by That's what everybody does, otherwise you run into a troubles. The problem is when you change the order unnoticed The problem is when you use non standard packages and you don't know what's inside, and there is a function or type that hides a well known function. Fortunately it doesn't happen many times, But when it happens, it can keep you hunting phantoms for a long time. And that's what I think should be solved. (In delphi) Once I came across a unit with a procedure move(Source:TDataxxx;var Dest:TDataxxx), and I was using the standard move(var source,dest;count:integer), the compiler said mismatch type arguments. I wasted 15 minutes checking help etc. scratching my head with the same error. I've read several times in blogs questions about errors related to THandle because it's not unusual that a unit declares a type THandle. In fact, it's logical that different units uses same names for similar concepts. Being aware of the order is a workaround that works, but it doesn't mean that relying on the order is the best idea. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] LowerCase vs. UnicodeLowerCase
El 11/10/2016 a las 10:03, Marco van de Voort escribió: > In our previous episode, Santiago A. said: >> I think that "automatic overriding" is a wrong design from the first >> turbo pascal and should be fixed. The need of overriding system >> functions like memory managers is a corner case to treat, not a reason >> to not solve the unexpected hide of declarations. > Well, the problem mainly exists because you don't have any control over > importing symbols from an unit other than "all". > > A different route would to fix that (like Modula2 or "qualified" importing > like in again M2 but also GPC). My two cents: Whenever there is a conflict, an ambiguity, you must full qualify the identifier otherwise the compiler will complain. For the special cases, when you need to hide the declaration, you could use the directive "override" for global declarations (types, functions, procedures, const, vars) , so the compiler knows that it must ignore previous declaration if the identifier is not full qualified. Just like it does now. For compatibility issues, you could add a compiler check, i.e. {$CHECK_AMBIGUITY ON/OFF} -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] LowerCase vs. UnicodeLowerCase
El 05/10/2016 a las 9:23, Graeme Geldenhuys escribió: > On 2016-10-05 08:11, LacaK wrote: >> Now I understand what happens, but isn't it bit confusing ? > Yup, I would agree, and if possible, one should be removed. Yes and no. Yes, probably in this case one of them should be removed, but the reason of why it's confusing is still there. If you declare two functions with identical name in the same unit, you get a "redeclared" error, unless you add the overload directive. If you declare two functions with identical name in the different units, the second "used" unit overrides, hides, the first declaration without any warning. This behavior sometimes leads unexpected compiler errors that stops you saying "what the...#@&?" for some time. Sometimes minutes, sometimes until people get an answer from a forum . Handle types are a common case. And compiler errors are the nice case, if there are not compiler errors because the both declarations are compatibles, you get unexpected behaviors that drives you nuts, like this case I think that "automatic overriding" is a wrong design from the first turbo pascal and should be fixed. The need of overriding system functions like memory managers is a corner case to treat, not a reason to not solve the unexpected hide of declarations. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Checking the validity of Format and friends at compile-time
El 05/10/2016 a las 19:47, Michalis Kamburelis escribió: > 2016-10-05 9:00 GMT+02:00 Maciej Izak <hnb.c...@gmail.com>: >> 2016-10-05 4:32 GMT+02:00 Michalis Kamburelis <michalis.ka...@gmail.com>: >>> For example, the call >>> >>> Format('%s', [123]) >> >> I have a small hint (instead of answer). We have in mORMot / NewPascal in >> SynCommons module nice function which works perfect in most of cases: >> >> FormatUTF8('%', [123], []); // same string '%' works for both: integer and >> string values >> FormatUTF8('%', ['123'], []); >> > That's a cool improvement. No need to write the type, so one less > thing that can go wrong:) I seldom use non-standard formats anyway > (like %g instead of %f for floats). I don't agree. You are asking for a compile time check, but now you accept skipping run time type check doing a automatic type conversion. Things can go as wrong as with classic format but, without runtime error or exception, hunting bugs is more difficult. I support your first idea: Compile time check. I haven't understand very well whether Sven Barth's reluctance is a matter of taste or whether there are serious technical reasons. If there are not severe design drawbacks, I would go for it. I love compile time checks. The more, the better. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Socket pair
I've seen that "accept" functions with socket pairs are deprecated. And fpsocketpair returns always -1. How do you get the in and out streams when a server accepts a new client connection? I have seen some server examples, like isocksrv.pp, but only read from client and send nothing back to client. can anyone point and example with pair of sockets or bidirectional connection communication? -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Asci85
El 16/09/2016 a las 15:01, José Mejuto escribió: > > Maybe there is something wrong in ASCII85 encoder, but this code is > wrong, it should be something like: > > try > StrmEnc85.CopyFrom(StrmIn,0); > StrmEnc85.Free; > Result:=StrmOut.DataString; > finally > > Because stream must be flushed before extracting result and the flush > is performed in the destroy. . > That's right. Solved! Thanks! -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Ascii85
El 16/09/2016 a las 10:16, Santiago A. escribió: > Hello: > > I'm trying to use ascii85 packages to decode/encode strings. But I get > this weird results: > > -- > Original Plain: 123456 > Correct Encoded: <~0etOA2)Y~> > > Encode 123456 = <~0etOA > Decode <~0etOA = 1234 > > Decode <~0etOA2)Y~> = 123456 > -- > > It looks like decoder stops reading somewhere. Sorry, I meant "Encoder" stops reading somewhere -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Asci85
Hello: I'm trying to use ascii85 packages to decode/encode strings. But I get this weird results: -- Original Plain: 123456 Correct Encoded: <~0etOA2)Y~> Encode 123456 = <~0etOA Decode <~0etOA = 1234 Decode <~0etOA2)Y~> = 123456 -- It looks like decoder stops reading somewhere. I'm using almost a verbatim copy of the packages example, but replacing TFileStreams by TStringStreams: Here is the code, - program Project1; uses sysutils,ascii85,classes; function Encode85(Plain: String): String; var StrmIn,StrmOut:TStringStream; StrmEnc85:TASCII85EncoderStream; begin StrmIn:=TStringStream.Create(Plain); try StrmOut:=TStringStream.Create(''); try StrmEnc85:=TAscii85EncoderStream.Create(StrmOut,72,True); try StrmEnc85.CopyFrom(StrmIn,0); Result:=StrmOut.DataString; finally StrmEnc85.Free; end; finally StrmOut.Free; end; finally StrmIn.Free; end; end; function Decode85(Encoded: string): string; var StrmIn,StrmOut:TStringStream; StrmDec85:TASCII85DecoderStream; buf:array [1..16] of byte; Count: LongInt; begin StrmIn:=TStringStream.Create(Encoded); StrmDec85:=TASCII85DecoderStream.Create(StrmIn); try StrmOut:=TStringStream.Create(''); try Repeat Count:=StrmDec85.Read(Buf,SizeOf(Buf)); If Count>0 then StrmOut.WriteBuffer(Buf,Count); Until (Count<SizeOf(Buf)); Result:=StrmOut.DataString; Finally StrmOut.Free; end; finally StrmDec85.Free; end; end; Const OriginalPlain='123456'; CorrectEncoded='<~0etOA2)Y~>'; var Encoded,Decoded:string; begin Writeln('Original Plain: ',OriginalPlain); Writeln('Correct Encoded: ',CorrectEncoded); writeln; Encoded:=Encode85(OriginalPlain); Writeln(Format('Encode %s = %s',[OriginalPlain,Encoded])); Decoded:=Decode85(Encoded); Writeln(Format('Decode %s = %s',[Encoded,Decoded])); Writeln; Encoded:='<~0etOA2)Y~>'; Decoded:=Decode85(Encoded); Writeln(Format('Decode %s = %s',[Encoded,Decoded])); Writeln; readln; end. - -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Windows console
El 05/09/2016 a las 16:26, José Mejuto escribió: > El 05/09/2016 a las 15:01, Santiago A. escribió: >> Hello: >> >> I have a little watchdog utility for windows that runs each five >> minutes, like a unix cron ("Tareas programadas" in Spanish, scheduled >> tasks?). It opened a console window for a second and that was very >> annoying. So I used the switch -GW and there is no more flashing console >> bothering. But then I can't show any help or any output for debug from >> the prompt. >> >> I can live with it, in fact, it usually uses a log file, but some times, >> when I'm installing, testing paramters etc, it's more handy to run the >> program from the prompt and see the result immediately or display the >> help instead of having to open logs. >> >> Is there any way to open a console on the fly and send the output to the >> console? > > Hello, > > I would create a .bat file in temp folder and run a new shell execute of > that .bat. This .bat simply display some echo lines and finally autokill > itself. > > If your system for security reasons do not allow run bats then you can > create a .txt file and launch a shell execute cmd with "type > \path\file.txt" (keeping session open or it will clear the screen). You > main program can wait 2-5 seconds and delete the .txt file to not > pollute the temp folder. > > Of course this is a "home made" solution :) Another is have a different > exe just for the help, have a .bat or .txt in your app folder just to > show the help if it is always the same, ... I have found a solution here: http://stackoverflow.com/questions/20134421/can-a-windows-gui-program-written-in-lazarus-create-a-console-and-write-to-it-at At least it works for windows uses Windows; begin AllocConsole; // in Windows unit IsConsole := True; // in System unit SysInitStdIO; // in System unit // Now you can do Writeln, DebugLn, ... end. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Windows console
Hello: I have a little watchdog utility for windows that runs each five minutes, like a unix cron ("Tareas programadas" in Spanish, scheduled tasks?). It opened a console window for a second and that was very annoying. So I used the switch -GW and there is no more flashing console bothering. But then I can't show any help or any output for debug from the prompt. I can live with it, in fact, it usually uses a log file, but some times, when I'm installing, testing paramters etc, it's more handy to run the program from the prompt and see the result immediately or display the help instead of having to open logs. Is there any way to open a console on the fly and send the output to the console? FPC 3.0.0 for Windows 7 and Windows XP -- Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Weird string behavior
El 27/07/2016 a las 16:10, Michael Schnell escribió: > On 07/26/2016 04:19 PM, Michael Van Canneyt wrote: >> >> This is not correct. In pascal the right-hand side of an assignment >> has a well-defined type. The compiler checks whether the type on the >> right is assignment-compatible to the left side. > > Hmm. > > if you do > > x := y + z; > > with x a real and y and z integers, the type of x will not change to > be an integer, but the value will be converted. > > > Now I understand that with strings the encoding is a kind of > "sub-type" and hence (usually) static and not convertible to allow for > the compiler do decide if a conversion is necessary. > > This has been discussed a long time ago and the argument was that > _fully_ dynamically typed strings are to costly regarding CPU demand. > > I did not get to know that those design decision has been changed for > the normal usage case (while there seems to be ways to sue certain > kinds of strings in a fully dynamical way) . > > Changing the encoding of the left side operand of ":=" would only be > logical if the encoding is never an attribute to the string's type but > always a dynamical attribute to the string's content. And what are the rules for changing left side operand? It looks that they are a little complicated. Freepascal needed codepages, so string with codepage was needed. Should it need dynamic codepage for backward compatibility? INHO, no. String should had been an alias of rawbytestring, and "codepage aware strings" should be another new type, but codepage should be static. Legacy programs could compile and run perfectly, and you could start using codepage aware strings type. Automatic conversions? Well, I'm not for it, but any way, left side shouldn't change its codepage. Nevertheless, that's my two cents. I looks that there is some pressure to be Delphi XX compatible, I left Delphi long long time ago (Delphi 5), so these compatibility issues are not in my radar. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Weird string behavior
El 26/07/2016 a las 16:19, Michael Van Canneyt escribió: > > > On Tue, 26 Jul 2016, Santiago A. wrote: > >> El 26/07/2016 a las 12:27, Mattias Gaertner escribió: >>> a3:=a1+a2 => cp = 1252 >>> a3:=a2+a1 => cp = 65001 >> Is that the expected behavior? >> >> IMHO the result should be the same. And the only way is to make it >> depend on a3, no matter what is in the left side. That's the way things >> are done in Pascal > > This is not correct. In pascal the right-hand side of an assignment > has a well-defined type. The compiler checks whether the type on the > right is assignment-compatible to the left side. Sorry I meant no matter what is in the right side. Other way my statment has no sense ;-) > > Michael. > > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal -- Saludos Santi s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Weird string behavior
El 26/07/2016 a las 12:27, Mattias Gaertner escribió: > a3:=a1+a2 => cp = 1252 > a3:=a2+a1 => cp = 65001 Is that the expected behavior? IMHO the result should be the same. And the only way is to make it depend on a3, no matter what is in the left side. That's the way things are done in Pascal -- Saludos Santi s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Weird string behavior
El 22/07/2016 a las 17:56, Jonas Maebe escribió: > > There is no hidden secret knowledge. Everything is documented and the > information is linked from the release notes. The "principle of least > surprise" has been applied in the sense that we didn't invent our own > system that introduces small or large differences compared to how > Delphi behaves in the same situation (and if there are differences, > then those are bugs in our implementation). With hidden knowledge I don't mean it's not documented, I mean that's like small print in contracts. Only those who know there is trick with adding are going to check manual. Complex things and pushing the language to its limits could require reading manual, adding two strings shouldn't. MyString := expression I really shouldn't need to know if right expression uses '+', or the result of a function, or '*', to guess what MyString type is. In addition, changing the codepage on the fly if a bad idea. If I cant change the codepage dynamically (I don't like it, but let's live with it), let me assign it explicitly, don't change it on the fly. SetCodePage(MyString,win1252); MyString := AnsiToUTF8(Ansi1 + Ansi2); // Automatically converted to Win-1252 before assign MyString := AnsiToUTF8(Ansi1) + AnsiToUTF8(Ansi2); // Automatically converted to Win-1252 before assign SetCodePage(MyString,utf8); MyString := AnsiToUTF8(Ansi1 + Ansi2); // No conversion needed MyString := AnsiToUTF8(Ansi2) + AnsiToUTF8(Ansi2); // No conversion needed MyString := Ansi1 + Ansi2; // Automatically converted to Utf8 before assign None changes the codepage of the String but me I don't like automatic conversion, but let's live with it. But I think that automatic change of var type is really wrong. This is Pascal, not bash or PHP. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Weird string behavior
El 22/07/2016 a las 15:03, Jonas Maebe escribió: > > See again > http://wiki.freepascal.org/FPC_Unicode_support#String_concatenations > (same as before). So ResultA := AnsiToUTF8(AnsiStrA + AnsiStrA); // UTF-8 ResultB := AnsiToUTF8(AnsiStrA) + AnsiToUTF8(AnsiStrA); // Win-1252 And resultA is not equal to ResultB It doesn't look like too intuitive. I would say that it is closer to "hidden secret knowledge" than to the "Principle of least surprise". -- Saludos Santiago A. s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Weird string behavior
El 22/07/2016 a las 12:55, Bart escribió: > Just check the vaue of StringCodePage(Utf8StrA). Not Initialized AnsiStrA: 1252 ResultA: 1252 AnsiStrA:=' ' AnsiStrA: 0 AnsiStrA[1]:=#243; // o acute win-1252 AnsiStrA: 0 ResultA:=AnsiStrA ResultA: 0 ResultA := AnsiStrA + ' ' ResultA: 1252 ResultA:=AnsiToUtf8(AnsiStrA); ResultA: 65001 ResultA:= AnsiToUtf8(AnsiStrA) + AnsiToUtf8(AnsiStrA); ResultA: 1252 I'm definitively completely lost --- program testconvertstr; var AnsiStrA:string; ResultA:string; begin writeln('Not Initialized'); writeln(' AnsiStrA: ',stringcodepage(ansistra)); writeln(' ResultA: ',stringcodepage(ResultA)); Writeln;writeln('AnsiStrA:='' '''); AnsiStrA:=' '; writeln(' AnsiStrA: ',stringcodepage(ansistra)); Writeln;writeln('AnsiStrA[1]:=#243; // o acute win-1252'); AnsiStrA[1]:=#243; // o acute win-1252 writeln(' AnsiStrA: ',stringcodepage(ansistra)); Writeln;writeln('ResultA:=AnsiStrA'); ResultA:=AnsiStrA; writeln(' ResultA: ',stringcodepage(ResultA)); Writeln;writeln('ResultA := AnsiStrA + '' '''); ResultA:=AnsiStrA+' '; writeln(' ResultA: ',stringcodepage(ResultA)); Writeln;Writeln('ResultA:=AnsiToUtf8(AnsiStrA);'); ResultA:=AnsiToUtf8(AnsiStrA); writeln(' ResultA: ',stringcodepage(ResultA)); Writeln;writeln('ResultA:= AnsiToUtf8(AnsiStrA) + AnsiToUtf8(AnsiStrA);'); ResultA:=AnsiToUtf8(AnsiStrA)+AnsiToUtf8(AnsiStrA); writeln(' ResultA: ',stringcodepage(ResultA)); Readln; end. -- Saludos Santi s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Weird string behavior
El 22/07/2016 a las 0:32, Bart escribió: > On 7/21/16, Santiago A. <s...@ciberpiula.net> wrote: > >> I've come across this issue: When I concatenate two strings in UTF8 they >> are converted to ansi (Win-1252) . > You have declared all string variables as plain "string", which is the > same as AnsiString(CP_ACP). So all string variables have the encoding > of your active codepage. > > Declare Utf8StrA and related as Utf8String. > In DisplayBytes do not use "String" as parametertype, since this will > again automatically convert things. > The AnsiToUtf8 is not necessary anymore if done this way: var AnsiStrA:string; // AnsiString(CP_ACP) AnsiStrB:string; // AnsiString(CP_ACP) Utf8StrA: string; // AnsiString(CP_ACP) Utf8StrB: string; // AnsiString(CP_ACP) Utf8StrConcat:string; // AnsiString(CP_ACP) begin AnsiStrA:=' '; AnsiStrA[1]:=#243; // o acute win-1252 AnsiStrB:='A'; // AnsiStrA is AnsiString(CP_ACP) // AnsiStrB is AnsiString(CP_ACP) Utf8StrA:=AnsiToUtf8(AnsiStrA); // 195 179 Utf8StrB:=AnsiToUtf8(AnsiStrB); // 65 // is Utf8StrA now utf8string? or something similar like Ansistring(UTF_8) // is Utf8StrB now utf8string? or something similar like Ansistring(UTF_8) Utf8StrConcat:=Utf8StrA+Utf8StrB; // AnsiString(CP_ACP) = UTF8 + UT8 // automatic Conversion to ansiString(CP_ACP) ? end; -- Saludos Santi s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Weird string behavior
Hello: I'm working on windows XP, FPC 3.0.0 from stable Lazarus 1.6. I've come across this issue: When I concatenate two strings in UTF8 they are converted to ansi (Win-1252) . A bug? Am I missing something? I have attached a demo. -- Saludos Santiago A. program testconvertstr; //--- procedure DisplayBytes(aString:String); var s:RawByteString absolute aString; i:Integer; begin Write(' '); for i:=1 to length(s) do write(ord(s[i]),' '); writeln; end; //--- // body //--- var AnsiStrA:string; AnsiStrB:string; Utf8StrA:string; Utf8StrB:string; Utf8StrConcat:string; begin AnsiStrA:=' '; AnsiStrA[1]:=#243; // o acute win-1252 AnsiStrB:='A'; Writeln('AnsiStrA: ');DisplayBytes(AnsiStrA); // 243 Writeln('AnsiStrB: ');DisplayBytes(AnsiStrB); // 65 Utf8StrA:=AnsiToUtf8(AnsiStrA); // 195 179 Utf8StrB:=AnsiToUtf8(AnsiStrB); // 65 writeln; Writeln('Utf8StrA:');DisplayBytes(Utf8StrA); // 195 179 Writeln('Utf8StrB:');DisplayBytes(Utf8StrB); // 65 // Expected 195 179 65, but displays 243 65 // as if after concatenation they were automatically // reverted to win-1252 Writeln('Utf8StrA+Utf8StrB ???:');DisplayBytes(Utf8StrA+Utf8StrB); writeln; Writeln('Utf8StrA again:');DisplayBytes(Utf8StrA); // 195 179 Writeln('Utf8StrB again:');DisplayBytes(Utf8StrB); // 65 Utf8StrConcat:=Utf8StrA+Utf8StrB; // same unexpected result assigning a intermediate var writeln; Writeln('Utf8StrConcat:');DisplayBytes(Utf8StrConcat); Readln; end. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Resource strings, passwords etc.
El 12/07/2016 a las 21:39, Graeme Geldenhuys escribió: > No, but why the hell would you want to hard-code a password inside an > executable. Encrypt it externally and read it from a .INI file at > runtime (or prompt for a password). Even something as simple as > XorString() is better than nothing - compared to storing it inside your > source code. > > Regards, > Graeme Well, if you don't prompt the password, where do you store the password to decrypt the externally encrypted password? ;-) Whenever you try to hide something without storing the password in user's brain you are just ofuscating. A hard coded password is just another way of ofuscating strings, but with a higher level of ofuscation. My solution to store passwords was to store de password in a .INI file (i.e. user doesn't want to type the password, wants the program to remember it). The connection password was encrypted with a hard-coded password and stored in base64 in the in file. i.e. implementation Const _Password='48-49-50'; // hardcoded ofuscated 123, so in resources it is not plain function unofuscate(s):string; begin . end; procedure LoadData; begin IniPassword:=unofuscate(_Password); ConnectionPass:=SimpleDecrypt(Base64Decode(ini.ReadString('connection','pass','')),IniPassword); end; I always declared the password in the implementation section, (don't know where I read that that way there is not a recognizable symbol "_Password"), if I had to use it in several places, I used ($include pass.inc} My ofuscate function was a little more complex, and but anyway, any system that stores passwords without human intervention is inherently insecure. Well, it was long time ago. -- Saludos Santiago A. s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] how to expand a set?
El 15/06/2016 a las 18:20, wkitt...@windstream.net escribió: > >>> how is a set of sets defined? >> No > > hunh? I meant, you can't. A set is not an ordinal type, but an structured type, so a set of sets is impossible. > > yup... > > if (this.messages.area.num in UsersMsgTaggedAreas) then > begin > ScanForNewMessages(this.messages.area.num); > > ScanForUserMessages(this.messages.area.num,this.user.name,this.user.nick); > end > else > inc(this.messages.area); > > ;) > That will work as long as UsersMsgTaggedAreas is restricted to 256 different values or less. And, not sure, but I think if num is out of the range of values of UsersMsgTaggedAreas's base type then the 'in' test won't result true or false, but an error. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] how to expand a set?
El 15/06/2016 a las 15:55, wkitt...@windstream.net escribió: > > what is the best/easiest way to increase the size of a set if the set > is defined as the following? > > > const > CMaxCount = 255; > > type > TMsgAreas = set of 0..CMaxCount; > > var > MsgAreas : TMsgAreas; > > > is a set of sets possible? No, the base type of a set must be an ordinal type. Enumeration type and integers. And the base type can't have more 255 elements > how is a set of sets defined? No > how are the elements in the sets accessed? ?? What do you mean with "access"? You can't access the element of a set, you can say if the an element is in a set or not. msgAreas:=[1..7]; if (2 in msAreas) then ... -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] code example where AnsiString used in FCL (SqlDB) causes data loss
El 11/05/2016 a las 16:38, Michael Van Canneyt escribió: > >> FPC 3.0 adds unsafe auto-conversions > > Why do you think it is unsafe ? > I have an answer for this. In short: Different codepage strings and raw strings should be considered different incompatible types. Pascal is a hardtyped language, and I love that, and codepages are prone to errors (all these threads prove it). Something about codpages needs a second thought. a) There shouldn't be automatic conversion at all. b) The codepage of a string shouldn't change when you assign a string with another codepage, just rise an error. c) Corollary of previous premises: Empty strings should also have codepage. Extra 1) Beside calling SetSetcodepage, it would be handy that you could set the codepage when you declare a string. I don't mean codepage should be statically typed, just it would be handy. Extra 2) Being able to set the codepage statically, so that mismatch codepage could be detected in compiler time, would be handy. In this case I do mean codepage could also be statically typed, -- Saludos Santi s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Lazarus vs MSEgui
I know it is a dangerous question that can easily turn into a holly war, flame or whatever. But here it is. I have only used Lazarus or a general editor (usually Jedit, geany). Time ago I checked a little MSEgui and, well, I didn't go for it. In MSEgui I found fonts small and interface not very nice. Beside I found it a little confusing. Later I found that it could be compiled to make fonts bigger etc. The honest reality is that I didn't devote much time to evaluate it. That's the problem of frameworks: when you learn one you get a little married with it, there are always complains and quirks, but before divorce you want to be sure that where you are moving to is better that what you have now. Unfortunately, getting the pros and cons requires working with it some time. The first pro of MSEgui is that it is light. In fact, That is the main pro of any thing that is not lazarus. No just because it's lighter but because lighter usually means less complex and less bugs. Cons. The most important. It looks like Lazarus has more developers, so may be a better decision for the long term. The second is the RAD. The immediate two directions updates, from GUI to source and from source to GUI, is very handy. Any body has experience in both (or another IDE for FPC) and has his two cents? By the way, has anybody managed to debug strings.text or any property with a getter? -- Saludos Santi s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Create dynamic SQL according to available params
El 07/04/2016 a las 14:00, Luiz Americo Pereira Camara escribió: > I enconter the following pattern frequently (simplified): > > SQL: > Select * From Customers Where FieldX = 1 > > Later i need a similar query that uses a different filter like > > Select * From Customers Where FieldX = 1 and FieldY = :paramy I remember a component of RxLib named TRxQuery. It had a published property "macros" of type TParams, so you could write this sql Select * From Customers Where FieldX = 1 and (%extrafilter). After setting de sql property, in design time was added an item to macros with name 'extrafilter' of type string and initial value '(0=0)', In run time you could do: RxQuery1.Macros.ParamByName('extrafilter'):='(0=0)'; or RxQuery1.Macros.ParamByName('extrafilter'):='FieldY=:paramy'; (I think there was also a RxQuery1.MacroByName to shorten RxQuery1.Macros.ParamByName) When you prepared the sql, macros where expanded in the sql. The was also a property named RealSQL of TString, it was the sql statement after macro substitution. (I'm not sure if RealSQL was public or I modified the library to make it public) When you changed a macro it was like changing the sql. You needed to prepare again the query. It is not that different from saving the original sql string and replacing certain parts, (in fact, I have done things like that). But it was handy. -- Saludos Santiago A. s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Class vs Object type
El 07/04/2016 a las 13:04, Graeme Geldenhuys escribió: > On 2016-04-07 11:58, Santiago A. wrote: >> Moreover, if the object uses classes instances that must be freed, you >> also must call destructor, then any advantage is over. > Technically yes, but as a rule of thumb, I *never* use Class objects > inside an Object object. That just seems messy. Usually, me neither. But I often use open arrays that can grow. Although open arrays are pointers that use heap, they are supposed to be liberated when the object is removed from stack, but in fpc 2.6.4 didn't properly. and 3.0.0 I have found strange behaviors and errors if I don't call a constructor. Nevertheless, I stick on my idea that even if objects have virtual methods, they should be initializated properly even if you don't call the constructor. -- Saludos Santi s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Class vs Object type
El 06/04/2016 a las 13:23, Graeme Geldenhuys escribió: > "The difference between objects and classes is mainly that an object is > allocated on the stack, as an ordinary record would be, and that classes > are always allocated on the heap." > > Are there pros or cons to either? > > Regards, > - Graeme - A nice pro of objects is that, if you don't need a constructor, you can forget about calling create and free. If you need a constructor (ie it has virtual methods), there is not that advantage. Moreover, if the object uses classes instances that must be freed, you also must call destructor, then any advantage is over. Maybe a little performance gain using stack instead of heap. A nice feature would be default creator and destructor: ej. type TMyObject=Object constructor default; Destructor default; end; procedure foo; var obj:TMyObject; begin // Default constructor (if it has) automatically called here obj.; obj.zzz; // Default destructor automatically called here end; Or even with parameters type TMyObjectParam=Object constructor default(n:Integer); Destructor default; end; procedure foo; var obj1:TMyObjectParam(7); obj2:TMyObjectParam; begin // Default constructor of obj1 automatically called here with param 7 // Default constructor of obj2 not called because the declaration has no parameters obj1.; obj1.zzz; if condition then begin obj2.Default(x); // Constructor must be called manually obj2.; obj2.zzz; end; // Default destructor of obj2 automatically called here if it has been initializated // Default destructor of obj1 automatically called here end; -- Saludos Santi s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Bitcounting
El 05/03/16 a las 19:03, Bart escribió: > Hi, > > Does FreePascal have a routine for counting bits? > So that e.g. BitCount(%100110011) gives 5 (number of bits that are 1)? > > I came up with (extracted from IntToBin()): > > function BitCount(N: Int64): Integer; > var > Q: QWord; > i: Integer; > begin > Result := 0; > Q := QWord(N); > for i := 0 to (8 * SizeOf(N) - 1) do > begin > if ((Q and 1) = 1) then Inc(Result); > Q := Q shr 1; > end; > end; > > Surely this can be done better? function BitCount_for(N: Int64): Integer; var Q: QWord; i: Integer; begin Result := 0; Q := QWord(N); for i := 0 to (8 * SizeOf(N) - 1) do begin inc(result,(Q and 1)); Q := Q shr 1; end; end; function BitCount_while(N: Int64): Integer; var Q: QWord; i: Integer; begin Result := 0; Q := QWord(N); While Q>0 do begin inc(result,(Q and 1)); Q := Q shr 1; end; end; The while version is slower if the first bit is 1 > > Bart > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal -- Santiago A. s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Objects, open arrays and memory leaks
Hello: I'm using Free Pascal Compiler version 3.0.0 [2015/11/16] for i386 I'm getting memory leaks (on winXP and Linux) . I have tracked to this. (Note: they are objects, not classes) type TArray=object InnerList:array of integer; constructor Init; end; constructor TArray.Init; begin SetLength(InnerList,10); end; procedure test; var obj:TArray; begin obj.init; obj.init; end; When I call twice the constructor "init" there is a memory leak. The open array of first init is not freed; init just sets the length of an open array to 10. I mean, no pointer or object created. I know open array are implemented pointers but I supposed that runtime would take care of it, so I was using the constructor to clear object and start from scratch. What I am missing? -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Problem with objects
El 23/12/2015 a las 12:13, Dennis Poon escribió: > > > Santiago Amposta wrote: >> Hello: >> I use fpc 2.6.4 and I have a problem of memory leaks, strange errors, >> etc. Finally I have tracked it to this: >> >> TSimpleArrayString=object >> List:array of String; >> end; >> >> TDerivedArrayString=object(TSimpleArrayString) >> other_field:integer; >> end; >> >> procedure TestSimple; >> var >> A:TSimpleArrayString; >> begin >>setLength(A.List,0); >> end; >> >> procedure TestDerived; >> var >> A:TDerivedArrayString; >> begin >>setLength(A.List,0); >> end; >> >> >> TestSimple; // Works Fine, >> TestDerived; // rises an exception SIGSEGV on setLength >> >> What am I doing wrong? >> > Did you call A.Create before calling TestDerived? Maybe A.List was not > initialized (which is done in constructor Create) and contains an > invalid pointer (to dynamic array of string). > When you call SetLength, it decrements the reference count of A.List > (which is not nil) and raisesSIGSEGV. > > Dennis > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal It's an object, not a class inherited from Tobject, so it hasn't create constructor. -- Saludos Santi s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Problem with objects
El 23/12/2015 a las 16:49, Dennis Poon escribió: > > > Even if it is an object, you can still define a constructor. > A constructor should initialize the memory area of the object to 0, > even if you don't explicitly assign List := nil; > It is safer to call this constructor before you handle the List. Well, AFAIK, according with the documentation, the constructor of an object is only necessary if it has virtual methods. It looks that calling a constructor that does nothing is a workaround solves the problem. But it doesn't make me feel secure. -- Saludos Santi s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Problem with objects
El 23/12/2015 a las 16:24, Lukasz Sokol escribió: > On 23/12/15 09:37, Santiago Amposta wrote: > I might be wrong... but I just tried: > > ... What's the conclusion? As far as I see, there is some kind of bug. There is no reason for getting different results depending on how you execute two independent and isolated procedures or if you comment in or out an unused procedure. -- Saludos Santiago A. s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Problem with objects
El 23/12/2015 a las 18:24, Jonas Maebe escribió: > Santiago Amposta wrote: > > > This is a bug in FPC 2.6.4 (it did not initialise managed fields of > parent objects for child objects that do not declare extra managed > fields). It is fixed in FPC 3.0. > I have used constructors as a workaround now I have a problem of memory leaks. TSimpleArrayString=object List:array of String; constructor Init; end; { TDerivedArrayString } TDerivedArrayString=object(TSimpleArrayString) other_field:integer; constructor Init; end; constructor TDerivedArrayString.Init; begin // nothing end; constructor TSimpleArrayString.Init; begin // nothing end; procedure TestSimple; var A:TSimpleArrayString; begin a.init; setLength(A.List,16); end; procedure TestDerived; var A:TDerivedArrayString; begin a.init; SetLength(a.list,16); SetLength(a.list,0); // If i comment this line, when I finish the program, the debug says there are unfreed blocks end; In TDerivedArrayString I need to manually set the length of the list to zero. If I don't, the memory is not freed, but in TSimpleArrayString it frees memory. Is it also a known bug of 2.6.4? -- Saludos Santiago A. s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Problem with objects
Hello: I use fpc 2.6.4 and I have a problem of memory leaks, strange errors, etc. Finally I have tracked it to this: TSimpleArrayString=object List:array of String; end; TDerivedArrayString=object(TSimpleArrayString) other_field:integer; end; procedure TestSimple; var A:TSimpleArrayString; begin setLength(A.List,0); end; procedure TestDerived; var A:TDerivedArrayString; begin setLength(A.List,0); end; TestSimple; // Works Fine, TestDerived; // rises an exception SIGSEGV on setLength What am I doing wrong? -- Regards Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] specialize, identifier not found
El 16/12/2015 a las 21:01, Sven Barth escribió: > Mode Delphi follows Delphi's syntax, thus no "generic" and > "specialize" keywords. Yes, you are right. I was just looking the objfpc syntax. > > The problem isn't default indexed properties. I guess your TRegAlias > is a record, thus it will be victim of this: > http://wiki.freepascal.org/User_Changes_2.4.0#Treating_direct-mapped_properties_as_regular_fields Yes, it looks like that's the problem. TReg=record regField_1:string; regField_1:string; end; TMyObject=object ... property Reg:TReg read getReg write setReg; end; Var myObject:TMyObject; I Can't do this: myObject.reg.regField_1:='A'; myObject.reg.regField_2:='B'; I have to do this: var auxReg:TReg; ... auxReg:=myObject.reg; auxReg.regField_1:='A'; auxReg.regField_2:='B'; myObject.reg:=auxReg; I can live with no passing them as var parameters, but I thing it is a little cumbersome for setting fields. I will try using pointers. Thanks, it was driving me mad. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] specialize, identifier not found
El 17/12/2015 a las 11:35, Sven Barth escribió: > > Am 17.12.2015 11:18 schrieb "Santiago A." <s...@ciberpiula.net > <mailto:s...@ciberpiula.net>>: > > I can live with no passing them as var parameters, but I thing it is a > > little cumbersome for setting fields. I will try using pointers. > > What do you mean with var-parameters? > I can't use the field as actual parameter of function with a var parameter: function foo(var n:integer); begin n:=n+1; end; foo(myObject.Reg.fieldReg) -- Saludos Santi s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] specialize, identifier not found
El 16/12/2015 a las 17:57, Santiago A. escribió: > Which FPC version? Which language mode? Sorry, I have forgotten version. {$mode Delphi} FPC 2.6.4 Same result on Win XP 32bits and Linux Gtk 64bits -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] specialize, identifier not found
El 16/12/2015 a las 17:25, Sven Barth escribió: > > Am 16.12.2015 16:12 schrieb "Santiago A." <s...@ciberpiula.net > <mailto:s...@ciberpiula.net>>: > > > > Type > > TRegAlias=record > >AliasName:string > > ... > > end; > > > > TArrayAlias=specialize TArray; // < Error here > > > > defconexion.pas(71,14) Error: Identifier not found "specialize" > > defconexion.pas(71,25) Error: Error in type definition > > defconexion.pas(71,25) Fatal: Syntax error, ";" expected but "identifier > > TARRAY" found > > > > > > Why this error? > > Why does the compiler try to look for a Identifier "specialize" instead > > of interpreting it as a reserved word? > > Which FPC version? Which language mode? > {$mode Delphi} I've just tried {$mode objfpc} and compiles type declaration, (Delphi mode can't understand generics?) But now I have another problem, when I use the variable, I get "Argument can't be assigned to" var arrayAlias:TArrayAlias; aliasList:TStringList; ... begin ... arrayAlias[i].AliasName:=aliasList[i]; //< Error here Where TArrayAlias=TArray, and TArray<_T> is an object, not a class. And it has a property property item[index:Integer]:_T read getItem write setItem; default; So, it has the getter and the setter. Doesn't objfpc mode accept default indexed properties? -- Saludos Santi s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] specialize, identifier not found
Type TRegAlias=record ... end; TArrayAlias=specialize TArray; // < Error here defconexion.pas(71,14) Error: Identifier not found "specialize" defconexion.pas(71,25) Error: Error in type definition defconexion.pas(71,25) Fatal: Syntax error, ";" expected but "identifier TARRAY" found Why this error? Why does the compiler try to look for a Identifier "specialize" instead of interpreting it as a reserved word? -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Blockread blockwrite var vs out parameters
El 16/12/2015 a las 11:55, Jonas Maebe escribió: > while with "out", they are first finalised Sorry, what does this mean? -- Saludos Santi s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal