Re: [fpc-pascal] How create a full text search with TChmWriter?
On 02/23/12 16:23, Mattias Gaertner wrote: > Now it stops earlier on my files: > > Exception at 00473837: ERangeError: > Range check error. > Backtrace does not help much: > > #0 0x004120d0 in fpc_raiseexception () > #1 0x0045fc38 in > SYSUTILS_$$_RUNERRORTOEXCEPT$LONGINT$POINTER$POINTER () > #2 0x in ?? () > > Mattias I've just discovered "info symbol x" Exception at 0053BA25: ERangeError: Range check error. [Inferior 1 (process 15556) exited normally] (gdb) bt No stack. (gdb) info symbol 0x53ba25 CHMWRITER$_$TCHMWRITER_$_APPENDBINARYINDEXFROMSITEMAP$TCHMSITEMAP$BOOLEAN_$$_PREPARECURRENTBLOCK + 197 in section .text of /usr/local/bin/fpdoc (gdb) This at least give me a hint Regards, Andrew ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] [ot] Some(paid) work to do in FreePascal
Hi, (Sorry if it's the wrong place to post that, please point my to any list best suited for that) I would like the following tool, coded in FPC for Linux 64, in command line. The usage is a proxy log scanner to automatically block "bad websites" from our proxy. I know there is ton os list, tools, etc for that but we want to block as little website as possible The binary is launched with a file as parameter 1, containing a list of URL to check (loadable by TStringList) and then will perform the following checks for each website of the list (eah check will return a score) : -whois search (There is a whois component with Indy, or you can parse the result of the whois command line) that returns domain creation, modification and expiration date, the owner and the registry (such as 1&1, godaddy, etc) -Check if the domains is listed on Google's SafeBrowse API. The check must be local, redownloading the source file if they are older than 30mn ( http://code.google.com/intl/fr/apis/safebrowsing/developers_guide_v2.html ) -Count the number of links on the webpage, then use Adblock's list to count the hits (the idea is to get the % of ads in the webpage), the regexp tool of FPC should work -Perform a check on a DNSBL ( http://www.spamhaus.org/dbl/ ) If you are interested please contact me with a price proposal Thanks, John ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: RE : RE : RE : [fpc-pascal] Re: Variant vs Pointer
In our previous episode, Ludo Brands said: > When you are thinking of using JSON you can use AnsiString as the internal > format eventually adding a datatype tag to avoid conversion data loss as > much as possible. ansistring is a decimal type. This incurs a binary to decimal conversion per se (which is afaik not needed in SQL if you use parameters) > > The TParams class, AFAIK, should work well with DBMS data > > format, don't? > > > > Again, the higher precision numeric and decimal datatypes as used in fe. > Oracle are poorly supported with variants Variants or the current sqldb implementation? > If higher precision numerics,a > date/time formats, decimal points and other locale related conversions > aren't an issue for you, and if you don't want strict compile time type > checking, please do use variants. Btw, there is a third route if you don't like stringly typing. In a past job I had a "import" app that imported the schemas from the db, transformed them (with additional lists of "exceptions") and generated pascal source code for all the associated objects and collections and the queries to load/store them. For really big jobs with a lot of exceptions (e.g. homegrown database layouts that are determined externally) this can be a great solution. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: RE : RE : RE : [fpc-pascal] Re: Variant vs Pointer
On Sat, Mar 3, 2012 at 1:20 PM, Ludo Brands wrote: >> > Or define an internal storage format and convert the >> different types >> > to that format. That is also what variants are doing. The >> difference >> > is that variants have pre-defined assignment routines and >> conversions >> > between the different variant types which don't always fit what you >> > want (date formats, decimal points, precision, characters >> set, etc.). >> > Assign fe. 1.2 to a variant and it will store it as a >> double while you >> > perhaps meant a 32 digit precision numeric value. >> >> I'm thinking to use JSON (TJSONData and subclasses) or at >> least the same idea. Could you give an example to use a >> internal storage format? Do you talk about Pointer and conversions? >> > > When you are thinking of using JSON you can use AnsiString as the internal > format eventually adding a datatype tag to avoid conversion data loss as > much as possible. > I have never used TJSONData before but used a homebrewn json implementation > to transfer arbitrary database data. Well, if I will use JSON, I can use TJSONData for this job because it have all conversions types were implemented. >> >> If Variant is so bad, why TParam is implemented using it? >> >> >> > >> > That is a very good question. Delphi compatibility is probably the >> > answer. >> > >> > Just look at the VarFmtBCD custom variant format created to fit the >> > higher precision numeric data types and all the >> difficulties to get it >> > right. >> > >> > Ludo >> >> Well, TParams in Delphi works fine. >> My new class will works with DBMS data format (integer, >> varchar, etc) very similar with TParams (I inherited of >> TParams, at the moment) with more functionalities. >> >> The TParams class, AFAIK, should work well with DBMS data >> format, don't? >> > > Again, the higher precision numeric and decimal datatypes as used in fe. > Oracle are poorly supported with variants. If higher precision numerics, > date/time formats, decimal points and other locale related conversions > aren't an issue for you, and if you don't want strict compile time type > checking, please do use variants. Thanks for these tips. I will use the JSON implementation in fpjson unit. Marcos Douglas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
RE : RE : RE : [fpc-pascal] Re: Variant vs Pointer
> > Or define an internal storage format and convert the > different types > > to that format. That is also what variants are doing. The > difference > > is that variants have pre-defined assignment routines and > conversions > > between the different variant types which don't always fit what you > > want (date formats, decimal points, precision, characters > set, etc.). > > Assign fe. 1.2 to a variant and it will store it as a > double while you > > perhaps meant a 32 digit precision numeric value. > > I'm thinking to use JSON (TJSONData and subclasses) or at > least the same idea. Could you give an example to use a > internal storage format? Do you talk about Pointer and conversions? > When you are thinking of using JSON you can use AnsiString as the internal format eventually adding a datatype tag to avoid conversion data loss as much as possible. I have never used TJSONData before but used a homebrewn json implementation to transfer arbitrary database data. > >> If Variant is so bad, why TParam is implemented using it? > >> > > > > That is a very good question. Delphi compatibility is probably the > > answer. > > > > Just look at the VarFmtBCD custom variant format created to fit the > > higher precision numeric data types and all the > difficulties to get it > > right. > > > > Ludo > > Well, TParams in Delphi works fine. > My new class will works with DBMS data format (integer, > varchar, etc) very similar with TParams (I inherited of > TParams, at the moment) with more functionalities. > > The TParams class, AFAIK, should work well with DBMS data > format, don't? > Again, the higher precision numeric and decimal datatypes as used in fe. Oracle are poorly supported with variants. If higher precision numerics, date/time formats, decimal points and other locale related conversions aren't an issue for you, and if you don't want strict compile time type checking, please do use variants. Ludo ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: RE : [fpc-pascal] Re: Variant vs Pointer
On Sat, Mar 3, 2012 at 12:57 PM, silvioprog wrote: > 2012/3/3 Luiz Americo Pereira Camara : >> On 3/3/2012 10:08, Marcos Douglas wrote: >>> >>> Think in my class like a Business Object. >>> The struct is very similar with TParams it has many TParam. The data, >>> in a TParam, is save in a Variant type. >>> I need something like: >>> u := TmyBO.Create; // the name does matter >>> u.Attr['name'].Value := 'Marcos'; // an instance is created and the >>> name is 'name' and the type is string >> >> TJSONObject (unit fpjson) does exactly that >> >> I use this way extensively >> >> Luiz > > Me too. TJSONObject is very nice. Please see Fields and Params in: > > https://github.com/silvioprog/lazwebsolutions/blob/master/Core/LWSCGI.pas > > In my personal tests I noticed that TJSONObject is very fast. Thanks Luiz and Silvio. If I will implement using subclasses for each type, I think this is a good choice for now. But I'm still curious about the Ludo's implementation. Marcos Douglas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: RE : [fpc-pascal] Re: Variant vs Pointer
2012/3/3 Luiz Americo Pereira Camara : > On 3/3/2012 10:08, Marcos Douglas wrote: >> >> Think in my class like a Business Object. >> The struct is very similar with TParams it has many TParam. The data, >> in a TParam, is save in a Variant type. >> I need something like: >> u := TmyBO.Create; // the name does matter >> u.Attr['name'].Value := 'Marcos'; // an instance is created and the >> name is 'name' and the type is string > > TJSONObject (unit fpjson) does exactly that > > I use this way extensively > > Luiz Me too. TJSONObject is very nice. Please see Fields and Params in: https://github.com/silvioprog/lazwebsolutions/blob/master/Core/LWSCGI.pas In my personal tests I noticed that TJSONObject is very fast. -- Silvio Clécio Site - LazSolutions - ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: RE : [fpc-pascal] Re: Variant vs Pointer
On 3/3/2012 10:08, Marcos Douglas wrote: Think in my class like a Business Object. The struct is very similar with TParams it has many TParam. The data, in a TParam, is save in a Variant type. I need something like: u := TmyBO.Create; // the name does matter u.Attr['name'].Value := 'Marcos'; // an instance is created and the name is 'name' and the type is string TJSONObject (unit fpjson) does exactly that I use this way extensively Luiz ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: RE : RE : [fpc-pascal] Re: Variant vs Pointer
On Sat, Mar 3, 2012 at 11:52 AM, Ludo Brands wrote: >> >> Think in my class like a Business Object. >> The struct is very similar with TParams it has many TParam. The data, >> in a TParam, is save in a Variant type. >> I need something like: >> u := TmyBO.Create; // the name does matter >> u.Attr['name'].Value := 'Marcos'; // an instance is created and the >> name is 'name' and the type is string >> >> The attributes are created on demand and the data is saved into a >> Variant, like TParam. >> If I do not use a Variant, I need to create one class to each type >> that I will use, right? >> > > Or define an internal storage format and convert the different types to that > format. That is also what variants are doing. The difference is that > variants have pre-defined assignment routines and conversions between the > different variant types which don't always fit what you want (date formats, > decimal points, precision, characters set, etc.). Assign fe. 1.2 to a > variant and it will store it as a double while you perhaps meant a 32 digit > precision numeric value. I'm thinking to use JSON (TJSONData and subclasses) or at least the same idea. Could you give an example to use a internal storage format? Do you talk about Pointer and conversions? >> If Variant is so bad, why TParam is implemented using it? >> > > That is a very good question. Delphi compatibility is probably the answer. > > Just look at the VarFmtBCD custom variant format created to fit the higher > precision numeric data types and all the difficulties to get it right. > > Ludo Well, TParams in Delphi works fine. My new class will works with DBMS data format (integer, varchar, etc) very similar with TParams (I inherited of TParams, at the moment) with more functionalities. The TParams class, AFAIK, should work well with DBMS data format, don't? Marcos Douglas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
RE : RE : [fpc-pascal] Re: Variant vs Pointer
> > Think in my class like a Business Object. > The struct is very similar with TParams it has many TParam. The data, > in a TParam, is save in a Variant type. > I need something like: > u := TmyBO.Create; // the name does matter > u.Attr['name'].Value := 'Marcos'; // an instance is created and the > name is 'name' and the type is string > > The attributes are created on demand and the data is saved into a > Variant, like TParam. > If I do not use a Variant, I need to create one class to each type > that I will use, right? > Or define an internal storage format and convert the different types to that format. That is also what variants are doing. The difference is that variants have pre-defined assignment routines and conversions between the different variant types which don't always fit what you want (date formats, decimal points, precision, characters set, etc.). Assign fe. 1.2 to a variant and it will store it as a double while you perhaps meant a 32 digit precision numeric value. > If Variant is so bad, why TParam is implemented using it? > That is a very good question. Delphi compatibility is probably the answer. Just look at the VarFmtBCD custom variant format created to fit the higher precision numeric data types and all the difficulties to get it right. Ludo ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Variant vs Pointer
On Sat, Mar 3, 2012 at 9:25 AM, Alberto Narduzzi wrote: >>> The reason for using a buffer in tdataset is that a record's data >>> normally >>> is located in one continuous buffer, from which a value is picked from >>> the >>> right spot (including strings) You can't have that with variants. >> >> >> Hm... right. >> So, if I will have a class like a TParam, that have FValue: Variant >> attribute, Would you change the implementation to not use Variant? > > > your class could use whatever you want, of course, but the overhead of the > Variant (a silly invention, IMHO, most probably MS related...) isn't worth. > Your programs, more or less, will always know what data they are working > with, hence you'll be safe and satisfied enough with the TField interface. > Don't generalize if there isn't actually any need for it. > > I may be wrong, of course, but I strongly doubt it... ;-) > > Just my 2c > > > Cheers, A. Well, if I won't generalize I need to create one class for each type, like TField does, but saving the data in a especific type variable. I would like to avoid it but... Marcos Douglas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: RE : [fpc-pascal] Re: Variant vs Pointer
On Sat, Mar 3, 2012 at 3:26 AM, Ludo Brands wrote: >> >> I need implements a similar structure but I need know if >> the use of >> >> Variant have very cost. >> > >> > >> > It has a cost. >> > >> > The reason for using a buffer in tdataset is that a record's data >> > normally is located in one continuous buffer, from which a value is >> > picked from the right spot (including strings) You can't have that >> > with variants. >> >> Hm... right. >> So, if I will have a class like a TParam, that have FValue: >> Variant attribute, Would you change the implementation to not >> use Variant? >> > > Not sure what you want to do but as Michael explained, the internal format > in tdataset is very much linked to the source of the data. Databases don't > understand pascal variants. They use only strictly typed data on the wire. > Using a variant as an internal format would only introduce overhead and > eventually data loss (fe. precision on decimals) without any gain. The > TField variant properties should be considered a convenience only and be > avoided as much as possible. > > If your new class has no links with the outside world you can use whatever > you want. Think in my class like a Business Object. The struct is very similar with TParams it has many TParam. The data, in a TParam, is save in a Variant type. I need something like: u := TmyBO.Create; // the name does matter u.Attr['name'].Value := 'Marcos'; // an instance is created and the name is 'name' and the type is string The attributes are created on demand and the data is saved into a Variant, like TParam. If I do not use a Variant, I need to create one class to each type that I will use, right? If Variant is so bad, why TParam is implemented using it? Marcos Douglas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Variant vs Pointer
The reason for using a buffer in tdataset is that a record's data normally is located in one continuous buffer, from which a value is picked from the right spot (including strings) You can't have that with variants. Hm... right. So, if I will have a class like a TParam, that have FValue: Variant attribute, Would you change the implementation to not use Variant? your class could use whatever you want, of course, but the overhead of the Variant (a silly invention, IMHO, most probably MS related...) isn't worth. Your programs, more or less, will always know what data they are working with, hence you'll be safe and satisfied enough with the TField interface. Don't generalize if there isn't actually any need for it. I may be wrong, of course, but I strongly doubt it... ;-) Just my 2c Cheers, A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: OT: Amazing new development tools
Martin wrote: On 29/02/2012 11:44, Mark Morgan Lloyd wrote: Martin wrote: Sure one *could* record *all* variables, and the callstack... But what if - you add a new variable, what to initialize it with? - remove the function that called the current code, or even delete the line where you just paused? Or one could record all input, and replay the app. But that has limits too. Neither of those are likely to happen btw on some platforms, gdb can step backwards (again limitations apply). But it's not integrated in Lazarus yet... Noting what I described looking at in http://lists.freepascal.org/lists/fpc-other/2012-February/000670.html, I found myself wondering whether the IDE could tweak (writable?) constants at runtime, or possibly closures once they exist. Being able to tune e.g. the exact position of visible components could be rather useful. The evaluate dialog, offers a way to change values. Yes it is not at all comfortable ... And be warned, it performs no checks. Trying to change managed types (string, dyn array) will almost certainly crash your app. I guess, if you have a Form you can change it's values. Only to make those thinks visible on screen, it is not enough to change them. You need to call the setter. And calling functions from the debugger is not yet there... Thanks, noted. I must admit that I've never really "got my head around" evaluation of anything other than simple variables, but I'm sure that's because I've not spent enough time really getting to grips with it. - If you work on the IDE itself try the package IdeInspector (it adds itself to "view" > "Ide Internals" if installed) Thanks, I'll make a point of looking at that, but it leads my into another question which I'll post in the Lazarus ML since I think it's out of place here. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal