[fpc-pascal]SQLite and NULL Strings...
Hi, This is a very weird behaviour I've found of either SQLite, or the Unit. I'm not sure... I have been discussing this same problem on the SQLite mailing list but without success there, so perhaps someone here might know... I have attached a test database, which contains 1 database entry, null strings are inserted using NULL... Check the database schema yourself. The problem therein lies in the fact that test3.pas returns for the query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; It should return a null string as it does in test2.pas and in the sqlite shell program. $ ./test2 Creating class Fields Names --- 0 - channel 1 - owner 2 - regTime 3 - state 4 - URL 5 - email 6 - channelNotice 7 - joins 8 - peak 9 - games 10 - modeLocked 11 - mailLevel 12 - restrict 13 - entries 14 - quota 15 - channelIdle 16 - noIdle 17 - lastSuspension 18 - hideAccess 19 - keepTopic 20 - onChannel 21 - opRestrict 22 - funMsg 23 - mustId 24 - tellAdd 25 - tellDel 26 - tellSet 27 - msgNotice 28 - topic 29 - topicSetter 30 - lastTopic 31 - autoCmd 32 - modes Fields --- 0 - #ProLogiTech prologic 1057934559 REGISTERED1 1 0 0 1 50 0 OFFNO YES YES NO NO NO NO NO NO NO $ ./test3 Creating class Fields Names --- 0 - channelNotice Fields --- 0 - This should be: 0 - Any ideas anyone ? The attached sqlite.pas and sqlitedb.pas were put together by Michael, myself and Eric Jourde (possibly ported from tsqlite I hear) cheers James -- - - James Mills Zero Defect Software Engineers Group - ZDSEG program test2; uses cmem, sqlite,sqlitedb, strings,classes; var MySQL: TSQLite; SQL: String; i,j : Integer; a : TStringList; begin Writeln('Creating class'); MySQL := TSQLite.Create('./channels.db'); MySQL.BusyTimeout := 1000; SQL := 'SELECT * FROM channels WHERE channel LIKE ''#ProLogiTech'';'; MySQL.Query(sql, nil); writeln('Fields Names ---'); for i:=0 to MySQL.List_FieldName.count-1 do writeln(i,' - ',MySQL.List_FieldName.Strings[i]); writeln('Fields ---'); for i:=0 to MySQL.List_Field.count-1 do begin a:=TStringList(MySQL.List_Field.items[i]); write(i,' - '); for j:=0 to a.count-1 do write(a.Strings[j],' '); writeln(''); end; // Uncomment to remove table again. // SQL := 'DROP TABLE Test;'; // MySQL.Query(sql, nil); MySQL.Free; end. program test3; uses cmem, sqlite,sqlitedb, strings,classes; var MySQL: TSQLite; SQL: String; i,j : Integer; a : TStringList; begin Writeln('Creating class'); MySQL := TSQLite.Create('./channels.db'); MySQL.BusyTimeout := 1000; SQL := 'SELECT channelNotice FROM channels WHERE channel LIKE ''#ProLogiTech'';'; MySQL.Query(sql, nil); writeln('Fields Names ---'); for i:=0 to MySQL.List_FieldName.count-1 do writeln(i,' - ',MySQL.List_FieldName.Strings[i]); writeln('Fields ---'); for i:=0 to MySQL.List_Field.count-1 do begin a:=TStringList(MySQL.List_Field.items[i]); write(i,' - '); for j:=0 to a.count-1 do write(a.Strings[j],' '); writeln(''); end; // Uncomment to remove table again. // SQL := 'DROP TABLE Test;'; // MySQL.Query(sql, nil); MySQL.Free; end. channels.db Description: Binary data {$mode objfpc} unit sqlite; interface { Automatically converted by H2Pas 0.99.15 from sqlite.h The following command line parameters were used: -S -D -p -l sqlite sqlite.h } const External_library='sqlite'; {Setup as you need} { Pointers to basic pascal types, inserted by h2pas conversion program.} Type PLongint = ^Longint; PSmallInt = ^SmallInt; PByte = ^Byte; PWord = ^Word; PDWord= ^DWord; PDouble = ^Double; PPPchar = ^ppchar; {$PACKRECORDS C} const _SQLITE_VERSION = '2.8.3'; SQLITE_ISO8859 = 1; {$ifndef win32} var sqlite_version : pchar;cvar;external; sqlite_encoding : pchar;cvar;external; {$endif} const SQLITE_OK = 0; SQLITE_ERROR = 1; SQLITE_INTERNAL = 2; SQLITE_PERM = 3; SQLITE_ABORT = 4; SQLITE_BUSY = 5; SQLITE_LOCKED = 6; SQLITE_NOMEM = 7; SQLITE_READONLY = 8; SQLITE_INTERRUPT = 9; SQLITE_IOERR = 10; SQLITE_CORRUPT= 11; SQLITE_NOTFOUND = 12; SQLITE_FULL = 13; SQLITE_CANTOPEN = 14; SQLITE_PROTOCOL = 15; SQLITE_EMPTY = 16; SQLITE_SCHEMA = 17; SQLITE_TOOBIG = 18; SQLITE_CONSTRAINT = 19; SQLITE_MISMATCH = 20; SQLITE_MISUSE = 21; SQLITE_NOLFS = 22; SQLITE_AUTH = 23; SQLITE_FORMAT = 24; SQLITE_ROW= 100; SQLITE_DONE = 101; SQLITE_COPY= 0; SQLITE_CREATE_INDEX= 1; SQLITE_CREATE_TABLE= 2; SQLITE_CREATE_TEMP_INDEX = 3;
Re: [fpc-pascal]v1.0.10 w32 release Eventlog resource not found
On Mon, 14 Jul 2003, Michael Van Canneyt wrote: Is there a search path for resources or how should this be properly fixed? The .res file should be put next to the installed .ppu file. To fix it, you can simply copy it there, but it is an error in the distribution files. (and in the Make install target) c: dir /s c:\pp\*.ppu doesn't find any files but there is a c:\pp\units\win32\fcl\eventlog.ppw, so I copied fclel.res from c:\pp\source\fcl\win32 to c:\pp\units\win32\fcl, removed fclel.res from my source directory and recompiled. Same output as before: C:\my-fpc\testing\eventlogppc386 tstelcmd.pp Hint: End of reading config file c:\pp\bin\win32\fpc.cfg Free Pascal Compiler version 1.0.10 [2003/06/27] for i386 Copyright (c) 1993-2003 by Florian Klaempfl Target OS: Win32 for i386 Compiling tstelcmd.pp syswin32.pp(9,1) Hint: Conditional I386 was set at startup in last compilation of syswin32.pp Compiling resource fclel.res c:\pp\bin\win32\windres.exe: can't open `fclel.res' for output: No such file or directory tstelcmd.pp(25,1) Error: Error while linking tstelcmd.pp(25,1) Fatal: There were 1 errors compiling module, stopping Closing script ppas.bat Mahalo, Ron ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]Strange Segfault...
Yes and no. Why is it so bad to write a function in that way ? It could of course be written two different ways, but I'd rather this way where I modify the string passed to the function. Explain it to me :) (I'm the only one that works on this project of ~30,000 LOC, so I don't see any problem) Turbo Pascal and Delphi 1 had a type called 'String'. This was limited to 255 chars, size of 256 chars, and position 0 holds the strings length. Delphi 2+ has a type called shortstring that behaves in exactly the same way as the old style string. Delphi 2+ altered the string type to be a pointer to a chunk of memory, and added a whole load of compiler magic to make strings automatically grow and shrink, added reference counting and 'copy of change' functionality (the last two to aid in not having to copy a string until someone alters it.) This is where your problem lies. Because FPC mimics Delphi string functionality, basically you'll end up with similar results. You'd be much better off Returning a value, and thereby avoiding the potential for big allocation/deallocations. That or use shortstrings. Matt ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]Can't download from US mirror
On maandag, jul 14, 2003, at 14:01 Europe/Brussels, Chuck Roberts wrote: When I try to download from the US mirror at http://www.us.freepascal.org/down-dos.html I get this error: No such file or directory. I get the same error when I try to download the win32 version of 1.0.10. That's because unlike the download mirror selection page claims, the US site still only has 1.0.6. It has the updated web pages for 1.0.10, but its ftp site still contains the 1.0.6 files. Jonas ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
RE: [fpc-pascal]Can't download from US mirror
They have on FTP old version 1.0.6 only ! CBL -Original Message- From: Chuck Roberts [mailto:[EMAIL PROTECTED] Sent: Monday, July 14, 2003 2:01 PM To: FPC-pascal Subject: [fpc-pascal]Can't download from US mirror When I try to download from the US mirror at http://www.us.freepascal.org/down-dos.html I get this error: No such file or directory. I get the same error when I try to download the win32 version of 1.0.10. Chuck ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]v1.0.10 w32 release Eventlog resource not found
On Sun, 13 Jul 2003, Ronald Fox wrote: On Mon, 14 Jul 2003, Michael Van Canneyt wrote: Is there a search path for resources or how should this be properly fixed? The .res file should be put next to the installed .ppu file. To fix it, you can simply copy it there, but it is an error in the distribution files. (and in the Make install target) c: dir /s c:\pp\*.ppu doesn't find any files but there is a c:\pp\units\win32\fcl\eventlog.ppw, so I copied fclel.res from c:\pp\source\fcl\win32 to c:\pp\units\win32\fcl, removed fclel.res from my source directory and recompiled. Same output as before: C:\my-fpc\testing\eventlogppc386 tstelcmd.pp Hint: End of reading config file c:\pp\bin\win32\fpc.cfg Free Pascal Compiler version 1.0.10 [2003/06/27] for i386 Copyright (c) 1993-2003 by Florian Klaempfl Target OS: Win32 for i386 Compiling tstelcmd.pp syswin32.pp(9,1) Hint: Conditional I386 was set at startup in last compilation of syswin32.pp Compiling resource fclel.res c:\pp\bin\win32\windres.exe: can't open `fclel.res' for output: No such file or directory tstelcmd.pp(25,1) Error: Error while linking tstelcmd.pp(25,1) Fatal: There were 1 errors compiling module, stopping In that case you'll have no choice but to copy the file to your project directory. It's a bug which will have to be fixed in the compiler. Michael. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]SQLite and NULL Strings...
On Mon, Jul 14, 2003 at 02:26:28PM +0200, Michael Van Canneyt wrote: On Mon, 14 Jul 2003, James Mills wrote: On Mon, Jul 14, 2003 at 09:59:17AM +0200, Michael Van Canneyt wrote: On Mon, 14 Jul 2003, James Mills wrote: Hi, This is a very weird behaviour I've found of either SQLite, or the Unit. I'm not sure... I have been discussing this same problem on the SQLite mailing list but without success there, so perhaps someone here might know... I have attached a test database, which contains 1 database entry, null strings are inserted using NULL... Check the database schema yourself. The problem therein lies in the fact that test3.pas returns for the query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; It should return a null string as it does in test2.pas and in the sqlite shell program. The problem is that an implicity conversion from Nil to empty string is done. You cannot solve this as long as stringlists are used to contain the data. (ok, you could set 'Null' as the string, but that is sloppy) is done. in what ? The SQLite library or TStringList ? sqlite. But you said You cannot solve this as long as stringlists are used to contain the data. This made me think it was a behaviour of TStringList ... If it truely is a behaviour of SQLite, I'll get them to change it. You'd need to have (as a minimum) an array of TField records: TField = Record IsNull : Boolean; Value : String; end; But this will require major changes, so I suggest trying to find or implement a TDataset descendent for SQLIte, this will solve most of your problems at once. How major would the changes be ? Otherwise I'll try and search for a TDataset descendent ? Couldn't I write a descendent myself ? (I've kinda of done something similar in creating a TDatabase descendant..., but it doesn't solve my problem) Implementing a TDataset descendent is not easy, it'll take you at least a week (conservative estimate). Why is this a hard thing to do ? Give me some ideas here, you might be conservative, but I don't muck around :) I'll attach my dbclass.pas a tiny desendant I wrote to simplify using queries (it's centered around making queries simpler)... cheers James Michael. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - - James Mills Zero Defect Software Engineers Group - ZDSEG unit dbClass; interface uses cMem, SQLite, SQLiteDB, Strings, Classes, Functions; type TDatabase = class(TObject) constructor Create; destructor Destroy; override; protected SQL: TSQLite; X: Integer; Y: Integer; S: TStringList; function simpleQuery(query: String): String; function complexQuery(query: String): TStringList; function multiQuery(query: String): TStringList; public end; implementation constructor TDatabase.Create; begin end; destructor TDatabase.Destroy; begin inherited Destroy; if NOT (SQL = nil) then begin SQL.Free; end; end; function TDatabase.simpleQuery(query: String): String; var tmp: String; begin tmp := query; replace('', 'NULL', tmp); writeLn('simpleQuery - ', tmp); if NOT (SQL = nil) then begin SQL.Query(tmp, nil); if (SQL.List_Field.count 0) then begin S := TStringList(SQL.List_Field.items[0]); simpleQuery := S.Strings[0]; end else begin simpleQuery := ''; end; end; end; function TDatabase.complexQuery(query: String): TStringList; var tmp: String; begin tmp := query; replace('', 'NULL', tmp); writeLn('complexQuery - ', tmp); if NOT (SQL = nil) then begin SQL.Query(tmp, nil); if (SQL.List_Field.count 0) then begin complexQuery := TStringList(SQL.List_Field.items[0]); end else begin complexQuery := TStringList.Create; end; end; end; function TDatabase.multiQuery(query: String): TStringList; var temp: String; tmp: String; I: Integer; J: Integer; strs: TStringList; begin temp := query; replace('', 'NULL', temp); writeLn('multiQuery - ', temp); if NOT (SQL = nil) then begin SQL.Query(temp, nil); if (SQL.List_Field.count 0) then begin strs := TStringList.Create; for I := 0 to (SQL.List_Field.Count - 1) do begin tmp := ''; for J := 0 to (TStringList(SQL.List_Field.Items[I]).Count - 1) do begin tmp := tmp + TStringList(SQL.List_Field.Items[I]).Strings[J] + ' '; end; tmp := copy(tmp, 1, (length(tmp) - 1)); strs.add(tmp); end; for I := 0 to (strs.Count - 1) do begin writeLn(I, ' - ', strs.Strings[I]); end; multiQuery := strs; end else begin multiQuery := TStringList.Create; end; end; end; end.
Re: [fpc-pascal]SQLite and NULL Strings...
On Mon, 14 Jul 2003, James Mills wrote: On Mon, Jul 14, 2003 at 02:26:28PM +0200, Michael Van Canneyt wrote: On Mon, 14 Jul 2003, James Mills wrote: On Mon, Jul 14, 2003 at 09:59:17AM +0200, Michael Van Canneyt wrote: On Mon, 14 Jul 2003, James Mills wrote: Hi, This is a very weird behaviour I've found of either SQLite, or the Unit. I'm not sure... I have been discussing this same problem on the SQLite mailing list but without success there, so perhaps someone here might know... I have attached a test database, which contains 1 database entry, null strings are inserted using NULL... Check the database schema yourself. The problem therein lies in the fact that test3.pas returns for the query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; It should return a null string as it does in test2.pas and in the sqlite shell program. The problem is that an implicity conversion from Nil to empty string is done. You cannot solve this as long as stringlists are used to contain the data. (ok, you could set 'Null' as the string, but that is sloppy) is done. in what ? The SQLite library or TStringList ? sqlite. But you said You cannot solve this as long as stringlists are used to contain the data. This made me think it was a behaviour of TStringList ... If it truely is a behaviour of SQLite, I'll get them to change it. The problem is that there is no way to distinguish between a 'null' and an empty string once it is converted to a string. The information is simply lost. You'd need to have (as a minimum) an array of TField records: TField = Record IsNull : Boolean; Value : String; end; But this will require major changes, so I suggest trying to find or implement a TDataset descendent for SQLIte, this will solve most of your problems at once. How major would the changes be ? Otherwise I'll try and search for a TDataset descendent ? Couldn't I write a descendent myself ? (I've kinda of done something similar in creating a TDatabase descendant..., but it doesn't solve my problem) Implementing a TDataset descendent is not easy, it'll take you at least a week (conservative estimate). Why is this a hard thing to do ? Give me some ideas here, you might be conservative, but I don't muck around :) Because TDataset is not an easy subject. You need to implement a lot of calls in a correct and predefined way. Michael. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]SQLite and NULL Strings...
On Mon, Jul 14, 2003 at 09:59:17AM +0200, Michael Van Canneyt wrote: On Mon, 14 Jul 2003, James Mills wrote: Hi, This is a very weird behaviour I've found of either SQLite, or the Unit. I'm not sure... I have been discussing this same problem on the SQLite mailing list but without success there, so perhaps someone here might know... I have attached a test database, which contains 1 database entry, null strings are inserted using NULL... Check the database schema yourself. The problem therein lies in the fact that test3.pas returns for the query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; It should return a null string as it does in test2.pas and in the sqlite shell program. The problem is that an implicity conversion from Nil to empty string is done. You cannot solve this as long as stringlists are used to contain the data. (ok, you could set 'Null' as the string, but that is sloppy) You'd need to have (as a minimum) an array of TField records: TField = Record IsNull : Boolean; Value : String; end; But this will require major changes, so I suggest trying to find or implement a TDataset descendent for SQLIte, this will solve most of your problems at once. Where might I find such a descendent that using SQLite ? I'm not quite sure what I'm looking for here... An initial search on google provides some delphi units that are probably not what I'm looking for. cheers James Michael. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - - James Mills Zero Defect Software Engineers Group - ZDSEG ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]SQLite and NULL Strings...
On Mon, 14 Jul 2003, James Mills wrote: On Mon, Jul 14, 2003 at 09:59:17AM +0200, Michael Van Canneyt wrote: On Mon, 14 Jul 2003, James Mills wrote: Hi, This is a very weird behaviour I've found of either SQLite, or the Unit. I'm not sure... I have been discussing this same problem on the SQLite mailing list but without success there, so perhaps someone here might know... I have attached a test database, which contains 1 database entry, null strings are inserted using NULL... Check the database schema yourself. The problem therein lies in the fact that test3.pas returns for the query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; It should return a null string as it does in test2.pas and in the sqlite shell program. The problem is that an implicity conversion from Nil to empty string is done. You cannot solve this as long as stringlists are used to contain the data. (ok, you could set 'Null' as the string, but that is sloppy) You'd need to have (as a minimum) an array of TField records: TField = Record IsNull : Boolean; Value : String; end; But this will require major changes, so I suggest trying to find or implement a TDataset descendent for SQLIte, this will solve most of your problems at once. Where might I find such a descendent that using SQLite ? I'm not quite sure what I'm looking for here... An initial search on google provides some delphi units that are probably not what I'm looking for. On the contrary, on Torry's pages there are some units that do exactly what I described. Michael. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]SQLite and NULL Strings...
On Mon, Jul 14, 2003 at 03:39:36PM +0200, Michael Van Canneyt wrote: On Mon, 14 Jul 2003, James Mills wrote: On Mon, Jul 14, 2003 at 09:59:17AM +0200, Michael Van Canneyt wrote: On Mon, 14 Jul 2003, James Mills wrote: Hi, This is a very weird behaviour I've found of either SQLite, or the Unit. I'm not sure... I have been discussing this same problem on the SQLite mailing list but without success there, so perhaps someone here might know... I have attached a test database, which contains 1 database entry, null strings are inserted using NULL... Check the database schema yourself. The problem therein lies in the fact that test3.pas returns for the query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; It should return a null string as it does in test2.pas and in the sqlite shell program. The problem is that an implicity conversion from Nil to empty string is done. You cannot solve this as long as stringlists are used to contain the data. (ok, you could set 'Null' as the string, but that is sloppy) You'd need to have (as a minimum) an array of TField records: TField = Record IsNull : Boolean; Value : String; end; But this will require major changes, so I suggest trying to find or implement a TDataset descendent for SQLIte, this will solve most of your problems at once. Where might I find such a descendent that using SQLite ? I'm not quite sure what I'm looking for here... An initial search on google provides some delphi units that are probably not what I'm looking for. On the contrary, on Torry's pages there are some units that do exactly what I described. Ok thanks. I had searched for TDataset descendant sqlite pascal one page came up from Torry's pages. *hits Mozilla, it crashes too much :P* cheers James Michael. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - - James Mills Zero Defect Software Engineers Group - ZDSEG ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]Strange Segfault...
On Mon, Jul 14, 2003 at 06:48:06AM -0700, Alan Mead wrote: I'm running into this string problem as well. I'd like to use strings longer than 255 but I get strange errors like: [EMAIL PROTECTED] seq-bayes]$ fpc mcmc3pl.pas Free Pascal Compiler version 1.0.6 [2002/05/23] for i386 Copyright (c) 1993-2002 by Florian Klaempfl Target OS: Linux for i386 Compiling mcmc3pl.pas Assembling mcmc3pl Linking mcmc3pl mcmc3pl.o: In function `_READ_CONFIG$INTEGER$INTEGER$STRING$STRING': mcmc3pl.o(.text+0x147): undefined reference to `FPC_READ_TEXT_LONGSTR' mcmc3pl.o(.text+0x17c): undefined reference to `FPC_VAL_SINT_LONGSTR' mcmc3pl.o(.text+0x243): undefined reference to `FPC_READ_TEXT_LONGSTR' mcmc3pl.o(.text+0x278): undefined reference to `FPC_VAL_SINT_LONGSTR' mcmc3pl.pas(215) Error: Error while linking Closing script ppas.sh [EMAIL PROTECTED] seq-bayes]$ fpc test_string500 Free Pascal Compiler version 1.0.6 [2002/05/23] for i386 Copyright (c) 1993-2002 by Florian Klaempfl Target OS: Linux for i386 Compiling test_string500.pas test_string500.pas(15,13) Fatal: Internal error These errors disappear when I edit the string definitions back to length 255 or less. Should I just avoid using longer strings or is there a compiler switch I have to include? Or is there a tutorial on FPC strings (I never used Delphi much)? Or is this behavior fixed in 1.0.10? I believe there is a compiler switch. cheers James -Alan --- Matt Emson [EMAIL PROTECTED] wrote: Yes and no. Why is it so bad to write a function in that way ? It could of course be written two different ways, but I'd rather this way where I modify the string passed to the function. Explain it to me :) (I'm the only one that works on this project of ~30,000 LOC, so I don't see any problem) Turbo Pascal and Delphi 1 had a type called 'String'. This was limited to 255 chars, size of 256 chars, and position 0 holds the strings length. Delphi 2+ has a type called shortstring that behaves in exactly the same way as the old style string. Delphi 2+ altered the string type to be a pointer to a chunk of memory, and added a whole load of compiler magic to make strings automatically grow and shrink, added reference counting and 'copy of change' functionality (the last two to aid in not having to copy a string until someone alters it.) This is where your problem lies. Because FPC mimics Delphi string functionality, basically you'll end up with similar results. You'd be much better off Returning a value, and thereby avoiding the potential for big allocation/deallocations. That or use shortstrings. Matt ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - - James Mills Zero Defect Software Engineers Group - ZDSEG ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal]SQLite and NULL Strings...
On Mon, Jul 14, 2003 at 03:06:44PM +0200, Michael Van Canneyt wrote: On Mon, 14 Jul 2003, James Mills wrote: On Mon, Jul 14, 2003 at 02:26:28PM +0200, Michael Van Canneyt wrote: On Mon, 14 Jul 2003, James Mills wrote: On Mon, Jul 14, 2003 at 09:59:17AM +0200, Michael Van Canneyt wrote: On Mon, 14 Jul 2003, James Mills wrote: Hi, This is a very weird behaviour I've found of either SQLite, or the Unit. I'm not sure... I have been discussing this same problem on the SQLite mailing list but without success there, so perhaps someone here might know... I have attached a test database, which contains 1 database entry, null strings are inserted using NULL... Check the database schema yourself. The problem therein lies in the fact that test3.pas returns for the query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; It should return a null string as it does in test2.pas and in the sqlite shell program. The problem is that an implicity conversion from Nil to empty string is done. You cannot solve this as long as stringlists are used to contain the data. (ok, you could set 'Null' as the string, but that is sloppy) is done. in what ? The SQLite library or TStringList ? sqlite. But you said You cannot solve this as long as stringlists are used to contain the data. This made me think it was a behaviour of TStringList ... If it truely is a behaviour of SQLite, I'll get them to change it. The problem is that there is no way to distinguish between a 'null' and an empty string once it is converted to a string. The information is simply lost. Just reconfirming with you and solidifying my knowledge. The reason it returns is because: when working with native pascal types, assigning null to a string results in an empty string right ? cheers James You'd need to have (as a minimum) an array of TField records: TField = Record IsNull : Boolean; Value : String; end; But this will require major changes, so I suggest trying to find or implement a TDataset descendent for SQLIte, this will solve most of your problems at once. How major would the changes be ? Otherwise I'll try and search for a TDataset descendent ? Couldn't I write a descendent myself ? (I've kinda of done something similar in creating a TDatabase descendant..., but it doesn't solve my problem) Implementing a TDataset descendent is not easy, it'll take you at least a week (conservative estimate). Why is this a hard thing to do ? Give me some ideas here, you might be conservative, but I don't muck around :) Because TDataset is not an easy subject. You need to implement a lot of calls in a correct and predefined way. Michael. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- - - James Mills Zero Defect Software Engineers Group - ZDSEG ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: Internal error 8888 (was Re: [fpc-pascal]Strange Segfault...)
On maandag, jul 14, 2003, at 20:31 Europe/Brussels, Alan Mead wrote: If there is, I cannot find it. {$H} does nothing and I re-read the portion of the docs that deal with the sting types again and I don't see what I'm doing wrong. There is a difference between longstrings and ansistrings. Ansistrings are fully supported, but longstrings (which is what you are using) aren't. To use ansistrings, either use {$h+} and declare your variable as string (i.e., without [lenght]), or use ansistring as type. Jonas ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: Internal error 8888 (was Re: [fpc-pascal]Strange Segfault...)
On Mon, 14 Jul 2003, Alan Mead wrote: --- James Mills [EMAIL PROTECTED] wrote: On Mon, Jul 14, 2003 at 06:48:06AM -0700, Alan Mead wrote: I'm running into this string problem as well. I'd like to use strings longer than 255 but I get strange errors like: [...] I believe there is a compiler switch. If there is, I cannot find it. {$H} does nothing and I re-read the portion of the docs that deal with the sting types again and I don't see what I'm doing wrong. {$H+} or {$H-} definitely works. If I declare stmp: ansiString; then the executable compiles and links fine but the strings don't actually work. For example, I readln(txt,stmp); and stmp only receives the first 255 columns of the file. what version are you using ? Michael. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal]Compiler bug?
Hi, the following code results in a error. program compiler_bug_1; {$mode objfpc} var a,b: integer; c,d,e,f: boolean; function Ok: boolean; begin result := ( a = b ) and c = d and e = f; end; var r: boolean; begin a := 1; b := 2; c := false; d := true; e := false; f := true; r := Ok; end. here is the output Free Pascal Compiler version 1.1 [2003/07/11] for i386 Copyright (c) 1993-2002 by Florian Klaempfl Target OS: Linux for i386 Compiling tst.pas tst.pas(15,2) Note: Local variable r is assigned but never used tst.pas(11,7) Error: Asm: Duplicate label .L3 tst.pas(10,9) Error: Asm: Duplicate label .L4 tst.pas(25,1) Fatal: There were 2 errors compiling module, stopping Regards. Jesus Reyes A. _ Do You Yahoo!? La mejor conexión a internet y 25MB extra a tu correo por $100 al mes. http://net.yahoo.com.mx ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: Internal error 8888 (was Re: [fpc-pascal]Strange Segfault...)
--- [EMAIL PROTECTED] wrote: {$H+} or {$H-} definitely works. Sorry, by does nothing I meant that it does nothing to solve my problems with strings. Of course, the fundamental problem is that I don't fully understand anything but old-fashioned TP strings. [EMAIL PROTECTED] seq-bayes]$ fpc test_string500 Free Pascal Compiler version 1.0.6 [2002/05/23] for i386 Copyright (c) 1993-2002 by Florian Klaempfl Target OS: Linux for i386 Compiling test_string500.pas test_string500.pas(21,13) Fatal: Internal error I'll upgrade to 1.0.10 soon ... so if that solves this problem, great. -Alan __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com{$H+} program test; const LEN = 500; type string500 = ansistring; {string500 = string[LEN];} var s:string500; s2:ansistring; {s2:string[LEN];} procedure tester(s:string); var s1:string500; s2:ansistring; {s2:string[LEN];} begin s1 := 'Hello world'; s2 := s; s1 := s; end; begin s := 'Hello world'; s2 := 'Hello world'; s:= s2; s2 := s; tester(s); end.