Re: [fpc-pascal] Testing set membership for unicode chars
2013/1/20 Paul Ishenin : > 20.01.13, 23:21, Wimpie Nortje пишет: >> >> Hi list >> >> I want to test membership of a unicode char in a set / array of unicode >> chars. Something like >> >> var ucCh: unicodechar; >> >> if ucCh in [ UnicodeChar('0')..UnicodeChar('9')] then >> dosomething; >> >> I am using fpc 2.6.0 and the '..' operator converts the data to a pascal >> set, which is limited to 1 byte data. >> >> Is there another way? > > Delphi has CharInSet() function for this: > http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/SysUtils_CharInSet@ansic...@tsyscharset.html > > I don't remember whether we have it in FPC at the moment. Don't know if it can be helpful for the OP, but some years ago, I sent 'Unicode category membership checking functions' here: http://bugs.freepascal.org/view.php?id=16400 Please feel free to use that code for whatever you want w/o restrictions. -j ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] State of fcl-stl generics lib
2013/1/11 Juha Manninen > > I remember seeing discussion about fcl-stl saying that it would still > need improvement but nobody is actively working on it. > I just couldn't find the thread about it now. So, what is the current state? > Sorry I have not studied the lib myself yet (long ToDo list). > > For example, if someone is developing a competing generics library, > could he be advised to improve fcl-stl instead? Would patches be accepted? > > This is based on a forum discussion: > http://www.lazarus.freepascal.org/index.php/topic,19496.msg111098/topicseen.html Oh, generics again! Shameless plug: http://code.google.com/p/fprb/wiki/heContnrs ;-) Jan (gmp package author) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Reversing bit-order of byte
Dne 3.5.2012 9:11 "Koenraad Lelong" napsal(a): > > Does anyone knows an efficient way to reverse bit-order of a byte for the arm-processor ? Lookup from a 256 byte precomputed table? Or I misunderstood the task. -jan ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Can it map class type as key?
2012/4/26 ZHANG Dao-yuan <1123mon...@gmail.com>: > Thanks for your makeshift :) . But the problem still confusing me. My code > is in type-section and it's a declaration not a statement. > >> tFpGMap > The form of the code is similar to a comparision expression and `<' here > looks like a less-than operator. But they are not. In my opinion, fpc should > not take the declaration as a statement then try to search for the nonsense > operator-overloaded methods. You might want to have a look at http://code.google.com/p/fprb/wiki/TheCmpBTreeMap -jan ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Win64 and currency
2012/3/30 Marco van de Voort : > In our previous episode, Pierre Free Pascal said: >> if you usee -Aas and -al >> you will see that >> TEST >> is just .quad -10 >> which is wrong of course... >> Using -10.0 fixes the bug for now if >> you really need this correct fast. >> >> It would be nice if you could submit a bug report. > > Note that #21091 is also about win64 and currency. Hi Marco, I'm very sorry for this OT message but as I saw you posting here it reminded me of: I've mailed you off-list some time ago and it seems the message probably didn't ever made it to your inbox (perhaps falsely detected as spam or something). May I please ask you to contact me? Thank you and once again, I'm really sorry to bring noise into this thread. Best regards, Jan ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] ANN: heLib/heContnrs stable version for FPC 2.6.0
The previously released (RC) version 0.4 was found to be working w/o known bugs with the latest stable FPC 2.6.0 (svn revison 19845). Now virtually (re)releasing the previous RC1 as the offical" stable. Download source tarball here: http://code.google.com/p/fprb/downloads/detail?name=release-0.4.tar.gz Online documentation: http://code.google.com/p/fprb/wiki/heContnrs Any feedback will be highly appreciated, thanks. -bflm ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] IInterface type value and the "as" keyword
2011/12/11 Marco van de Voort : > In our previous episode, Honza said: >> Now I'm trying to make that code work with >> current stable (AFAICS that's 2.4.4) > > Correct, but it is relatively short before the 2.6.0 release, with a first > RC1 already available. Since 2.6.0 might arrive this year still (or in the > first week of the next), I suggest your focus your attention there, and > forget about 2.4.4. Good suggestion, done exactly that. >> I suppose something has changed with the FPC interfaces and/or using >> the "as" keyword in the above construct. Of course I searched e.g. the >> "changes" wiki pages 2.4.0->2.4.2->2.4.4(and even ->2.6.0), but I >> failed to find anything related, the same result for the mailing lists >> and general googling attempts. And of course I tried every single >> change to the code I could imagine may work. > > I assume it is bugfixed in 2.5+, which never made it back to the 2.4 series. Yes, after switching to 2.6.0 the problem disappeared, thank you very much! Thanks to your help (and some hours of hacking), I'm now here: $ ./helib_test -a -p --format=plain ... Number of run tests: 701 Number of errors:0 Number of failures: 0 Heap dump by heaptrc unit 5844426 memory blocks allocated : 252487390/286727568 5844426 memory blocks freed : 252487390/286727568 0 unfreed memory blocks : 0 True heap size : 294912 True free heap : 294912 $ ;-) Thanks again! Best regards, -bflm PS: helib/heContnrs release-0.4, RC1 for FPC 2.6.0 (tested with svn rev 19814), tar download available here: http://code.google.com/p/fprb/downloads/detail?name=release-0.4.tar.gz Feedback/issue reports/volunteers to test on other platforms/architectures/... welcome. (I can easily run tests only on 64bit Ubuntu 10.10.) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] IInterface type value and the "as" keyword
Hi list, after a long pause I'm trying to revive some code which I didn't touch as long as early this year. At that time it compiled OK with trunk FPC (I believe version 2.5.1). Now I'm trying to make that code work with current stable (AFAICS that's 2.4.4). Everything went smooth until compiler stumbled upon: function TheInterfaceListTest.Value(const It: IInterface): Integer; begin Result := (It as TInterfacedTracedObject).ID; // <-- line 238 end; with the error: "hecontnrs_list_test.pas(238,17) Error: class type expected, but got "IUnknown". FYI: TInterfacedTracedObject interface is: TInterfacedTracedObject = class(TInterfacedObject) private FID: Integer; FTracer: TBits; public constructor Create(const ATracer: TBits; const AID: Integer); destructor Destroy; override; property ID: Integer read FID; property Tracer: TBits read FTracer; end; I suppose something has changed with the FPC interfaces and/or using the "as" keyword in the above construct. Of course I searched e.g. the "changes" wiki pages 2.4.0->2.4.2->2.4.4(and even ->2.6.0), but I failed to find anything related, the same result for the mailing lists and general googling attempts. And of course I tried every single change to the code I could imagine may work. That said, I'm sure it's my fault to find the info or it's my fault in some other way - me being blind to see something obviously wrong with the code in the snippet, though I'm sure it used to compile w/o problem before. Can please someone enlighten me? Thanks in advance, sorry for being dumb ;-) Best regards, -bflm PS: Actually I found some recent discussions about FPC interfaces, but if I understood them correctly, no one of them seemed to me like an explanation for my problem. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] operator overloading and counting references / creating / destoying anonymous instances
2011/7/28 Bernd : > ¹ I depend on OpenSSL already anyways, so I thought why not make use > of its bignum too when I need it. I hope you're aware of the FPC GMP bindings: http://wiki.freepascal.org/gmp The section http://wiki.freepascal.org/gmp#Extensions_bindings_.26_types discuses extended bindings which use the automated memory handling and overloaded operators. See also the sources: http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/gmp/src/gmp.pas?view=markup starting at line 1684. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fgl.TFPGMap
2011/1/20 Alex Shishkin : > As I understand problem is in the compiler. It cant use overloaded operator > if it was defined after generic. AFAIK exactly that is the problem and that's why TFPGMap can't cope with some types. >> You can take a look on this container lib, which might be helpful for your >> task: >> http://code.google.com/p/fprb/wiki/heContnrs > > Good lib, but Lazarus codetools does not support nested classes as for now. That's unfortunately a thing I can't help you with. -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fgl.TFPGMap
2011/1/20 Alex Shishkin : > Following code causes error "Operator is not overloaded: "TObject" < > "TObject"" > How to make it work? > > program generictest2; > {$mode objfpc}{$H+} > uses > fgl; > operator < (a: TObject; b: TObject): boolean; > begin > result := PtrInt(a) < PtrInt(b); > end; > type > TMyMap = specialize TFPGMap ; > begin > end. AFAIK TFPGMap can be specialized only with types which have the relational operators predefined by the compiler. See also: http://bugs.freepascal.org/view.php?id=15480 You can take a look on this container lib, which might be helpful for your task: http://code.google.com/p/fprb/wiki/heContnrs -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Moving callbackfunctions to class
2010/12/30 Darius Blaszyk : > Though I understand the error, I do not know if there is a way to circumvent > this? I guess: In the callback you have to get the current window id using glutGetWindow, then dispatch the call to the right object instance using that id via some kind of mapping from window ids to instances. cf: "Before the callback, the current window is set to the window needing to be redisplayed...", src: http://www.opengl.org/resources/libraries/glut/spec3/node46.html -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] commutative operators
2010/12/29 David Emerson : > On Wed 29 Dec 2010, Honza wrote: >> IIRC you don't have to. > > well... I do have to. I get "can't determine which overloaded function to > call" > because I have a lot of similar-looking functions and := operators You're right, I verified it just now. I didn't remembered it correctly. FYI, bellow is the verification example used, later modified to compile successfully with trunk FPC. Introduction of the ':=' operators for T1 and T2 enabled the '+' operator commutativity. program project1; {$mode objfpc}{$H+} type T1 = record Dummy: Boolean; Value: Integer; end; T2 = record Dummy: String; Value: Integer; end; operator +(A: T1; B: T2): Integer; begin Result := A.Value + B.Value; end; operator :=(X: T1): T2; begin Result.Value := X.Value end; operator :=(X: T2): T1; begin Result.Value := X.Value end; var V1: T1; V2: T2; begin V1.Value := 2; V2.Value := 3; Writeln(V1 + V2, ' ', V2 + V1); end. -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] commutative operators
2010/12/29 David Emerson : > suppose I define an operator: > > operator + (a: one_type; b: another_type) : one_type; > > Is there any way to specify that it should be "commutative", so I don't have > to > additionally define the reverse: > > operator + (a: another_type; b: one_type) : one_type; IIRC you don't have to. -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] generics class hierarchy
2010/12/19 Sven Barth : > While I DO agree with you (after some thinking about the consequences) that > a base class should not be allowed to be specified by a template parameter > (and this is the way it already is), I don't agree with you that the > documentation states this as clearly as you propose it. I admit, that it looks clear to me only now - after/because of several hours bouncing my head against the keyboard when I struggled to get generics make what I wanted, so I'm not anymore unbiased when looking at the docs :-) > Here the documentation of generics should state more clearly that "class(T)" > is not allowed, neither in the main class nor in sub classes. I believe any reasonable improvement patch of the docs would be welcome by the dev team. You can then get into the chapter text exactly those words you would like to read there - a nice compensation for a little effort I think :-) Best regards, -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] generics class hierarchy
2010/12/19 David Emerson : Please see my just sent reply to Sven. -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] generics class hierarchy
2010/12/19 Sven Barth : >> "There is a single placeholder _T. It will be substituted by a type >> identifier when the generic class is specialized. The identifier _T >> *may not be used for anything else than a placehoder*. " >> > > According to the documentation I'd say that it should succeed, because in > "class(BaseClass)" "BaseClass" is a type identifier. But of course that has > its own set of problems... see the second last paragraph of this mail. The type parameter in the inheritance part clause, i.e. class(T) part of the generic class declaration has nothing to do with the placeholder formal parameter. The placeholder formal arg list are given inside the sharp brackets <> as a kind of macro parameters. And the docs explicitly states that a placeholder identifier may not be used elsewhere in the generic declaration except for identifying the place where the "macro" expansion should substitute the instantiation/specialization parameter. So using it in the inheritance clause is invalid. IMO the docs are clear on this and my experiments seems to confirm this behaviour. I have excersised generics a lot to get heLib compiled and working. Still the latest changes in the compiler broke the published code as I realized very recently and not yet uploaded the remedy which sits on my local disk. >> The bold part is IMO violated by the declaration. Anyway, it could be >> perhaps (not tested) written as: >> >> type >> TBoxProxy = class(_t_point); >> generic gt_box<_t_point, _num> = class(TBoxProxy) >> f_width, f_height : _num; >> end; >> > > No, this won't work, because "_t_point" won't be defined when "TBoxProxy" is > parsed. Yes it's not defined and that was my 3rd note, you can't base a generic declaration on a not yet specialized ancestor. >> Another strange point is, that the declaration of gt_box doesn't use >> the formal specialization paramater `_t_point` at all (in the posted >> code), so the same the other way around should also work: > It IS used, because David wants to influence the class the generic class > gt_box inherits from when specializing the class. It is not used *anywhere except* in the invalid place of the ancestor type. > type > TIntPoint = class > x, y: Integer; > end; > > TFloatPoint = class > x, y: Single; > end; > > generic gt_box<_t_point, _num> = class(_t_point) > width, height: _num; > end; > > TFloatBox = specialize gt_box; > TIntBox = specialize gt_box; > >> type >> generic gt_box<_num> = class<_t_point> >> f_width, f_height : _num; >> end; >> > > This won't compile because of the "<...>" around "_t_point". Also it's not > what Daniel intends. Yes, that's just a typo, round parenthesis are what I've meant and should wrote there. >> A 3rd note is that your code can't compile as _t_point is not declared >> when gt_box is declared, but the declaration wants to inherit from >> _t_point, so IMO also for this the code is rightfully rejected the >> compiler. > > The question is whether this should be rejected if "_t_point" is a template > parameter... on the other hand this would violate compile time checks of the > generic class... > > I'm still thinking how David's idea could be achieved in another way which > is supported by the compiler... I've not yet got time to look at his goal at all, so I don't know. I just spotted the invalid constructs presented. -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] generics class hierarchy
2010/12/19 David Emerson : > type > generic gt_box<_t_point,_num> = class (_t_point) // FAILS :-( > f_width, f_height : _num; > end; I think it should fail according to the docs, see: http://www.freepascal.org/docs-html/ref/refse42.html "There is a single placeholder _T. It will be substituted by a type identifier when the generic class is specialized. The identifier _T *may not be used for anything else than a placehoder*. " The bold part is IMO violated by the declaration. Anyway, it could be perhaps (not tested) written as: type TBoxProxy = class(_t_point); generic gt_box<_t_point, _num> = class(TBoxProxy) f_width, f_height : _num; end; Another strange point is, that the declaration of gt_box doesn't use the formal specialization paramater `_t_point` at all (in the posted code), so the same the other way around should also work: type generic gt_box<_num> = class<_t_point> f_width, f_height : _num; end; A 3rd note is that your code can't compile as _t_point is not declared when gt_box is declared, but the declaration wants to inherit from _t_point, so IMO also for this the code is rightfully rejected the compiler. HTH -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Initialize/Finalize with count, is it possible?
2010/11/20 Max Vlasov : > FillChar(Section^, Count*ElementSize, 0); > Initialize(TNameValueRec(Section^), Count); > > Is possible for such syntax to be supported? Probably I'm one of those rare > developer using it, and maybe because of this I just have to make some patch > by myself, suggesting the result to be committed :). Please let me know if > it's possible. Why to patch the language when a for loop can do the same as above? -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Widestring Questions
2010/10/26 Tobias Giesen : > I think the problem might be that Widestring reference counting is not > thread safe. But it worked fine in FPC 2.2. A bug may show anytime anywhere, but the built in ref counted string types are AFAIK thread safe what concerns the ref count per se. I suspect a subtle flaw in the client code is more probable. -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] IntList
2010/10/19 Brian Winfrey : > Take a look at http://code.google.com/p/fprb/. I have just perused > it, but it looks pretty good. I'm willing to cooperate (as free time permits) on any required FPRB/heLib review/modification process would any part(s) of the code be considered/adopted by the dev team, including but not limited to (re)releasing the code under a FCL compatible license (currently New BSD). Just let me know if/what is necessary. -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Optimized matrix multiplication functions for pascal?
2010/10/9 Bo Berglund : > So I need to get hold of two Delphi functions: > > function matmul(X, Y: array of double): array of double; > and > function transpose(X: array of double): array of double; > > Where can I find such functions? > I am not a matematician myself so I don't know what these > functions really do... The machinery is depicted e.g. here: http://en.wikipedia.org/wiki/Matrix_multiplication http://en.wikipedia.org/wiki/Matrix_transpose IMO it's not really tough to implement them in FPC. -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TFileStream and stdin - how to make this work?
2010/10/3 Bernd Kreuss : > TIOStream seems to work the same way on linux and windows (I tested only > with wine but it worked) ...and it will block. > > It seems I really have to do the receiving of the data in a separate > thread. > > (I wanted to avoid this because the things that must be done after > reading the data must be done in the main thread (it's a GUI > application) and now I have to fiddle around with synchronize & friends > instead of a simple method call which is not nice because I also have to > immediately answer the messages on stdout in a synchronous manner with > information received from the GUI. Polling on idle from the GUI thread > would have been so much more simple and elegant.) See also sockets: http://wiki.lazarus.freepascal.org/Sockets and pipes: http://www.freepascal.org/docs-html/fcl/pipes/tinputpipestream.html The TInputPipeStream has a "property NumBytesAvailable: DWord; [r] Number of bytes available for reading.", which may enable the polling. -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TFileStream and stdin - how to make this work?
2010/10/3 Bernd Kreuss : > this might be a stupid question but I find myself again struggling with > file IO and stdin/stdout. I am trying to do the following: > > StdIn := TFileStream.Create('/dev/stdin', fmOpenRead); > > and later on i want to poll whether there is something to read. I want > to try reading binary data that will be piped to my application and i > need to poll (non blocking!) and in case of incoming data read the first > byte to determine the type of message that has arrived and then read the > rest. > > The Stream seems to be able to read when there is something to read on > stdin but I cannot find any way to actually test whether the ReadByte() > will block (nothing to read) or whether there is data available. > > the properties size and position both are always $ and > the stream has no eof property. > > Can this be done at all? And is my way of opening the stream correct? > What would be a more platform independent way of opening the stdin as a > stream to read binary data or is there a different and better way to do > this, maybe a stream is not the correct thing for this at all? How do I > poll and read binary data from stdin? I don't think it's possible to succeed in this using TFileStream. Additionally, the stdin thing on *nix is IMO designed to be normally used in a blocking manner. OTOH, it's likely, that on *nix you can find some syscall/libc functionality, which will provide the "file descriptor is ready for reading" information. But you asked for platform independence and I don't know much about Windows. Neither if there is or is not something like that being cross platform somewhere in the RTL/FCL already. -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Build scripts for Freepascal and Lazarus compilation from source
2010/10/3 Frank Church : > I have posted an article and some code on some bash scripts I have developed > to install FPC and Lazarus from source at > http://devblog.brahmancreations.com/content/build-scripts-for-installing-freepascal-and-lazarus-from-source. > > Any comments and tips are well come. Oops: Access denied You are not authorized to access this page. -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How to get to Range Check Error location
2010/10/2 Juha Manninen (gmail) : Hi Juha, I just tried and can confirm that a LCL app running inside Lazarus (r27491), having turned on range checks is able to perfectly catch and show the place of an range check error (Ubuntu 10.04/AMD64). What I've not tried, but suggest to try, is to open the Lazarus project in Lazarus and run it as the tes app I'm talking above. Maybe then it will show nicely also the range check error sources in Lazarus itself. HTH PS: The test app main form unit source unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls; type { TForm1 } TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private F: Byte; public { public declarations } end; var Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject); begin F := F + 1; end; procedure TForm1.FormCreate(Sender: TObject); begin F := High(F); end; end. -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Initializing records and other complicated structures
2010/9/27 Jim : > Fpc sometimes complains (hints) about local variables not being initialized. > My question: how do I initialize more complicated structures like > records? And should I need to (I'm guessing no in the example below, but > the contents of the record will be undefined - no problem as there are > no pointers/strings in there)? > > Example: > > Type > TIfdTag = packed Record > ID: word; > //Tag number > Typ: word; > //Type tag > Count: cardinal; > //tag length > Offset: cardinal; > //Offset / Value > End; > > Var > tag: TIfdTag; > > in code somewhere > ReadTag(tag); > > As TIfdTag seems to contain non-pointer records only, I thought I could > use Sizeof and tried this: > FillByte(tag, SizeOf(tag), 0); //initialize var. > The compiler warning doesn't go away though. > > Is this the recommended way of doing things? There is not enough code shown to say much. If the ReadTag procedure is declared with a presumably var paramater of type TIfdTag then the compiler warning is OK if the passed record has not been initialized in any way. In such case it may/should help to change the 'var' paramater to an 'out' parameter to explicitly tell the compiler that there is nothing going into ReadTag but only the other way. HTH -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Is Delphi7 on Windows to FPC on embedded Linux possible?
2010/9/25 Bo Berglund : > So then I found FPC and now I am looking for advice concerning if it would be > possible to use FPC/Lazarus to program for an embedded Linux board with a > graphics LCD screen. I want to be able to do the following: > > 1) Communicate via RS232 to the equipment core to control it and retrieve > data. We already have a serial interface protocol for sending and retrieving > data and commands, which would be the gateway into the core. So the first > question is if there exists some class/component in FPC that can be used to > communicate. > > 2) Display control screens in a GUI way with standard controls (buttons, text > boxes, radio buttons etc). This would be the new user interface for the > instrument. > > 3) Display data graphically (curves, pie charts etc). We need to improve on > the on-board datat display a lot > > 4) Store data on a file system, either SSD or flash memory. > > Can this be done? 1) I'm not aware of a ready made solution, but it quite probable exists and if not it would be probable pretty easy to write one. It's supposedly mostly a matter of getting access to/opening the right (text) device. 2) Depends. Has the embeded Linux only a frame buffer device or a X server? On X you can choose from more than one widgetset supported by FPC/Lazarus. GTK+ can AFAIK also run on bare fbdev but I don't know if the LCL/GTK does support that. 3) see 2) 4) Linux suports a broader range of filesystems than Windows, no problem expected here. > Is it possible to program on a standard Linux distribution but compile for > the embedded linux? Yes, that's what cross compiling is for. In any case, the embeded Linux CPU has to be a FPC supported one, e.g. x86, AMD64, ARM, ... and many more. > Can I even re-use my Delphi7 classes from the windows environment? Those dependent purely only on RTL/VCL and not on direct WinAPI calls have a good chance to being ported to FPC. Sometimes they will just work w/o modifications in Delphi mode. -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Questions regarding arrays
2010/9/23 Graeme Geldenhuys : > Out of interest. Do you know if dynamic array elements are in sequence > (storage area in memory) too - like static arrays? So could I do the > same as above, but instead of using a static array, use a dynamic > array, and pass the address of the first element to the C API? AFAIK yes as long as you don't break (it's possible using some wild casting) the ref counting mechanism and handle the zero length case. var V1: array [L..H] of T; V2: array of T; magic_c_function(@V1[L]); if Length(V2) <> 0 then magic_c_function(@V2[0]) else magic_c_function(nil); -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Questions regarding arrays
2010/9/22 Graeme Geldenhuys : > type > TAtomArray = array[0..0] of TAtom; > PAtomArray = ^TAtomArray; > > Now if I change TAtomArray to the follow, then my code doesn't work. :-) > > TAtomArray = array of TAtom; // a dynamic array > > So what exactly is the difference between these two? > > TAtomArray = array[0..0] of TAtom; > vs > TAtomArray = array of TAtom; > > > Is array[0..0] not actually a dynamic array, but just a static array > with a single item? If so, then why does the returned value from the C > API call, which returns a pointer to an array of culong's (normally > more that one item) work? Somewhere I'm getting confused with all > this, but would love to understand it correctly, and why it works. :) > In brief AFAIK: type T1 = array[l..h] of T3; T2 = array of T3; says that T1 is a value type and T2 is a pointer type (ptr casted deref of a T2 typed variable may(? depends on implementation) safely alias a T1 typed entity, but a pointer to a first element of a T1 value can't be safely aliased to a T2 typed entity). Additionally dynamic arrays are a compiler handled structures, the differences are similar to those between shortstrings and AnsiStrings types. -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: What is wrong with this enum and array related code
2010/9/12 Frank Church : > Does that mean that although an enum is an ordinal type, an integer cannot > be coerced into using it to index an array? IMO just cast it to the correct type (of the array index) giving the compiler a chance to accept it. -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Generic B+Trees, Lists and Vectors
With tests and documentation. Requires trunk FPC. Download: http://code.google.com/p/fprb/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Generic enumerators
Sample code for someone in need of generic containers with generic enumerators (no biz/ads there): http://freepascal-bits.blogspot.com/2010/05/sampler-generic-enumerators-for-generic.html ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] String buffer
On Tue, 9 Feb 2010 10:45:55 -0300, Fl?vio Etrusco wrote: > Some (hopefully constructive) commentaries (and then I would suggest > to add to LCL or FCL): > 1) It could be called really TStringBuffer; > 2) The 'W' methods could be called 'Append'; > 3) The GetS method could truncate the string to avoid the copy, as I > think the common use will not be Append+Read+Append+Read, but > Append+Append+...+Read... I agree in all points, even while having some more ideas on the naming. If it will be considered for FCL, then let the dev team pick identifiers of their choice and any other changes/improvements - I'll be happy to implement them if needed. On Wed, 10 Feb 2010 09:49:30 +0200 Graeme Geldenhuys wrote: > Could you explain what the advantages are of > that string buffer object compared to a standard string types like > AnsiString or TStringList? I guess some memory and/or time could be saved in certain usage patterns compared to TSTringList and String. There is now a dumb benchmark on the blog, but nobody should trust other's benchmarks :) http://freepascal-bits.blogspot.com/2010/02/string-buffer-performance.html -bflm ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] String buffer
Probably just reinventing the wheel - I was not able to quickly find a String builder/buffer elsewhere. Source code for anyone possible interested is published on a blog (no ads there, so I hope it's OK to post the link): http://freepascal-bits.blogspot.com/2010/02/simple-string-buffer.html -bflm ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Generics problem/question
Hi all. At Mantis Florian already explained, why it is not possible to provide more information in the error message. Still he meanwhile managed to make it better. I got some time to return to this and now I'm here: 17:11 myn...@tux64:~/fpc/bugreports/20100105$ cat project1.pas program project1; {$mode objfpc}{$H+} uses fgl; type TPar = record I: Integer; end; operator = (A, B: TPar): Boolean; begin Result := A.I = B.I; end; type TSpec = specialize TFPGList; begin end. 17:22 myn...@tux64:~/fpc/bugreports/20100105$ fpc project1.pas Free Pascal Compiler version 2.5.1 [2010/01/14] for x86_64 Copyright (c) 1993-2009 by Florian Klaempfl Target OS: Linux for x86-64 Compiling project1.pas Error: Operator is not overloaded: "" = "" project1.pas(24) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted Error: /home/myname/lib/fpc/2.5.1/ppcx64 returned an error exitcode (normal if you did not specify a source file to be compiled) 17:22 myn...@tux64:~/fpc/bugreports/20100105$ svn info ~/svn/fpc/trunk Path: /home/myname/svn/fpc/trunk URL: http://svn2.freepascal.org/svn/fpc/trunk Repository Root: http://svn2.freepascal.org/svn/fpc Repository UUID: 3ad0048d-3df7-0310-abae-a5850022a9f2 Revision: 14633 Node Kind: directory Schedule: normal Last Changed Author: paul Last Changed Rev: 14633 Last Changed Date: 2010-01-14 09:41:27 +0100 (Čt, 14 led 2010) 17:23 myn...@tux64:~/fpc/bugreports/20100105$ I'm now able to track the source of the error message to line 715:50 of rtl/objpas/fgl.pp: 711 function TFPGList.IndexOf(const Item: T): Integer; 712 begin 713Result := 0; 714{$info TODO: fix inlining to work! InternalItems[Result]^} 715while (Result < FCount) and (PT(FList)[Result] <> Item) do 716 Inc(Result); 717if Result = FCount then 718 Result := -1; 719 end; Still I'm stuck and don't know how to use items like TPar in the specialization of TFPGList - or if it is a compiler bug. Thanks in advance for anyone's help/explanation/hint. -bflm Topic/previous messages context: http://www.mail-archive.com/fpc-pascal@lists.freepascal.org/msg18933.html Mantis issue: http://bugs.freepascal.org/view.php?id=15480 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Generics problem/question
Submitted: http://bugs.freepascal.org/view.php?id=15480 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Generics problem/question
Hi all, I tried to specialize fgl.TFPGList with some record type and got a compiler error. Am I doing something completely wrong (sorry in that case) or is this a bug? (Ubuntu 9.10, 64 bit) 22:35 myn...@tux64:~/fpc/bugreports/20100105$ cat project1.pas program project1; {$mode objfpc}{$H+} uses fgl; type TPar = record I: Integer; end; TSpec = specialize TFPGList; begin end. 22:35 myn...@tux64:~/fpc/bugreports/20100105$ fpc project1.pas Free Pascal Compiler version 2.5.1 [2010/01/05] for x86_64 Copyright (c) 1993-2009 by Florian Klaempfl Target OS: Linux for x86-64 Compiling project1.pas Error: Operator is not overloaded project1.pas(18) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted Error: /home/myname/lib/fpc/2.5.1/ppcx64 returned an error exitcode (normal if you did not specify a source file to be compiled) 22:35 myn...@tux64:~/fpc/bugreports/20100105$ svn info ~/svn/fpc/trunk/ Path: /home/myname/svn/fpc/trunk URL: http://svn2.freepascal.org/svn/fpc/trunk Repository Root: http://svn2.freepascal.org/svn/fpc Repository UUID: 3ad0048d-3df7-0310-abae-a5850022a9f2 Revision: 14549 Node Kind: directory Schedule: normal Last Changed Author: jonas Last Changed Rev: 14549 Last Changed Date: 2010-01-05 20:53:43 +0100 (Út, 05 led 2010) 22:35 myn...@tux64:~/fpc/bugreports/20100105$ Thanks in advance for any info. bflm ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal