[fpc-pascal] G_TYPE_STRV in Pascal?

2009-11-05 Thread Matthias Klumpp
Hello!
I currently try to implement parts of the DBUs-GLib-API in Pascal. To test
some of the functions, I need the G_TYPE G_TYPE_STRV (look here:
http://library.gnome.org/devel/gobject/unstable/gobject-Boxed-Types.html#G-TYPE-STRV--CAPS
)
Does anyone know, how to represent this type in Pascal?
E.g. G_TYPE_STRING is represented by GType(16 shl
G_TYPE_FUNDAMENTAL_SHIFT);, which is the right one for G_TYPE_STRV?
Regards
   Matthias

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] G_TYPE_STRV in Pascal?

2009-11-05 Thread Henry Vermaak
2009/11/5 Matthias Klumpp matth...@nlinux.org:
 Hello!
 I currently try to implement parts of the DBUs-GLib-API in Pascal. To test
 some of the functions, I need the G_TYPE G_TYPE_STRV (look here:
 http://library.gnome.org/devel/gobject/unstable/gobject-Boxed-Types.html#G-TYPE-STRV--CAPS
 )
 Does anyone know, how to represent this type in Pascal?
 E.g. G_TYPE_STRING is represented by GType(16 shl
 G_TYPE_FUNDAMENTAL_SHIFT);, which is the right one for G_TYPE_STRV?

Look at packages/gtk2/src/glib/gboxed.inc to see how these are
implemented (function implementation is in glib2.pas).  You can
probably add it to that file.

Henry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] conformant arrays and Free Pascal

2009-11-05 Thread Bruce Bauman
I am trying to convert a huge amount of code written in MetaWare
Professional Pascal to Free Pascal. Unfortunately, the MetaWare code
makes fairly extensive use of Pascal conformant arrays.

Free Pascal's open arrays are similar, but modifying all of the uses of
conformant arrays would be a fairly big job.

Any advice for us?

-- Bruce
CONFIDENTIALITY NOTICE: This e-mail is confidential and intended
solely for the use of the individual or entity to which it is addressed.  If
you are not the intended recipient, be advised that you have received 
this email in error and that any use, dissemination, forwarding, printing 
or copying of this e-mail is strictly prohibited. If you received this e-mail
in error, please delete it from your computer and contact the sender.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpc and Sqlite UDF

2009-11-05 Thread Luiz Americo Pereira Camara

Nataraj S Narayan escreveu:

Hi

Anybody has written custom UDF for Sqlite 3 using fpc?

If so kindly help me with some hints to get started.
  


See the attached files. It implements a custom format date function

Luiz
program testfunction;

{$Mode ObjFpc}
{$H+}
{$define DEBUGHEAP}

uses 
{$ifdef DEBUGHEAP}
  Heaptrc,
{$endif}
{$ifdef Linux}
  cmem,
{$endif}
  sqlite3ds,
  sqlite3,  
  sysutils, db, 
  inifiles;
  

procedure CustomFunction(context: PSqlite3_Context; argc: LongInt; argv: PPSqlite3_Value); cdecl;
  procedure DumpVariable(Index: Integer);
  begin
case sqlite3_value_type(argv[Index]) of
SQLITE_INTEGER:
  WriteLn('Type: SQLITE_INTEGER - Value: ', sqlite3_value_int(argv[Index]),'  ' ,sqlite3_value_double(argv[Index]));  
SQLITE_NULL: 
  WriteLn('Type: SQLITE_NULL - Value: NULL');
SQLITE_FLOAT:
  writeln('Type: SQLITE_FLOAT - Value: ', sqlite3_value_double(argv[Index]));
SQLITE_TEXT:
  writeln('Type: SQLITE_TEXT - Value: ', sqlite3_value_text(argv[Index]));
else
  WriteLn('Type: Unknown - Value: ', sqlite3_value_text(argv[Index]));  
end;
  end;  
var
  i: Integer;  
begin
  WriteLn('argc: ', argc);
  for i := 0 to argc - 1 do
DumpVariable(i);
  sqlite3_result_int(context, 13);  
end;

procedure StrFTime(context: PSqlite3_Context; argc: LongInt; argv: PPSqlite3_Value); cdecl;  
var
  Year, Month, Day: word;
  FormatStr: String;
begin
  if (sqlite3_value_type(argv[1])  SQLITE_INTEGER) and 
(sqlite3_value_type(argv[1])  SQLITE_FLOAT) then
  begin
sqlite3_result_null(context);
Exit;
  end;
  FormatStr := UpperCase(sqlite3_value_text(argv[0]));
  DecodeDate(sqlite3_value_double(argv[1]), Year, Month, Day);
  if FormatStr = '%Y' then
sqlite3_result_int(context, Year)
  else
if FormatStr = '%M' then
  sqlite3_result_int(context, Month)
else
  if FormatStr = '%D' then
sqlite3_result_int(context, Day)
  else
sqlite3_result_null(context);
end;

  

const
  SQLITEDS_TESTS_INI_FILE = 'sqlitedstests.ini';
  DEFAULT_TABLENAME = 'tabletest';
  DEFAULT_FILENAME = 'test.db';
  
var 
  dsTest:TSqlite3Dataset;
  ini: TIniFile;

begin 
  {$ifdef DEBUGHEAP}
  SetHeapTraceOutput(ExtractFileName(ParamStr(0))+'.heap.log');
  {$endif}
  dsTest := TSqlite3Dataset.Create(nil);
  with dsTest do
  begin
//Load Database properties from a inifile
ini := TIniFile.Create(SQLITEDS_TESTS_INI_FILE);
FileName := ini.ReadString('testinfo', 'filename', DEFAULT_FILENAME);
TableName := ini.ReadString('testinfo', 'tablename', DEFAULT_TABLENAME);
ini.Destroy;
if not TableExists then
begin
  with FieldDefs do
  begin
Clear;
Add('Integer', ftAutoInc);
Add('String', ftString);
Add('DateTime', ftDateTime);
Add('Date', ftDate);
Add('Time', ftTime);
  end; 
  CreateTable;
end;
writeln('ReturnString after CreateTable: ', ReturnString);
Open;
sqlite3_create_function(SqliteHandle, 'strftime', 2, sqlite_any, nil, @strftime, nil, nil);
Append;
FieldByName('DateTime').AsDateTime := Now;
FieldByName('Date').AsDateTime := Date;
FieldByName('Time').AsDateTime := Time;
WriteLn('Date: ',FieldByName('Date').AsDateTime);
WriteLn('Time: ',FieldByName('Time').AsDateTime);
WriteLn('DateTime: ',FieldByName('DateTime').AsDateTime);
Post;
ApplyUpdates;
WriteLn(QuickQuery('Select strftime(''%Y'',Date) as mydate from '+ tablename +' limit 1;'));
WriteLn(QuickQuery('Select strftime(''%M'',Date) as mydate from '+ tablename +' limit 1;'));
WriteLn(QuickQuery('Select strftime(''%D'',DateTime) as mydate from '+ tablename +' limit 1;'));
Destroy;
  end;
end.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

[fpc-pascal] setting a custom driver in TReader

2009-11-05 Thread Roland Schaefer
Hi,

I'm wondering how to set a custom driver object for TReader instances.
Both in TReader and TWriter the Driver property is read-only, but in
TWriter I can at least use the alternative constructor which takes a
TAbstractObjectWriter. TReader only has the constructor which takes a
TStream and a buffer size Integer. Why is that?

Actually, this slightly ugly snippet from LResources/CreateLRSReader
shows that I'm not the only one trying to do this (where Result is a
TReader instance):

  // hack to set a write protected variable.
  // DestroyDriver:=true; TReader will free it
  Driver:=LRSObjectReaderClass.Create(s,4096);
  p:=...@result.driver;
  Result.Driver.Free;
  TAbstractObjectReader(p^):=Driver;


Any hints why this is implemented as it is, and whether there are
cleaner ways of using custom drivers would be highly appreciated.

Cheers
Roland
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpc and Sqlite UDF

2009-11-05 Thread Nataraj S Narayan
Hi  Luiz

Getting this:-

 /software/fpc-uclibc/lib/fpc/2.5.1/ppcrossarm -MObjFPC -TLinux
-Parmv5 -gl -Xd -Xs -l -darm -XParm-linux-uclibcgnueabi- -CfSOFT
-CaEABI -darm -gl -O- -CpARMV5  -uUSE_LOCALIZE
-Fu/software/fpc-arm/units/arm-linux/ testfunction.pas
Free Pascal Compiler version 2.5.1 [2009/10/23] for arm
Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Linux for ARM
Compiling testfunction.pas
testfunction.pas(25,66) Error: Identifier not found sqlite3_value_int
testfunction.pas(42,21) Error: Identifier not found sqlite3_result_int
testfunction.pas(59,23) Error: Identifier not found sqlite3_result_int
testfunction.pas(62,25) Error: Identifier not found sqlite3_result_int
testfunction.pas(65,27) Error: Identifier not found sqlite3_result_int
testfunction.pas(124) Fatal: There were 5 errors compiling module, stopping
Fatal: Compilation aborted


Any Sqlite version problem?

On SQLite version 3.4.2

regards

Nataraj

On Fri, Nov 6, 2009 at 1:56 AM, Luiz Americo Pereira Camara
luiz...@oi.com.br wrote:
 Nataraj S Narayan escreveu:

 Hi

 Anybody has written custom UDF for Sqlite 3 using fpc?

 If so kindly help me with some hints to get started.


 See the attached files. It implements a custom format date function

 Luiz

 ___
 fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
 http://lists.freepascal.org/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] THelpEvent usage and meaning of parameters?

2009-11-05 Thread Graeme Geldenhuys
Marco van de Voort wrote:
 
 I can assume you have grepped FPC and Lazarus SVN for it, and there were no
 occurrances, so no backwards compatibility reasons?

Actually I did. :-)

* Nothing in FPC - as expected.

* One unit in Lazarus (forms.pp) - as expected.

This should be little effort to fix in Lazarus, but will probably break
somebodies code. But then again, the K3 proposed signature is an
improvement. And there are many cases in FPC and Lazarus that are not
Delphi compatible simply because it's an improvement over Delphi or
because it's for the greater good (cross-platform and not tied closely
to Windows API).

Clearly this mailing list is not viewed by many, so I will raise this
issue and suggestion in the Lazarus mailing list, where this change will
have a bigger impact.


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal