Re: [fpc-pascal] Unit/library for writing data structures to files
David W Noon writes: Incidentally, from your first message in this thread, you said you were writing an OLAP application. You might care to look at PostgreSQL as a database manager. It does rather nice OLAP functionality, straight out of the box -- and it's free. Somewhat offtopic... Im a full time Postgresql DBA. Have used postgresql for 5+ years and it doesn't do so well with the very uneven data distribution the dataset I have. This is exactly why I am doing this work. I am primarily trying to experiment with some designs as proof of concepts. PostgreSQL is a general purpose DB wich does great most of the time, but I think it does not do well with very unevenly distributed data in the analytics environment at my job. Have only been in this new job for about 4 months, but so far it seems by far this is the one dataset that has given me the biggest challenge to get it to work well with Postgresql. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Pascal equivalent to split/explode commands?
Francisco Reyes-2 wrote: > > I will be reading a delimited file, usually tabs, and want to parse it > into > variables or some form of array. > You can use TStringList for that purpose. -- View this message in context: http://www.nabble.com/Pascal-equivalent-to-split-explode-commands--tp18917044p18919084.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Unit/library for writing data structures to files
On Sun, 2008-08-10 at 16:51 -0400, Francisco Reyes wrote: > Michael Van Canneyt writes: > > > You can also try the Classes unit if you use object oriented programming. > > Each component can write itself to stream. > > Played a little bit with the Classes unit. > Don't really see any benefit over justin writing records directly. > Am I missing something? > > Also when reading back, on both cases(class or directly using records) it > seems I need to use fixed length records. At least based on the examples I > have seen so far. Is there a way to save variable length records and then > read them back? Normally you write the length as a prefix before the record, typically as some kind of integer type (e.g. LongWord or TsSize). When you read the record later you read the length prefix first, then read the number of bytes that the prefix specified. As a rough and ready example: in_file := FpOpen('input_data.dat', O_RdOnly); . { Other stuff goes here. } . bytes_read := FpRead(in_file, record_len, sizeof(record_len)); bytes_read := FpRead(in_file, buf_area, record_len); Incidentally, from your first message in this thread, you said you were writing an OLAP application. You might care to look at PostgreSQL as a database manager. It does rather nice OLAP functionality, straight out of the box -- and it's free. Regards, Dave [RLU#314465] == [EMAIL PROTECTED] (David W Noon) == signature.asc Description: This is a digitally signed message part ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Pascal equivalent to split/explode commands?
Is there anything simmilar to the functions other languages have split/explode? I will be reading a delimited file, usually tabs, and want to parse it into variables or some form of array. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Unit/library for writing data structures to files
Michael Van Canneyt writes: You can also try the Classes unit if you use object oriented programming. Each component can write itself to stream. Played a little bit with the Classes unit. Don't really see any benefit over justin writing records directly. Am I missing something? Also when reading back, on both cases(class or directly using records) it seems I need to use fixed length records. At least based on the examples I have seen so far. Is there a way to save variable length records and then read them back? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access inherited^2
Hi! Am Sonntag, den 10.08.2008, 10:01 +0200 schrieb Vincent Snijders: > Johann Glaser schreef: > > Hi! > > > > How can I access an inherited inherited method which was overloaded? > > Try the following, mark the constructors as overloaded: > > > > == Example: == > > > > {$mode objfpc}{$H+} > > Program TestInherited; > > Uses Classes, SysUtils; > > > > Type > > TFirst = class > Constructor Create(A,B,C:Integer); overload; > > End; > > TSecond = class(TFirst) > Constructor Create(A,B:Integer); overload; > > End; > > TThird = class(TSecond) > Constructor Create(A,B:Integer); overload; > > End; Thanks, that really helped now. While Zaher Dirkey's hint (Mon, 4 Aug 2008 15:24:03 +0300) also helped and did it's job, it had one drawback: If TFirst.Create raised an exception, this could not by caught by TThird.Create. Even worse, it "converted" to an "Access violation" exception. I debugged this issue and found that it happend at a "call 0x30(%ecx)" instruction in TThird.Create. ECX pointed to a memory structure where address 0x30 was $. This seems very likely to be a problem with internals of FPC's handling of constructors and exceptions. Using "overload" now works like a charm. Michael, could you please add this to the documentation? Thanks Hansi ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Unit/library for writing data structures to files
On Sat, 9 Aug 2008, Francisco Reyes wrote: > I looked through the contributed units in the http://freepascal.org site and > did not see anything that could take an array or some other data structure and > write it to disk. Also the library would need to do the opposite, read from > disk into a data structure. > > I figure before I try and re-invent the wheel I would ask if there is any good > libraries/unit(s) like that already. Perhaps something simmilar to what Python > has on it's Picle library. > > Is the Objects unit what I am looking for? > In this url > http://coleweb.dc.fi.udc.es/docencia/edi/freepascal/doc/user/node10.html Not really. > I foud this description. > > objects > This unit provides the base object for standard Turbo Pascal objects. It also > implements File and Memory stream objects, as well as sorted and non-sorted > collections, and string streams. > > > File and Memory stream objects > > The application I am trying to do is a database. > I want to try some concepts for doing Analytics/OLAP work and performance will > be a concern so I figure FPC would be a good tool for the job. > > >From reading this URL > http://www.learn-programming.za.net/programming_pascal_learn11.html > > I see one can write records to a file. Would that be a feasible approach? Indeed. That's why it exists :-) You can also try the Classes unit if you use object oriented programming. Each component can write itself to stream. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Access inherited^2
Johann Glaser schreef: Hi! How can I access an inherited inherited method which was overloaded? Try the following, mark the constructors as overloaded: == Example: == {$mode objfpc}{$H+} Program TestInherited; Uses Classes, SysUtils; Type TFirst = class Constructor Create(A,B,C:Integer); overload; End; TSecond = class(TFirst) Constructor Create(A,B:Integer); overload; End; TThird = class(TSecond) Constructor Create(A,B:Integer); overload; End; Constructor TFirst.Create(A, B, C: Integer); Begin { ... } End; Constructor TSecond.Create(A, B: Integer); Begin inherited Create(A,B,0); End; Constructor TThird.Create(A, B: Integer); Begin inherited Create(A,B,0); { <-- Error: Wrong number of parameters specified for call to "Create" } End; Begin End. === The compiler complains in TThird.Create that the call to the inherited method doesn't work. Removing the word "inherited" doesn't help. What happened to the method with 3 parameters? Why is there an error message? How can I access it? The constructor with 3 parameters is hidden. Vincent ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal