Re: [fpc-pascal] Clone a instance of object
On Mon, Sep 23, 2013 at 8:50 AM, Sven Barth pascaldra...@googlemail.comwrote: You need to add a Result.Assign(Self) to your clone call and implement a virtually inherited Assign method in each class where you copy all fields. This is how TPersistent and its descendants do it as well. Yes I added assign, but as example above, it is crashed when creating it Result:=TBaseObject(ClassType).Create; -- I am using last revision of Lazarus, FPC 2.6 on Windows XP SP3 Best Regards Zaher Dirkey ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Clone a instance of object
On Mon, 23 Sep 2013, Zaher Dirkey wrote: Hi, I have objects (classes) derived from base one TBaseObject = class(TObject) public constructor Create; virtual; function Clone:TBaseObject; end; TMyObject = class(TBaseObject) my fields here end; o1, o2:TmyObject; o1 already created; o2 := o1.Clone; in Clone i want to create new object from TmyObject but in base object in Clone method,like this TBaseObject.Clone:TBaseObject; begin Result:=TBaseObject(ClassType).Create;//I know it is wrong here end; This is wrong. You are typecasting a class reference to an object instance. The following works: {$mode objfpc} Type TBaseObject = class(TObject) public constructor Create; virtual; function Clone:TBaseObject; end; TBaseObjectClass = Class of TBaseObject; constructor TBaseObject.Create; begin end; Function TBaseObject.Clone:TBaseObject; Var C : TBaseObjectClass; begin C:=TBaseObjectClass(ClassType); Result:=C.Create; end; Type TMyObject = class(TBaseObject) // my fields here end; Var o1, o2:TmyObject; begin o1:=TMyObject.Create; o2 := o1.Clone as TmyObject; end. Michael.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Clone a instance of object
On 23/09/13 10:02, Michael Van Canneyt wrote: This is wrong. You are typecasting a class reference to an object instance. The following works: {$mode objfpc} Type TBaseObject = class(TObject) public constructor Create; virtual; function Clone:TBaseObject; end; TBaseObjectClass = Class of TBaseObject; constructor TBaseObject.Create; begin end; Function TBaseObject.Clone:TBaseObject; Var C : TBaseObjectClass; begin C:=TBaseObjectClass(ClassType); Result:=C.Create; end; What would happen if Result := Self.ClassType.Create were used instead? Type TMyObject = class(TBaseObject) // my fields here end; Var o1, o2:TmyObject; begin o1:=TMyObject.Create; o2 := o1.Clone as TmyObject; end. Stephano ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Clone a instance of object
On Mon, 23 Sep 2013, patspiper wrote: On 23/09/13 10:02, Michael Van Canneyt wrote: This is wrong. You are typecasting a class reference to an object instance. The following works: {$mode objfpc} Type TBaseObject = class(TObject) public constructor Create; virtual; function Clone:TBaseObject; end; TBaseObjectClass = Class of TBaseObject; constructor TBaseObject.Create; begin end; Function TBaseObject.Clone:TBaseObject; Var C : TBaseObjectClass; begin C:=TBaseObjectClass(ClassType); Result:=C.Create; end; What would happen if Result := Self.ClassType.Create were used instead? The wrong constructor would be called. Classtype is equivalend to 'Class of TObject'. The typecast is needed to ensure that the TBaseObject.Create constructor is called. Your basic polymorphism problem... Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Incompatible type for generics?
Short answer: you can't. The same would happen with normal classes. Long answer: You could add an additional method Next to your TIntTree which returns a TIntTree and just do Result := TIntTree(inherited Next); there. Why are you subclassing in this case anyway? Thanks, I will inherit the method. I need to add features in the sub-class. This empty TIntTree is just to show the problem. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] bridging an C++ shared library statically
On 09/21/2013 04:04 PM, Xiangrong Fang wrote: Hi All, I need to use a C++ so file in FreePascal AFAIK, you only can use C++ libraries in Pascal, if the functions for the mutual interface are flat C function (i. e. ANSI C functions not using any C++ classes). Of course, on top of this in both source codes the same ABI spec needs to be defined (e.g. PASCAL or STDCALL). -Michael ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] bridging an C++ shared library statically
Am 23.09.2013 10:53, schrieb Michael Schnell: On 09/21/2013 04:04 PM, Xiangrong Fang wrote: Hi All, I need to use a C++ so file in FreePascal AFAIK, you only can use C++ libraries in Pascal, if the functions for the mutual interface are flat C function (i. e. ANSI C functions not using any C++ classes). Of course, on top of this in both source codes the same ABI spec needs to be defined (e.g. PASCAL or STDCALL). You know that he wrote this the following as well (directly after your quote ends)? I have written a C wrapper for it, which successfully connected to Pascal. He only has problems LINKING the library and here it does not matter whether the library is written in C or C++. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Clone a instance of object
On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt mich...@freepascal.org wrote: Var C : TBaseObjectClass; begin C:=TBaseObjectClass(ClassType)**; Result:=C.Create; end; Yes, that help me, thanks. Now about assigning I must repeat it (assign) for every child class copy its field members, is there any trick to copy the values like assigning record var to another record var? I know it is kind of strange way :P Thanks Zaher Dirkey ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: StrUtils.RomanToInt oddities
On 20/09/13 19:49, Bart wrote: On 9/20/13, Reinier Olislagers reinierolislag...@gmail.com wrote: The question however becomes what is the algorithm for deciding invalid characters which IMO will become a mess very quickly. Much better to just consider the entire input as invalid. Here's my implementation: Here is how I would write it ;) function TryRomanToInt(AInput:String; out AResult: integer):boolean; var i, Len, N, Np1 : integer; function TryRomanCharToInt(AIn: Char; out AOut: integer): boolean; begin case AIn of 'M' : AOut := 1000; 'D' : AOut := 500; 'C' : AOut := 100; 'L' : AOut := 50; 'X' : AOut := 10; 'V' : AOut := 5; 'I' : AOut := 1; else AOut := 0; end; Result := (AOut 0); end; begin // if it looks like shameless cp, it's because it is ;) Result := False; AInput := UpperCase(AInput); //don't use AnsiUpperCase please Len := Length(AInput); if (Len = 0) then Exit; // i := 1; for i := 1 to Len-1 do begin if not TryRomanCharToInt(AInput[i], N) then begin AResult := -1; // invalidate everything exit; // writeln('Not a valid roman numeral at position ',i); end; if (i Len -1) then begin if not TryRomanCharToInt(AInput[i+1], Np1) then begin AResult := -1; // invalidate everithing exit; // writeln('Not a valid roman numeral at position ',i+1); end; // according to wikipedia, wonder if these are hard or soft rules thou... if not (((N = 100) and (Np1 100)) or // C can be placed before L or M ((N = 10) and (Np1 10) and (Np1 = 100)) or // X can be placed before L or C ((N = 1) and (Np1 1) and (Np1 = 10))) // I can be placed before V and X then begin AResult := -1; // invalidate everithing: catches MDCLXVIVXLDM exit; // writeln('Not a valid roman numeral combination at position ',i, ' and ',i+1); end; if N = Np1 then AResult := AResult + N else AResult := AResult - N; end; else // i = Len-1 = last char we just add (consider : MCM : add 1000, sub 100, add 1000 = 1900) begin AResult := AResult + N; end; end; // for // if the above, after all characters are through, has resulted in 0 or less, // we invalidate everything at the end (consider : CMLM, IIIM ) Result := AResult 0; if not Result then AResult := 0; end; (only mind-compiled ;) tests welcome ;) ) -L program test; {$mode objfpc} {$H+} uses SysUtils, StrUtils; function TryRomanToInt(S: String; out N: Integer): Boolean; var i, Len: Integer; Terminated: Boolean; begin Result := (False); S := UpperCase(S); //don't use AnsiUpperCase please Len := Length(S); if (Len = 0) then Exit; i := 1; N := 0; Terminated := False; //leading M's while (i = Len) and (S[i] = 'M') do begin //writeln('TryRomanToInt: Found 1000'); Inc(i); N := N + 1000; end; //then CM or or CD or D or (C, CC, CCC, ) if (i = Len) and (S[i] = 'D') then begin //writeln('TryRomanToInt: Found 500'); Inc(i); N := N + 500; end else if (i + 1 = Len) and (S[i] = 'C') then begin if (S[i+1] = 'M') then begin //writeln('TryRomanToInt: Found 900'); Inc(i,2); N := N + 900; end else if (S[i+1] = 'D') then begin //writeln('TryRomanToInt: Found 400'); Inc(i,2); N := N + 400; end; end ; //next max 4 C's if (i = Len) and (S[i] = 'C') then begin //find max 4 C's //writeln('TryRomanToInt: Found 100'); Inc(i); N := N + 100; if (i = Len) and (S[i] = 'C') then begin //writeln('TryRomanToInt: Found 100'); Inc(i); N := N + 100; end; if (i = Len) and (S[i] = 'C') then begin //writeln('TryRomanToInt: Found 100'); Inc(i); N := N + 100; end; if (i = Len) and (S[i] = 'C') then begin //writeln('TryRomanToInt: Found 100'); Inc(i); N := N + 100; end; end; //then XC or XL if (i + 1 = Len) and (S[i] = 'X') then begin if (S[i+1] = 'C') then begin //writeln('TryRomanToInt: Found 90'); Inc(i,2); N := N + 90; end else if (S[i+1] = 'L') then begin //writeln('TryRomanToInt: Found 40'); Inc(i,2); N := N + 40; end; end; //then L if (i = Len) and (S[i] = 'L') then begin //writeln('TryRomanToInt: Found 50'); Inc(i); N := N + 50; end; //then (X, xx, xxx, ) if (i = Len) and (S[i] = 'X') then begin //find max 4 X's //writeln('TryRomanToInt: Found 10'); Inc(i); N := N + 10; if (i = Len) and (S[i] = 'X') then begin //writeln('TryRomanToInt: Found 10');
Re: [fpc-pascal] Clone a instance of object
On Mon, Sep 23, 2013 at 12:46 PM, Michael Van Canneyt mich...@freepascal.org wrote: There is no such safe mechanism. The best you can do is make the properties published, and write an RTTI lookup routine that copies all Published values. I've done this several times, it works well for most situations. It is not the fastest way like assigning a record, can we ask it as a feature in FPC ? Best Regards Zaher Dirkey ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Clone a instance of object
On Mon, 23 Sep 2013, Zaher Dirkey wrote: On Mon, Sep 23, 2013 at 12:46 PM, Michael Van Canneyt mich...@freepascal.org wrote: There is no such safe mechanism. The best you can do is make the properties published, and write an RTTI lookup routine that copies all Published values. I've done this several times, it works well for most situations. It is not the fastest way like assigning a record, can we ask it as a feature in FPC ? It's impossible to do correctly. Michael.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Clone a instance of object
On Mon, 23 Sep 2013 11:46:54 +0200 (CEST) Michael Van Canneyt mich...@freepascal.org wrote: On Mon, 23 Sep 2013, Zaher Dirkey wrote: On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt mich...@freepascal.org wrote: Var C : TBaseObjectClass; begin C:=TBaseObjectClass(ClassType); Result:=C.Create; end; Yes, that help me, thanks. Now about assigning I must repeat it (assign) for every child class copy its field members, is there any trick to copy the values like assigning record var to another record var? I know it is kind of strange way :P There is no such safe mechanism. Well, actually there is a safe mechanism. You use a record to store the class variables. But it looks clumsily: type TMyClass = class(TPersistent) private type TMyClassVars = record a,b,c: string; end; private F: TMyClassVars; public procedure Assign(Source: TPersistent); property a: string read F.a write F.a; end; procedure TMyClass.Assign(Source: TPersistent); begin F:=TMyClass(Source).F; inherited; end; The best you can do is make the properties published, and write an RTTI lookup routine that copies all Published values. I've done this several times, it works well for most situations. Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Clone a instance of object
On Mon, Sep 23, 2013 at 12:57 PM, Mattias Gaertner nc-gaert...@netcologne.de wrote: type TMyClass = class(TPersistent) private type TMyClassVars = record a,b,c: string; end; private F: TMyClassVars; public procedure Assign(Source: TPersistent); property a: string read F.a write F.a; end; But in derived classes fields will not assigned? Best Regards Zaher Dirkey ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Clone a instance of object
On Mon, 23 Sep 2013 12:10:41 +0200 Frederic Da Vitoria davito...@gmail.com wrote: 2013/9/23 Mattias Gaertner nc-gaert...@netcologne.de On Mon, 23 Sep 2013 11:46:54 +0200 (CEST) Michael Van Canneyt mich...@freepascal.org wrote: On Mon, 23 Sep 2013, Zaher Dirkey wrote: On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt mich...@freepascal.org wrote: Var C : TBaseObjectClass; begin C:=TBaseObjectClass(ClassType); Result:=C.Create; end; Yes, that help me, thanks. Now about assigning I must repeat it (assign) for every child class copy its field members, is there any trick to copy the values like assigning record var to another record var? I know it is kind of strange way :P There is no such safe mechanism. Well, actually there is a safe mechanism. You use a record to store the class variables. But it looks clumsily: type TMyClass = class(TPersistent) private type TMyClassVars = record a,b,c: string; end; private F: TMyClassVars; public procedure Assign(Source: TPersistent); property a: string read F.a write F.a; end; procedure TMyClass.Assign(Source: TPersistent); begin F:=TMyClass(Source).F; inherited; end; This wouldn't clone included objects. I mean: if the object to be cloned contains objects, those included objects should probably be cloned too, but putting them into a record wouldn't achieve that. Anything that needs code to create needs code to clone. You can always creates cases where cloning need special code. But if you limit yourself you can use some of the existing frameworks like TReader/TWriter of tiopf. Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: build a compiler for GO32v2 under Windows 8 (or 7)
sorry ... delayed answer ... I don´t felt very well these days and this subject is a bit difficult for me ... but I will give time this week to read all I received ... and find out a way ... I´ll write later this week any way, I thank you very much all for your help! Philippe On Thu, 19 Sep 2013 22:01:50 +0200, Sven Barth wrote: On 18.09.2013 18:48, Philippe wrote: (first time I am using the mail list ... I may do it wrong!) I have a quite big program (now with more than 200.000 lines), first build with TP7. For example it accesses CGA memory through absolute address ... Years ago I moved to FPC. And it compiled ok under Windows 98 then under XP. Now with with a new PC running Windows 8 ... the compiler bugs. It works fine with small program but not with one which executable about 1.5 Mb large (which is my case, I did not checked till which size it works!). It's not necessarily a problem of your executable size, but the problem is the size/amount of units, because when compiling the compiler needs to keep all their interface meta-data in RAM. My program should run in prompt command window of any MS Windows version (compiling on XP machine, the executable runs fine on MS Windows 8 machine) This will however not work on a 64-bit systems as the NT Virtual DOS Machine (ntvdm.exe) is not supported there anymore. -- Philippe Links: -- [1] mailto:fpc-pascal@lists.freepascal.org [2] http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Problems reading some of the messages from this mailing list
Am 23.09.2013 13:09, schrieb Guillermo Martínez: Hi, I'm receiving some of the messages from this mailing list coding in an odd format: A block of characters and digits without any sense. For example, the one I quoted at the end of this mail. Does somebody knows why? According to my Thunderbird the message you quoted is of mime type multipart/mixed, so it's basically a HTML mail. Maybe that is the problem? Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Clone a instance of object
On Mon, 23 Sep 2013, Mattias Gaertner wrote: On Mon, 23 Sep 2013 11:46:54 +0200 (CEST) Michael Van Canneyt mich...@freepascal.org wrote: On Mon, 23 Sep 2013, Zaher Dirkey wrote: On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt mich...@freepascal.org wrote: Var C : TBaseObjectClass; begin C:=TBaseObjectClass(ClassType); Result:=C.Create; end; Yes, that help me, thanks. Now about assigning I must repeat it (assign) for every child class copy its field members, is there any trick to copy the values like assigning record var to another record var? I know it is kind of strange way :P There is no such safe mechanism. Well, actually there is a safe mechanism. You use a record to store the class variables. But it looks clumsily: type TMyClass = class(TPersistent) private type TMyClassVars = record a,b,c: string; end; private F: TMyClassVars; public procedure Assign(Source: TPersistent); property a: string read F.a write F.a; end; procedure TMyClass.Assign(Source: TPersistent); begin F:=TMyClass(Source).F; inherited; end; Yes. But that works only for 'simple' types and still requires you to write code. For the more general case where you can have arrays, classes, interfaces and whatnot as fields of your object, there is simply no correct way. Michael.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Nested comments
I realized FPC supports nested {} comments by default. SynPdf, a Synopse PDF engine http://synopse.info/fossil/wiki?name=PDF+Engine has '{' characters inside comments but they are not meant as nested comments. How to turn nested comments off? I did not find any such option even by using the new advanced (!) All Options GUI in Lazarus. Regards, Juha ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Nested comments
On Mon, 23 Sep 2013, Juha Manninen wrote: I realized FPC supports nested {} comments by default. SynPdf, a Synopse PDF engine http://synopse.info/fossil/wiki?name=PDF+Engine has '{' characters inside comments but they are not meant as nested comments. How to turn nested comments off? I did not find any such option even by using the new advanced (!) All Options GUI in Lazarus. Use Delphi mode or TP mode. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Problems reading some of the messages from this mailing list
On Mon, September 23, 2013 13:22, Sven Barth wrote: Am 23.09.2013 13:09, schrieb Guillermo Martínez: Hi, I'm receiving some of the messages from this mailing list coding in an odd format: A block of characters and digits without any sense. For example, the one I quoted at the end of this mail. Does somebody knows why? According to my Thunderbird the message you quoted is of mime type multipart/mixed, so it's basically a HTML mail. Maybe that is the problem? That should not be an issue by itself. The more likely reason is probably use of 8-bit message (utf-8) without encoding in us-ascii (7-bit) compatible envelope - typically MIME Quoted Printable (as already used for the HTML section, but not for the plain text version). Some mail servers may not allow that and recode the message in MIME Base64 encoding (which is most likely the text below); while doing that, they should include this information in the header, but I suspect that this hasn't happened in the case of Guillermo (this could be checked if he forwards the received message in attachment - doing this via fpc-other would be more appropriate than here). Nevertheless, the real solution is probably for Philippe to configure his e-mail client not to send 8-bit messages without 7-bit safe encoding). Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Clone a instance of object
On 23/09/13 14:57, Michael Van Canneyt wrote: On Mon, 23 Sep 2013, Mattias Gaertner wrote: On Mon, 23 Sep 2013 11:46:54 +0200 (CEST) Michael Van Canneyt mich...@freepascal.org wrote: On Mon, 23 Sep 2013, Zaher Dirkey wrote: On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt mich...@freepascal.org wrote: Var C : TBaseObjectClass; begin C:=TBaseObjectClass(ClassType); Result:=C.Create; end; Yes, that help me, thanks. Now about assigning I must repeat it (assign) for every child class copy its field members, is there any trick to copy the values like assigning record var to another record var? I know it is kind of strange way :P There is no such safe mechanism. Well, actually there is a safe mechanism. You use a record to store the class variables. But it looks clumsily: type TMyClass = class(TPersistent) private type TMyClassVars = record a,b,c: string; end; private F: TMyClassVars; public procedure Assign(Source: TPersistent); property a: string read F.a write F.a; end; procedure TMyClass.Assign(Source: TPersistent); begin F:=TMyClass(Source).F; inherited; end; Yes. But that works only for 'simple' types and still requires you to write code. For the more general case where you can have arrays, classes, interfaces and whatnot as fields of your object, there is simply no correct way. Can't the clipboard help in cloning? Similar to the IDE's copy and paste. Stephano ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Nested comments
On Mon, Sep 23, 2013 at 3:06 PM, Michael Van Canneyt mich...@freepascal.org wrote: Use Delphi mode or TP mode. Thanks, it helped. Actually there already was {$MODE Delphi} in an include file. Apparently it does not work, it must be in every pascal unit. This PDF package still does not compile with Lazarus. I will see which is easier, port it for Lazarus or add embedded font support for PowerPDF. If somebody knows a solution for PDF embedded fonts, please tell me. Regards, Juha ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Nested comments
Am 23.09.2013 14:28, schrieb Juha Manninen: On Mon, Sep 23, 2013 at 3:06 PM, Michael Van Canneyt mich...@freepascal.org wrote: Use Delphi mode or TP mode. Thanks, it helped. Actually there already was {$MODE Delphi} in an include file. Apparently it does not work, it must be in every pascal unit. The include needs to be before the interface uses clause. Better before the 'interface' keyword. Otherwise the modeswitch inside an include file works without problems as the FPC compiler uses that as well. Maybe you need to check for warnings... Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Clone a instance of object
2013/9/23 Michael Van Canneyt mich...@freepascal.org On Mon, 23 Sep 2013, Mattias Gaertner wrote: On Mon, 23 Sep 2013 11:46:54 +0200 (CEST) Michael Van Canneyt mich...@freepascal.org wrote: On Mon, 23 Sep 2013, Zaher Dirkey wrote: On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt mich...@freepascal.org wrote: Var C : TBaseObjectClass; begin C:=TBaseObjectClass(ClassType)**; Result:=C.Create; end; Yes, that help me, thanks. Now about assigning I must repeat it (assign) for every child class copy its field members, is there any trick to copy the values like assigning record var to another record var? I know it is kind of strange way :P There is no such safe mechanism. Well, actually there is a safe mechanism. You use a record to store the class variables. But it looks clumsily: type TMyClass = class(TPersistent) private type TMyClassVars = record a,b,c: string; end; private F: TMyClassVars; public procedure Assign(Source: TPersistent); property a: string read F.a write F.a; end; procedure TMyClass.Assign(Source: TPersistent); begin F:=TMyClass(Source).F; inherited; end; Yes. But that works only for 'simple' types and still requires you to write code. For the more general case where you can have arrays, classes, interfaces and whatnot as fields of your object, there is simply no correct way. Isn't there? Maybe it wouldn't be easy, but IIRC Delphi offers something related to this with TComponents and Streams. This Delphi mechanism I knew worked only for properties, but I found references that there existed a wider mechanism in D2010. -- Frederic Da Vitoria (davitof) Membre de l'April - « promouvoir et défendre le logiciel libre » - http://www.april.org ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Clone a instance of object
On Mon, 23 Sep 2013, Frederic Da Vitoria wrote: Yes. But that works only for 'simple' types and still requires you to write code. For the more general case where you can have arrays, classes, interfaces and whatnot as fields of your object, there is simply no correct way. Isn't there? Maybe it wouldn't be easy, but IIRC Delphi offers something related to this with TComponents and Streams. This Delphi mechanism I knew worked only for properties, but I found references that there existed a wider mechanism in D2010. There is no GENERAL way. The RTTI based mechanisms make special assumptions about how to reference components, tpersistents and whatnot. If I have a field that is a stream. How are you going to correctly copy this ? Just the stream instance pointer ? The stream+Contents ? The answer depends on how the classes are supposed to behave. The language itself cannot give you this mechanism. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Clone a instance of object
Am 23.09.2013 14:23, schrieb patspiper: On 23/09/13 14:57, Michael Van Canneyt wrote: On Mon, 23 Sep 2013, Mattias Gaertner wrote: On Mon, 23 Sep 2013 11:46:54 +0200 (CEST) Michael Van Canneyt mich...@freepascal.org wrote: On Mon, 23 Sep 2013, Zaher Dirkey wrote: On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt mich...@freepascal.org wrote: Var C : TBaseObjectClass; begin C:=TBaseObjectClass(ClassType); Result:=C.Create; end; Yes, that help me, thanks. Now about assigning I must repeat it (assign) for every child class copy its field members, is there any trick to copy the values like assigning record var to another record var? I know it is kind of strange way :P There is no such safe mechanism. Well, actually there is a safe mechanism. You use a record to store the class variables. But it looks clumsily: type TMyClass = class(TPersistent) private type TMyClassVars = record a,b,c: string; end; private F: TMyClassVars; public procedure Assign(Source: TPersistent); property a: string read F.a write F.a; end; procedure TMyClass.Assign(Source: TPersistent); begin F:=TMyClass(Source).F; inherited; end; Yes. But that works only for 'simple' types and still requires you to write code. For the more general case where you can have arrays, classes, interfaces and whatnot as fields of your object, there is simply no correct way. Can't the clipboard help in cloning? Similar to the IDE's copy and paste. Even then you'd need to convert the fields to the format the clipboard expects. And if you managed to correctly stream all properties than you don't need the clipboard anyway... Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: Problems reading some of the messages from this mailing list
From: Tomas Hajny xhaj...@hajny.biz That should not be an issue by itself. The more likely reason is probably use of 8-bit message (utf-8) without encoding in us-ascii (7-bit) compatible envelope - typically MIME Quoted Printable (as already used for the HTML section, but not for the plain text version). Some mail servers may not allow that and recode the message in MIME Base64 encoding (which is most likely the text below); while doing that, they should include this information in the header, but I suspect that this hasn't happened in the case of Guillermo (this could be checked if he forwards the received message in attachment - doing this via fpc-other would be more appropriate than here). Nevertheless, the real solution is probably for Philippe to configure his e-mail client not to send 8-bit messages without 7-bit safe encoding). Tomas So I can't do anything, can I? Unfortunatelly there are more users that sends their e-mail that way, specially chinese ones. Thanks. Guillermo Ñuño Martínez. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Clone a instance of object
On 23/09/13 10:46, Michael Van Canneyt wrote: I've done this several times, it works well for most situations. My I also suggest Zaher takes a look at tiOPF's code to see how they implement class cloning. Also be careful about the pitfalls of cloning a class. eg: How you want to handle more complex cases. eg: Cloning a class with a reference to another class, or cloning a class with an embedded class (field), etc... tiOPF's implementation allows the developer to decided how such cases should be handled. Regard, Graeme. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Clone a instance of object
On Mon, Sep 23, 2013 at 12:58 PM, Graeme Geldenhuys gra...@geldenhuys.co.uk wrote: Also be careful about the pitfalls of cloning a class. eg: How you want to handle more complex cases. eg: Cloning a class with a reference to another class, or cloning a class with an embedded class (field), etc... tiOPF's implementation allows the developer to decided how such cases should be handled. The idea is simply than needs to use a stream or RTTI, it is like a record, if looked at an object like as a record but it is inheritable. Compile can now every object body, and do the assigning as record assign. That's the feature I like to have. Best Regards Zaher Dirkey ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Clone a instance of object
On Mon, Sep 23, 2013 at 4:28 PM, Zaher Dirkey parm...@gmail.com wrote: The idea is simply than needs to use a stream or RTTI, it is like a record, if looked at an object like as a record but it is inheritable. Compile can now every object body, and do the assigning as record assign. That's the feature I like to have. Best Regards This is a funny example about what in my mind about what I talk (I know it is stupid and unsafe) If you look it is only for the class that not yet inherited yet, and work only for the top class, but the compiler can guss all inheited/derived classes and make the same assign. If some understand it, maybe give more explain. - type TmyRec = record s: string; i: integer; end; PmyRec=^TmyRec; TmyObj = class(TObject) s: string; i: integer; end; procedure TForm1.Button1Click(Sender: TObject); var o1, o2: TmyObj; begin o1 := TmyObj.Create; o2 := TmyObj.Create; o1.s := 'test1'; o1.i := 122; PmyRec(@o2)^ := PmyRec(@o1)^; WriteLn(o2.s); WriteLn(o2.i); end; - Best Regards Zaher Dirkey ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Problems reading some of the messages from this mailing list
I changed the webmail configuration to MIME / 8 bits ... I hope it helps! Philippe On Mon, 23 Sep 2013 15:06:00 +0200, Guillermo Martínez wrote: From: Tomas Hajny That should not be an issue by itself. The more likely reason is probably use of 8-bit message (utf-8) without encoding in us-ascii (7-bit) compatible envelope - typically MIME Quoted Printable (as already used for the HTML section, but not for the plain text version). Some mail servers may not allow that and recode the message in MIME Base64 encoding (which is most likely the text below); while doing that, they should include this information in the header, but I suspect that this hasn't happened in the case of Guillermo (this could be checked if he forwards the received message in attachment - doing this via fpc-other would be more appropriate than here). Nevertheless, the real solution is probably for Philippe to configure his e-mail client not to send 8-bit messages without 7-bit safe encoding). Tomas So I can't do anything, can I? Unfortunatelly there are more users that sends their e-mail that way, specially chinese ones. Thanks. Guillermo Ñuño Martínez. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org [2] http://lists.freepascal.org/mailman/listinfo/fpc-pascal [3] Links: -- [1] mailto:xhaj...@hajny.biz [2] mailto:fpc-pascal@lists.freepascal.org [3] http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities
On 9/23/13, Lukasz Sokol el.es...@gmail.com wrote: function TryRomanToInt(AInput:String; out AResult: integer):boolean; var i, Len, N, Np1 : integer; [snip] if N = Np1 then AResult := AResult + N else AResult := AResult - N; end; else // i = Len-1 = last char we just add (consider : MCM : add 1000, Compiler doesn't like the else here. I removed the ; after the end 1 line above. sub 100, add 1000 = 1900) begin AResult := AResult + N; end; end; // for // if the above, after all characters are through, has resulted in 0 or less, // we invalidate everything at the end (consider : CMLM, IIIM ) Result := AResult 0; if not Result then AResult := 0; end; (only mind-compiled ;) tests welcome ;) ) It produces odd output though: C:\Users\Bart\LazarusProjecten\ConsoleProjectentest Enter Roman numeral: LL //should be illegal TryRomanToInt('LL') - 50 StrUtils.RomanToInt('LL') = 100 Enter Roman numeral: MM TryRomanToInt('MM') - 1050 //obviously should be 2000 StrUtils.RomanToInt('MM') = 2000 Enter Roman numeral: II TryRomanToInt('II') - 1051 // nice one! StrUtils.RomanToInt('II') = 2 So, it's a little bit flawed. Anyhow, let's not focus upon what the new code should be. The question was: is current behaviour (accepting IIMIIC etc.) a bug or not. Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities
Premise: I didn't go through your entire implementation, thou' at first sight looks much better than the current one. I know roman numerals since I was 8 or 9 yo, that makes a quick and dirt result of about 35 years. Thing is: 1. in the roman numerals, not all the digits can be subtracted from the others 2. no more than three same roman numerals can appear in a row. so that XM is as invalid as . (although this amenity can be seen on some - in my opinion poor - wristwatches' face that uses roman numerals, for the 4h, showing instead of the correct IV, but this is another story) in roman numerals we have only these digits: I(1) V(5) X(10) L(50) C(100) D(500) M(1000) (sorry, no digit for the expected progression, for 5000) the only digits that can be subtracted are I, X and C (only those on the left side of the table above), and they can only from the 2 digits immediately following them in the system, so that: I can be subtracted only from V and X X can be subtracted only from L and C C can be subtracted only from D and M so that 45 cannot be written as VL (50 - 5, as one might suspect) but must be written as XLV, or to better understand, as (XL)V = 40 + 5 The maximum roman numeral that can be represented is 4999, that is NOT MMMIM, but instead: MMM(CM)(XC)(IX) 1000+1000+1000+(1000-900)+(100-10)+(10-1) After this, roman numerals always begin with bigger numbers to sum up, and proceed to smaller, so you cannot start adding up 10, then 500, then again 1; like XDI (whether it be intended to be 491 or 511 - just no way) I did an implementation some time ago, for pure fun, and provided I find it out (or maybe I can just rewrite it, on the basis of this knowledge) I will be - repository allowing ;-) - wery happy to contribute with my 2c for it. Cheers, A. On 20/09/13 21:49, Bart wrote: On 9/20/13, Reinier Olislagersreinierolislag...@gmail.com wrote: The question however becomes what is the algorithm for deciding invalid characters which IMO will become a mess very quickly. Much better to just consider the entire input as invalid. Here's my implementation: program test; {$mode objfpc} {$H+} uses SysUtils, StrUtils; function TryRomanToInt(S: String; out N: Integer): Boolean; var i, Len: Integer; Terminated: Boolean; begin Result := (False); S := UpperCase(S); //don't use AnsiUpperCase please Len := Length(S); if (Len = 0) then Exit; i := 1; N := 0; Terminated := False; //leading M's while (i= Len) and (S[i] = 'M') do begin //writeln('TryRomanToInt: Found 1000'); Inc(i); N := N + 1000; end; //then CM or or CD or D or (C, CC, CCC, ) if (i= Len) and (S[i] = 'D') then begin //writeln('TryRomanToInt: Found 500'); Inc(i); N := N + 500; end else if (i + 1= Len) and (S[i] = 'C') then begin if (S[i+1] = 'M') then begin //writeln('TryRomanToInt: Found 900'); Inc(i,2); N := N + 900; end else if (S[i+1] = 'D') then begin //writeln('TryRomanToInt: Found 400'); Inc(i,2); N := N + 400; end; end ; //next max 4 C's if (i= Len) and (S[i] = 'C') then begin //find max 4 C's //writeln('TryRomanToInt: Found 100'); Inc(i); N := N + 100; if (i= Len) and (S[i] = 'C') then begin //writeln('TryRomanToInt: Found 100'); Inc(i); N := N + 100; end; if (i= Len) and (S[i] = 'C') then begin //writeln('TryRomanToInt: Found 100'); Inc(i); N := N + 100; end; if (i= Len) and (S[i] = 'C') then begin //writeln('TryRomanToInt: Found 100'); Inc(i); N := N + 100; end; end; //then XC or XL if (i + 1= Len) and (S[i] = 'X') then begin if (S[i+1] = 'C') then begin //writeln('TryRomanToInt: Found 90'); Inc(i,2); N := N + 90; end else if (S[i+1] = 'L') then begin //writeln('TryRomanToInt: Found 40'); Inc(i,2); N := N + 40; end; end; //then L if (i= Len) and (S[i] = 'L') then begin //writeln('TryRomanToInt: Found 50'); Inc(i); N := N + 50; end; //then (X, xx, xxx, ) if (i= Len) and (S[i] = 'X') then begin //find max 4 X's //writeln('TryRomanToInt: Found 10'); Inc(i); N := N + 10; if (i= Len) and (S[i] = 'X') then begin //writeln('TryRomanToInt: Found 10'); Inc(i); N := N + 10; end; if (i= Len) and (S[i] = 'X') then begin //writeln('TryRomanToInt: Found 10'); Inc(i); N := N + 10; end; if (i= Len) and (S[i] = 'X') then begin //writeln('TryRomanToInt: Found 10'); Inc(i); N := N + 10; end; end; //then IX or IV if (i + 1= Len) and (S[i] = 'I') then begin if (S[i+1] = 'X') then begin Terminated := (True);
Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities
Ooops, I also forgot to mention that only I, X, C and M can appear up to three times in a row. V, L and D does not; they can only once. Cheers again, A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities
On 23.09.2013 21:17, Alberto Narduzzi wrote: Ooops, I also forgot to mention that only I, X, C and M can appear up to three times in a row. V, L and D does not; they can only once. Are you sure regarding M considering there is no symbol for 5000? Or didn't Romans count to more than 5000 - 1? Regards, sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities
On 9/23/13, Alberto Narduzzi albertonardu...@yahoo.com wrote: Thing is: 1. in the roman numerals, not all the digits can be subtracted from the others 2. no more than three same roman numerals can appear in a row. My implementation is a little more relaxed as to rule 2. It is more often violated than rule 1. Typically is not al that uncommon. I did an implementation some time ago, for pure fun, and provided I find it out (or maybe I can just rewrite it, on the basis of this knowledge) I will be - repository allowing ;-) - wery happy to contribute with my 2c for it. By all means. The princial question must be answered first though. Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities
On 9/23/13, Sven Barth pascaldra...@googlemail.com wrote: Are you sure regarding M considering there is no symbol for 5000? Or didn't Romans count to more than 5000 - 1? There are numerous extensions upon the scheme. In later times adding horizontal lines above or under a Roman numeral meant multiply by 1000. I don't believe though Romans knew negative numbers. But I'm certainly not an expert on the matter. Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities
2013/9/23 Bart bartjun...@gmail.com The question was: is current behaviour (accepting IIMIIC etc.) a bug or not. What about making an option of it? Anyhow, if the function accepts invalid combinations, what should it return? For some, the answer would be obvious (), but some combinations are indeed ambiguous (M) So that we maybe could accept unambiguous invalid combinations, but I don't see how to accept ambiguous ones. -- Frederic Da Vitoria (davitof) Membre de l'April - « promouvoir et défendre le logiciel libre » - http://www.april.org ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities
On 9/23/13, Frederic Da Vitoria davito...@gmail.com wrote: What about making an option of it? It's up to the fpc devels. Anyhow, if the function accepts invalid combinations, what should it return? For some, the answer would be obvious (), but some combinations are indeed ambiguous (M) So that we maybe could accept unambiguous invalid combinations, but I don't see how to accept ambiguous ones. If it accepts, then it should apply the subtraction rule: only the (one) numeral left to the other (bigger one) can be subtracted. So IIIM would be III + IM = 3 + 1000-1 = 1002 (and not 1000-3 = 997) There should be no ambiguity there, it's only a pain to watch it. Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] FPCUnit test + raise E;
On Thu, Sep 19, 2013 at 1:44 AM, Sven Barth pascaldra...@googlemail.com wrote: Am 18.09.2013 23:34 schrieb Marcos Douglas m...@delfire.net: On Tue, Sep 17, 2013 at 2:41 PM, Sven Barth pascaldra...@googlemail.com wrote: On 17.09.2013 17:27, Marcos Douglas wrote: On Tue, Sep 17, 2013 at 12:18 PM, Marcos Douglas m...@delfire.net wrote: Another thing you could try (just for testing): change your exception handler procedure to a function that returns bool and use it like this: === code begin === procedure TghSQLConnector.Connect; begin try FLib.Connect; except on E: Exception do if not DoOnException(E) then raise; end; end; === code end === Regards, Sven The only difference is the use of raise; instead raise E; right? Marcos Douglas In project in attachment before, if you change the line 50 from: raise E; to: raise Exception.Create(E.Message); Will work... but is this correct? So this seems to be indeed a problem of freeing exceptions. Whether you misuse the exception system or you encountered a bug needs to be determined... If this is a bug I can register in bug tracker. I don't know yet whether it's a bug or a mistake... Lazarus 1.1 r42461 FPC 2.6.2 i386-win32-win32/win64 Could you test your original one with 2.7.1 as well? I can't compile Lazarus with FPC 2.7.1 (as you saw in lazarus-list) so, I can't test... :( It's ok if you use a 2.7.1 before the merge of the cpstrrtl branch. There AFAIK weren't any exception related changes since then. For now I resolved use re-raise the original Exception using FPC 2.6.2. Thank you again. Marcos Douglas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities
What about making an option of it? If it accepts, then it should apply the subtraction rule: only the (one) numeral left to the other (bigger one) can be subtracted. So IIIM would be III + IM = 3 + 1000-1 = 1002 (and not 1000-3 = 997) There should be no ambiguity there, it's only a pain to watch it. as I said, roman numerals what they are. If you want to invent something new, nowadays, extending the roman numerals to your like, well (growl!) feel free to do it, but do not pretend to call them so. IIIM has no meaning in roman numerals. FULL STOP. There is no such logic as you depict it. 1002 = MII, and 997 = CMXCVII. All the rest is pure bull in terms of roman numerals by the very name. I begin to have a feeling that here somebody is merely talking nonsense; say, like pretending to use the digit 2 in the binary system... This is no decimal notation logic; things are as they are, so do not pretend to give roman numerals a value according to their position in the number itself; it is pure NONSENSE here. Or maybe you have no clue about, so do not litter Pascal with something you don't know anything about, which will only make you just ridicule; possibly (hope not, thou') by the very Embarcadero/Delphi guys... which is not so good for Freepascal, really. Ah, BTW, what Delphi does (as I read maybe on the very first reply to the topic, sic), here, makes no sense too. Roman numerals are what they are, irrelevantly of what somebody *may think they are*. A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities
What about making an option of it? Anyhow, if the function accepts invalid combinations, what should it return? For some, the answer would be obvious (), but some combinations are indeed ambiguous (M) So that we maybe could accept unambiguous invalid combinations, but I don't see how to accept ambiguous ones. they are not ambiguous, they are simply INVALID. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities
Are you sure regarding M considering there is no symbol for 5000? Or didn't Romans count to more than 5000 - 1? yes I am. as 5000 - 1 would need to be written CMXCIX, which has the 4-M-in-a-row, that is invalid, as a maximum of three is allowed. Yes, probably ancient Romans had no need to count more that 3999 Sestertiae ;-) I don't believe though Romans knew negative numbers. But I'm certainly not an expert on the matter. never though about, but if the only matter is DEBT, then just write positive numbers under the DEBT column, and everybody shall be happy too, provided they know the meaning of such a column ;-) P.S. Have no clue of roman arithmetics, thou', which looks a little more weird to implement, or just to think about :-O A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities
On 23/09/2013 22:30, Alberto Narduzzi wrote: What about making an option of it? Anyhow, if the function accepts invalid combinations, what should it return? For some, the answer would be obvious (), but some combinations are indeed ambiguous (M) So that we maybe could accept unambiguous invalid combinations, but I don't see how to accept ambiguous ones. they are not ambiguous, they are simply INVALID. So the question is, what does or should do RomanToInt for invalid input? It is NOT called CheckValidRoman, so it could be that the result for invalid input is simply undefined. If it is, then all is ok. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: StrUtils.RomanToInt oddities
So the question is, what does or should do RomanToInt for invalid input? It is NOT called CheckValidRoman, so it could be that the result for invalid input is simply undefined. If it is, then all is ok. so, what does 10AT (or $10AT for tht matter) return for HexToDec??? maybe NaN, if there is such a definition in Pascal??? Looks acceptable to me. But IsValidRoman is as good as a solution too, indeed... ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Problems reading some of the messages from this mailing list
On Monday, September 23, 2013 7:09 AM, Guillermo Martínez gmarti...@burdjia.com wrote: Hi, I'm receiving some of the messages from this mailing list coding in an odd format: A block of characters and digits without any sense. For example, the one I quoted at the end of this mail. Does somebody knows why? that's base64 encoding... what you quoted does not show the content-transfer-encoding line which tells you if it is BASE64 or QUOTED-PRINTABLE or 8BIT or 7BIT or BINARY or x-token i've been dealing with something similar in my recent bouts with the synapse mime library and decoding sewly arrived email posts... ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal