Re: [fpc-pascal] TMaskUtils.ValidateInput function: how is it supposed to behave?
On 2016-04-18 19:26, Luiz Americo Pereira Camara wrote: > I propose to write a test suite first with the desired output, based on > Delphi. Fantastic idea! Test Driven Development - the best way to write any software. Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TMaskUtils.ValidateInput function: how is it supposed to behave?
On Mon, 18 Apr 2016, Luiz Americo Pereira Camara wrote: 2016-04-18 13:47 GMT-03:00 Bart: [..] The internal processing of the (edit)mask is the same as TMaskEdit. If that is broken somehow, it is also broken in TMaskEdit. The only functions that may need adjustments are * function FormatMaskText(const EditMask: string; const AValue: string): string; * function FormatMaskInput(const EditMask: string): string; * function MaskDoFormatText(const EditMask: string; const AValue: string; ASpaceChar: Char): string; * function TMaskUtils.TryValidateInput(out ValidatedString: String): Boolean; But since there is no real documentation and there is no test suite, it's hard to tell if they do not function as they should or introduce regressions. I propose to write a test suite first with the desired output, based on Delphi. I agree 100% Given that the implementation becomes a detail, subject to changes in future. I can take the duty of starting, just need to know the format. fpcunit or plain tests like most fpc tests? fpcunit. 'most fpc tests' are for the compiler, not for unit functionality. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Any chance to add the TStringBuilder to FCL?
El 18/04/16 a les 09:53, Marco van de Voort ha escrit: In our previous episode, J?rgen Hestermann said: > in loops. (it is that way in M2 btw, where the basetype is unsigned. Not > happy with that) I don't know what you mean. A For-loop has it's limits anyway. Limits like in for i:=0 to someexpression.count-1 are evaluated as expression before using the result to for. If count=0 this would become for i:=0 to $, so you need to guard this with a if count>0 then. Wait, doesn't that evaluate to for i:=0 to -1 at least if count is a signed integer? Bye -- Luca ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TMaskUtils.ValidateInput function: how is it supposed to behave?
2016-04-18 13:47 GMT-03:00 Bart: [..] > The internal processing of the (edit)mask is the same as TMaskEdit. > If that is broken somehow, it is also broken in TMaskEdit. > > The only functions that may need adjustments are > > * function FormatMaskText(const EditMask: string; const AValue: string): > string; > * function FormatMaskInput(const EditMask: string): string; > * function MaskDoFormatText(const EditMask: string; const AValue: string; >ASpaceChar: Char): string; > * function TMaskUtils.TryValidateInput(out ValidatedString: String): > Boolean; > > But since there is no real documentation and there is no test suite, > it's hard to tell if they do not function as they should or introduce > regressions. > > I propose to write a test suite first with the desired output, based on Delphi. Given that the implementation becomes a detail, subject to changes in future. I can take the duty of starting, just need to know the format. fpcunit or plain tests like most fpc tests? Luiz ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TMaskUtils.ValidateInput function: how is it supposed to behave?
On 4/18/16, Michael Van Canneytwrote: > I think Bart meant that the maskutils unit should simply use unicodestring. > Given that it almost surely will need to deal with $ and € etc, that seems > like a better approach. Yep. In UTF8 the 1 on 1 relation between the internal mask structure and the content of Value gets lost. In LCL's MaskEdit unit this is solved by assuming all string data is UTF8. (We convert the result from the widgetset to UTF8 explicitely) The MaskEdit unit has routines (GetCodePoint/SetCodePoint) that rely on routines in LazUtf8 in order to match a position of a codepoint to a position in the internal mask. This cannot be done in pure fpc, so a TMaskUtils based on AnsiChar can only function with single byte encoding (as it is now, so that doesn't break anything).. (UTF8 might even work if no case conversion is used in the mask, I have not tested). I attach an alterative _maskutils unit, which basically uses the same approach as TMaskEdit, but without the UTF8 support. Rewriting this to use WideChar and UnicodeString should be very easy. The internal processing of the (edit)mask is the same as TMaskEdit. If that is broken somehow, it is also broken in TMaskEdit. The only functions that may need adjustments are * function FormatMaskText(const EditMask: string; const AValue: string): string; * function FormatMaskInput(const EditMask: string): string; * function MaskDoFormatText(const EditMask: string; const AValue: string; ASpaceChar: Char): string; * function TMaskUtils.TryValidateInput(out ValidatedString: String): Boolean; But since there is no real documentation and there is no test suite, it's hard to tell if they do not function as they should or introduce regressions. Note; I did not find any reference to use of MaskUtils in FreePascal itself, except for the uses clause in the db uit (where I did not find any reference to the above mentioned functions). Q: Would changing the implementation to UnicodeString introduce regressions or compilation errors for existing programs using this unit? (It'll probably give warnings about possible data loss due to implicit conversions.) Bart { /*** maskutils.pas - ***/ * * * * This file is part of the Lazarus Component Library (LCL) * * * * See the file COPYING.modifiedLGPL, included in this distribution,* * for details about the copyright. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * * * Author: Bart Broersma } unit _maskutils; {$mode objfpc}{$H+} {.$define DebugMaskUtils} interface uses Classes, SysUtils; function FormatMaskText(const EditMask: string; const AValue: string): string; function FormatMaskInput(const EditMask: string): string; function MaskDoFormatText(const EditMask: string; const AValue: string; ASpaceChar: Char): string; type TEditMask = type string; TMaskeditTrimType = (metTrimLeft, metTrimRight); { Type for mask (internal) } tMaskedType = (Char_Start, Char_Number, Char_NumberFixed, Char_NumberPlusMin, Char_Letter, Char_LetterFixed, Char_LetterUpCase, Char_LetterDownCase, Char_LetterFixedUpCase, Char_LetterFixedDownCase, Char_AlphaNum, Char_AlphaNumFixed, Char_AlphaNumUpCase, Char_AlphaNumDownCase, Char_AlphaNumFixedUpCase, Char_AlphaNumFixedDownCase, Char_All, Char_AllFixed, Char_AllUpCase, Char_AllDownCase, Char_AllFixedUpCase, Char_AllFixedDownCase, Char_HourSeparator, Char_DateSeparator, Char_Stop); { TMaskUtils } type TMaskUtils = class(TObject) private FRealMask: String; FMask: String; // internal representatio of the mask FValue: String; FMaskLength: Integer; FMaskSave: Boolean;
Re: [fpc-pascal] is there any pascal library of SNTP (Simple Network Time Protocol)?
Am Monday 18 April 2016 17:34:10 schrieb Dennis: > I am want to embed the SNTP into my applications so that I don't have to > run Dimension 4 or other software to correct my PC Clock. Synapse http://synapse.ararat.cz/doc/help/sntpsend.TSNTPSend.html ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] is there any pascal library of SNTP (Simple Network Time Protocol)?
On 2016-04-18 16:34, Dennis wrote: > I am want to embed the SNTP into my applications Take a look at the Indy 10.6.0.2 components, they have the SNTP protocol implemented. They are free and open source. Get the latest code from their code repository. Official SVN repository: https://svn.atozed.com:444/svn/Indy10/trunk Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Any chance to add the TStringBuilder to FCL?
Am 2016-04-18 um 11:33 schrieb Sven Barth: Am 18.04.2016 07:58 schrieb "Jürgen Hestermann">: > And why was a directive implemented to use 0-based indices > even for strings but none for 1-based indices in dynamic arrays? > IMO the latter would be much more desired. The usual reason: Delphi compatibility. If Delphi wouldn't have that directive, we wouldn't have that either, because most others are content with the indices as they are. Seems that whenever something goes into the wrong direction then always Delphi is the culprit. ;-( ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Any chance to add the TStringBuilder to FCL?
Am 2016-04-18 um 09:53 schrieb Marco van de Voort: Limits like in for i:=0 to someexpression.count-1 are evaluated as expression before using the result to for. If count=0 this would become for i:=0 to $, so you need to guard this with a if count>0 then. Well, for 1-based arrays it would be for i := 1 to someexpression.count (without the annyoing -1). In general I can make sure that somexpression.count is zero or larger when I use it to determine an index for my array. The same would be for i := low(array) to high(array) which is very common and where I would not need to use an unsigned integer. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] is there any pascal library of SNTP (Simple Network Time Protocol)?
I am want to embed the SNTP into my applications so that I don't have to run Dimension 4 or other software to correct my PC Clock. Thanks in advance. Dennis ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TMaskUtils.ValidateInput function: how is it supposed to behave?
On Mon, 18 Apr 2016, Graeme Geldenhuys wrote: On 2016-04-18 15:51, Bart wrote: Maybe a version of maskutils unit based on UnicodeString should also be made? This seems so redundant. I still need to study the new FPC 3.0 string handling, but I was hoping such duplication of implementations would not be necessary with newer FPC versions. We don't see such rubbish [duplication of code with various string types] in Java or C# or Qt, so why must we put up with it in Object Pascal. I think Bart meant that the maskutils unit should simply use unicodestring. Given that it almost surely will need to deal with $ and € etc, that seems like a better approach. Michael.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TMaskUtils.ValidateInput function: how is it supposed to behave?
On 2016-04-18 15:51, Bart wrote: > Maybe a version of maskutils unit based on UnicodeString should also > be made? This seems so redundant. I still need to study the new FPC 3.0 string handling, but I was hoping such duplication of implementations would not be necessary with newer FPC versions. We don't see such rubbish [duplication of code with various string types] in Java or C# or Qt, so why must we put up with it in Object Pascal. Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TMaskUtils.ValidateInput function: how is it supposed to behave?
On 4/18/16, Bartwrote: >> I recently did some work on it; the class works completely wrong IMO, and As a side note: function ValidateInput : string; The function raises an exception upon failure. Since we did not have to follow Delphi here, a better declaration IMHO would have been: function ValidateInput (out ValidatedString: string): Boolean; or as a pair of functions (like the conversion routines for strings): function ValidateInput : string; function TryValidateInput (out ValidatedString: string): Boolean; Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TMaskUtils.ValidateInput function: how is it supposed to behave?
On 4/18/16, Michael Van Canneytwrote: > I recently did some work on it; the class works completely wrong IMO, and I > though to replace it completely with the functions found in the LCL. Yep, I was going that way too (and started coding it so). Currently FormatMaskText from maskedit (LCL) behaves better than the one from maskutils. The LCL implementation handles UTF8, the fpc's will (also with code ported form LCL) only handle single byte encoding. Maybe a version of maskutils unit based on UnicodeString should also be made? Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TMaskUtils.ValidateInput function: how is it supposed to behave?
On Sun, 17 Apr 2016, Bart wrote: Hi, I cannot find any documentation about TMaskUtils.ValidateInput function (unit MaskUtils). AFAICS Delphi does not have such a class? (ref: http://docwiki.embarcadero.com/Libraries/XE6/en/System.MaskUtils) There are some bugreports about this unit in Mantis which got me interested. I recently did some work on it; the class works completely wrong IMO, and I though to replace it completely with the functions found in the LCL. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Any chance to add the TStringBuilder to FCL?
Am 18.04.2016 07:58 schrieb "Jürgen Hestermann": > And why was a directive implemented to use 0-based indices > even for strings but none for 1-based indices in dynamic arrays? > IMO the latter would be much more desired. The usual reason: Delphi compatibility. If Delphi wouldn't have that directive, we wouldn't have that either, because most others are content with the indices as they are. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Any chance to add the TStringBuilder to FCL?
In our previous episode, J?rgen Hestermann said: > > in loops. (it is that way in M2 btw, where the basetype is unsigned. Not > > happy with that) > > I don't know what you mean. > A For-loop has it's limits anyway. Limits like in for i:=0 to someexpression.count-1 are evaluated as expression before using the result to for. If count=0 this would become for i:=0 to $, so you need to guard this with a if count>0 then. This is a common construct so quite annoying. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal