Re: [fpc-pascal] how to make a type private to the unit but not defining it in the implementation section?

2019-03-07 Thread Dennis Poon



Anthony Walter wrote:

type
  _PrivateData = class
    private type THidden = record Name: string; end;
  end;

... and later in the implementation section of the same unit ...

var H: _PrivateData.THidden; begin H.Name := 'Hello'; end;



But that will have the same problem of extra long method declaration name
  procedure _PrivateData.THidden.Method1;
  begin
  end;


Dennis

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

Re: [fpc-pascal] Announcement GLPT

2018-09-26 Thread Dennis Poon



Darius Blaszyk wrote:
On Tue, Sep 25, 2018 at 5:21 PM Dennis > wrote:


I tried it but found that drawing text in OpenGL seems to be
problematic.
Is there anyway to draw text using windows' existing font? Or is
there a
library for nicer vector based font?


There is a unit called uglyfont.pas included in Lazarus. I ported it 
some time ago for an imgui implementation example. This is a simple 
vector font. You can also implement a freetype font fairly easy. In 
fact I can share some code. Just search for NeHe and you will find it 
online as well.


Although GLUT came with standard fonts I am not inclined to include a 
font in GLPT soon. Same for menu, UI and other drawing stuff. This 
should be handled one level higher up.


I am writing a Chinese program and the Chinese character set is huge 
with many thousand of characters, and each character has many strokes. I 
think the work required is too daunting and the improvement in speed is 
not that much for my simple chart plotting use.


I will stay with Lazarus UI for the moment. In future, I might explore 
fpGUI instead.


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

Re: [fpc-pascal] why can't we define class operator for old fashion object type, but ok for 'advanced record' type?

2018-08-16 Thread Dennis Poon



Sven Barth via fpc-pascal wrote:

Am 15.08.2018 um 10:59 schrieb Dennis:
Why class operator is accepted for advanced records but not old 
fashion object???
Because objects are not records. Internally they are handled more 
closely to classes than records.


Would it be too hard to also implement class operators for old fashion 
objects?  That will be very  nice.


Dennis

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

Re: [fpc-pascal] Will moving from due core CPU to 6 Core CPU of the same clock speed improve the speed of FPC compiling?

2018-08-07 Thread Dennis Poon



Martin wrote:


Out of interest, how long does it take you to compile your project?

Only 20 seconds. But sometimes, when I modify some units used by other 
units which are in turn used by other units, FPC throws the following 
exception when I compile (not build)

uspdata.pas(228,50) Error: Compilation raised exception internally

When that happens, I have to build the entire project, and that takes 
much longer.


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

Re: [fpc-pascal] No type info available for this type (Enumerated type with constant assignment)

2018-07-24 Thread Dennis Poon



Sven Barth via fpc-pascal wrote:
Dennis mailto:de...@avidsoft.com.hk>> schrieb 
am Mo., 23. Juli 2018, 12:24:


Is this kind of enumerated type with constant assignment not
supported
by FPC 3.0.4?

   TMonthType = (January=1, February, May=5,June, July);


The enumeration type itself is supported, however TypeInfo() and thus 
GetEnumName() and friends are not.



No only that, the following also gives error
  for a in TMonthType do
 begin
   //a won't be assigned the proper values
    end;

Regards,
Sven


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


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

Re: [fpc-pascal] Is there a smart way to save/restore NotifyEvents and objects?

2018-02-02 Thread Dennis Poon



Sven Barth via fpc-pascal wrote:
Am 02.02.2018 17:53 schrieb "Dennis" >:


I have list of objects which contains references to other objects.
I need to save all these objects to harddisk to be restored on a
latter day.

I know how to stream the data fields of these objects to a
TFileStream but the tricky part is these how to restore the object
references.

The only way I can think of is to assign unique IDs to each
objects and store these IDs to file.
When these objects are later restored, I used these IDs find the
actual objects and re-assign them back to the object references.

It is tedious. Is there a smarter way?

Also, there are some TNotifyEvent fields  e.g. OnClick, OnClose
etc.  How do I save and restore them from file?

Many thanks in advance.


If your objects inherit from TComponent and you use published 
properties you can use the streaming screen of the RTL.


I am curious how TComponent save and restore TnotifyEvent fields. Can 
you explain a little bit?

Also, what is 'streaming screen' of RTL? How to use it?

Thanks.

Dennis

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

Re: [fpc-pascal] any existing units/libraries for sorting?

2018-01-03 Thread Dennis Poon



Santiago A. wrote:

El 03/01/2018 a las 16:09, Dennis escribió:

I have a list of records (each with a few fields).

What do you mean with list?
A TList? You can use sort method


Thanks for the reminder. I forgot about it.

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

Re: [fpc-pascal] Cannot find entry point of a routine inside a windows 64 dll

2017-12-13 Thread Dennis Poon



Sven Barth via fpc-pascal wrote:
Am 13.12.2017 03:04 schrieb "Dennis" >:


I am converting my windows 32 program to 64 bit.
It compiled with lazarus without any problem.(fpc 3.0.2)

I also compile the dll that is used, into a 64 bit dll.

However, when I ran the 64 bit program, windows reported 'cannot
find the entry point "the routine name in the dll" (the dll file name)

In the routine of the dll, there is an out parameter of type
WideString,

could this be the problem?

If not, what else could be the cause of the problem?


Considering the code you gave I really wonder how that ever worked... 
Did you set the calling convention using the $calling directive? 
Otherwise you need to add it to every function. Also you're on the 
eager side by using the "name" clause for the external as you can be 
sure then what name is used. Lastly are you sure that the DLL you're 
dealing with is a 64-bit library?


In the original 32 bit program, I wrote the windows 32-bit dll in the 
Starter (FREE) edition of Delphi and call (using those codes I showed 
you) from my FPC 32 bit program without any problem.
Since there is NO FREE Delphi for 64 bit version, I wrote a windows 
64-bit program using FPC 64 bit and then try calling it from my FPC 
64-bit program and encountered the "Cannot find entry point of a routine 
inside a windows 64 dll" error.


In the 32 bit program, I did not use the $calling directive and did not 
use 'name' clause and it worked perfectly.
I could add the name clause in the 64 bit program, but can you teach me 
how to use the $calling directive?
Since in the 64 bit version, i will be writing both the dll and the 
calling program, what $calling directive should I use?

Do I need to specify it clearly on both the dll and the calling code?

Maybe you should take a look at fpSpreadsheet which allows you to work 
with Excel files of different versions directly and does not need a 
library.


I tried to use the fpSpreadsheet sample program last time. If the 64 bit 
dll thing did not work out, I will have to rely on the fpSpreadsheet 
thing but my customers are all used to Excel and prefer sticking to it :-(


Thanks for your response.

Dennis

Regards,
Sven


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


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

Re: [fpc-pascal] Is there any pascal interface to TensorFlow or other neural network tools?

2017-12-07 Thread Dennis Poon



schuler wrote:

"> or even neural network libraries written in Pascal?
Try contacting schuler in Lazarus forum. "

Hello, this is schuler!!!

You can find the most recent project update here:
https://forum.lazarus.freepascal.org/index.php/topic,39049.0.html

There are many neural network layers (convolution, maxpool, concat, full
connect, local connect, ...) on 1D, 2D and 3D plus initialization functions
(uniform, Glorot, He, LeCun). Although the OpenCL implementation is still
cooking, the AVX implementation rocks.




Thanks.

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

Re: [fpc-pascal] Is there any pascal interface to TensorFlow or other neural network tools?

2017-10-29 Thread Dennis Poon



Michael Van Canneyt wrote:



On Sat, 28 Oct 2017, Dennis wrote:


or even neural network libraries written in Pascal?

I know there are many python interfaces/libraries but I hope to use 
Pascal entirely so that I don't have to run a python server along 
side my Free Pascal program.


Or, is it possible to call python from Free pascal?

If not, in the worst case, I have to write  python tcp/ip server to 
accepts commands from (and send back results to ) my FPC program.


Tensorflow has a C library interface, the c_api.h header can be easily
translated with h2pas.

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/c/c_api.h

I did a quick run, it translates quite well.

Michael.


That's good news. Thanks a lot.

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

Re: [fpc-pascal] How to call C++ function with Vector

2017-09-26 Thread Dennis Poon



Marco van de Voort wrote:


I myself generally solve this with a wrapper DLL, by crafting a DLL in C++
that exports a C (not C++) interface, and then use that. The same method as
QT is used from Lazarus (via wrapper dll/.so qtpas)
___

Thanks.  I think I will follow your advice.

Dennis

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

Re: [fpc-pascal] why the 0.5 in the Unix Epoch (for UnixToDateTime function)

2017-08-01 Thread Dennis Poon



Vojtěch Čihák wrote:


Hi,

wiki https://en.wikipedia.org/wiki/Julian_day says that "... Julian 
day number 0 assigned to the day starting at noon on January 1, 4713 
BC, ..."


The noon means 0,5.


Thanks,
that is a weird definition though IMHO.

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

Re: [fpc-pascal] Why casting interface as Tobject will result in a different reference?

2017-05-27 Thread Dennis Poon



Sven Barth via fpc-pascal wrote:

The idea itself is valid, cause "(IMyInterfaceVar as TObject) as
IMyInterface = IMyInterfaceVar" is true if and only if IMyInterface is
a COM interface. If IMyInterface really is a CORBA interface as Dennis
wrote then the compiler should already have complained at the "aObj :=
aInt as TObject" line as this type of conversion is*not*  supported by
CORBA interfaces (cause they don't provide QueryInterface() which is
needed for this). At least for me the compiler*did*  complain (both
3.0.2 and 3.1.1) when I tested this.
So the question is: is IMyInterface indeed a CORBA interface? If so
then why does the compiler not complain? If not then why doesn't it
work? For both cases a full example would be needed to investigate
this.

Regards,
Sven

Sorry, I got it wrong. The interface was in fact COM style instead of CORBA.

In case of COM interface, why

var
   aInt : IMyInterface;
  aObj : TObject;
begin


...
   aInt := MyList.Items[0];

   aObj := aInt as TObject;

why sometimes (not always)   aInt  <>   (aObj as IMyInterface ) ?

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

Re: [fpc-pascal] Run Time Type Info - are the type names of all classes defined in a unit stored in the RTTI?

2017-03-01 Thread Dennis Poon



Sven Barth wrote:


Am 01.03.2017 11:53 schrieb "Dennis" >:

>
> Programmatically, I want to make a list of all Classes defined in 
the unit.

> Is this info stored in the RTTI or anywhere else?

This info is not yet available, but will be in the future.



Thanks.

Ideally, with this feature, in the initialization section of the unit, I 
can 'register' all the classes defined in the unit into a 
dictionary.
That way, when loading objects from file, I can use the dictionary to 
lookup the actual TClass with the stored Classname, to recreate the 
object stored.


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

Re: [fpc-pascal] how to use Default to replace this ' FillChar(aRecord, sizeof(aRecord), 0);

2016-12-05 Thread Dennis Poon



Lars wrote:

Do you know about this feature:

var
   SomeRec: TSomeRecord = ();

This is good for global variable.
But I wonder whether it has effect in procedure's local variable since 
it requires the compiler to clear the record on the stack (which is at 
different location every time).


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


Re: [fpc-pascal] how to use Default to replace this " FillChar(aRecord, sizeof(aRecord), 0);

2016-12-05 Thread Dennis Poon



Sven Barth wrote:


Am 05.12.2016 08:24 schrieb "Dennis" >:

>
> In this old statement, I don't need to know the type of aRecord
> but if I want to use Default, I have to know the exact type of the 
varaible aRecord and pass it to Default(aRecordType) e.g. aRecord := 
Default(aRecordType)  //where var  aRecord : aRecordType

>
> Is it possible to use default without knowing the variable type? (it 
is because sometimes the type get renamed)


No, it's not possible. You'll simply have to rename one more location.

Regards,
Sven



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


Re: [fpc-pascal] what is the possible cause of EPrivilege Privileged instruction ?

2016-10-26 Thread Dennis Poon



Snorkl e wrote:


Your not using teventobject in your threads are you?
There is a bug in the RTL which could cause weird issues with threads 
if you are using teventobject.create.




I don't use TEventObject (because I don't know how to use it).
I have my internal task queue that my worker thread loop through the 
task queue.

The exception was raised within one of the many tasks in the task queue.

Dennis
On Oct 26, 2016 10:58 AM, "Dennis" > wrote:


I have a multi threaded program which executes a list of tasks in
real time.
It is difficult to debug with a debugger on this program (since
debugging will pause the execution which will be messy for this
application).

So, I log the exceptions to a log file and I found this exception:
EPrivilegePrivileged instruction

What could possibly raise this exception?

My program is win 32 from Lazarus 1.7  FPC 3.1.1
and running on Win 7 64 bit.

thanks in advance.

Dennis
___
fpc-pascal maillist  - fpc-pascal@lists.freepascal.org

http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal




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


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


Re: [fpc-pascal] Resource strings, passwords etc.

2016-07-13 Thread Dennis Poon



Graeme Geldenhuys wrote:

On 2016-07-13 08:31, Mark Morgan Lloyd wrote:

Sometimes it's difficult to avoid having to do that sort of thing, or
obfuscating them in an external file.

You could use something like DCPCrypt to help the cause. Or you could
follow similar tactics to what OnGuard uses - encode sensitive text in a
data structure. At the very least use a const of bytes instead of clear
text. For example:



May I know what OnGuard is? googling it returns something irrelevant.

On the subject,  can the OP simply use UPX to encrypt the executable 
binary. It won't be secured but no more unsecured than other simple 
solutions.


UPX is at http://portableapps.com/apps/utilities/free_upx_portable

The original sourceforge.net link is dead, I don't know why.

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


Re: [fpc-pascal] Surprise. Comparison of method is only done on the routine address

2016-07-12 Thread Dennis Poon



Michael Van Canneyt wrote:



On Tue, 12 Jul 2016, Dennis wrote:

I always thought comparison of methods is done on both the data and 
the code part.

  TMethod = record
Code : CodePointer;
Data : Pointer;
  end;
But the following proves it is NOT.
What is the rationale behind such behavior?


AFAIK: Delphi compatibility.


May I know what do they claim to be the rationale behind this decision?

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


Re: [fpc-pascal] can the compiler zero any out parameter of procedure/function automatically?

2016-07-11 Thread Dennis Poon



Jonas Maebe wrote:

Dennis wrote:

I know it is my responsibility to initialize out parameters, but I think
the compiler could help us by initializing all out parameters.

The compiler will fill out-parameters with garbage if you use the -gt
command line parameter, which can help you detect such problems more easily.

If you forget to assign a value to an out-parameter in a particular
case, having it return nil by default could easily be just as wrong as
it returning any other random value. For that reason, there is no
support for automatically initialising out-parameters.


How about issue a compiler warning if one forgets to zero any out parameter?

Dennis

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


Re: [fpc-pascal] what is the correct way to write {$IFDEF FPC Version > 3.0}

2016-07-08 Thread Dennis Poon



Bart wrote:

On 7/8/16, Dennis  wrote:


what is the correct way to write {$IFDEF FPC Version > 3.0}

See answers above.

For your information:
FPC_FULLVERSION construction:
Major*1 + Minor*100 + Revision

Thank you all for your answers.

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


Re: [fpc-pascal] Is there a reactive framework for Free Pascal?

2016-07-07 Thread Dennis Poon



Sven Barth wrote:


Am 07.07.2016 10:13 schrieb "Graeme Geldenhuys" 
>:

>
> Hi Dennis,
>
> Would you mind explaining what is a “reactive framework”?

http://reactivex.io/

Once we support helpers for interfaces and anonymous functions (and 
maybe lambda expressions ^.^ ) one could try to port it.


Regards,
Sven


How about for the time being, any library to help with distributing 
tasks to various threads' queue.
Right now, only Application.QueueAsycnCall has a queue to which you can 
send tasks (  procedure (integer) of object ).

Normal Tthread has  no queues.
I am implementing my own queues for worker thread and encounter some 
problems when the program quits and some objects not being freed at the 
right order.
The application then just hangs (I suppose because some objects are 
still not freed so UI thread keeps on waiting). One of the 4 CPU cores 
is thus at full capacity for ever.


I hope someone has done some work in this area which I can learn from.

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


Re: [fpc-pascal] Bls: Bls: Quick Modern Object Pascal Introduction, for Programmers

2016-06-22 Thread Dennis Poon
I saw your document on for x in ListX  loop and would like to reconfirm 
that it is always iterated in ascending order, right?


can we do it in descending order without a user defined enumerator? i.e. 
for simple enumerated type, is there a construct to iterate through it 
in descending order?


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


Re: [fpc-pascal] Quick Modern Object Pascal Introduction, for Programmers

2016-06-21 Thread Dennis Poon



2) use of ClassType function for cloning objects

I added two things:

- A section about TPersistent.Assign. This is the "basic approach to
cloning" that should probably be shown first. See it here:
http://michalis.ii.uni.wroc.pl/~michalis/modern_pascal_introduction/modern_pascal_introduction.html#_cloning_tpersistent_assign
. I mentioned the special rules when calling the "inherited" from
Assign overrides, and AssignTo, and the fact that TPersistent makes
the default visibility "published".

- And the ClassType, with the example of Clone method using it, is
added at the desciption of "class references" on
http://michalis.ii.uni.wroc.pl/~michalis/modern_pascal_introduction/modern_pascal_introduction.html#_class_references


Just read your example

|function TMyClass.Clone(AOwner: TComponent): TMyClass; begin // This 
would always create an instance of exactly TMyClass: //Result := 
TMyClass.Create(AOwner); // This can potentially create an instance of 
TMyClass descendant: Result := TMyClassRef(ClassType).Create(AOwner); 
Result.Assign(Self); end |


|I remember someone once asked whether we should override the method 
Assign or AssignTo.|
|I am worried, choosing the wrong method to override will produce 
unexpected result.|

||
|Dennis|

||
|
|

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


Re: [fpc-pascal] Quick Modern Object Pascal Introduction, for Programmers

2016-06-19 Thread Dennis Poon

May I suggest the addition of :
1) user defined operator?
2) use of ClassType function for cloning objects


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


Re: [fpc-pascal] Quick Modern Object Pascal Introduction, for Programmers

2016-06-19 Thread Dennis Poon



Michalis Kamburelis wrote:

Hi,

So, I wrote a document describing (quickly!) many features of the
modern Object Pascal:)

Read on:

http://michalis.ii.uni.wroc.pl/~michalis/modern_pascal_introduction/modern_pascal_introduction.html

http://michalis.ii.uni.wroc.pl/~michalis/modern_pascal_introduction/modern_pascal_introduction.pdf




Good work and thank you for your contribution to the community.

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


Re: [fpc-pascal] Error: Internal error 2014052302 on changing some common units

2016-04-15 Thread Dennis Poon



Sven Barth wrote:


Am 15.04.2016 13:40 schrieb "Dennis" >:

>
> whenever I change the source of a common unit (that is used by many 
other units), when I compile with lazarus 1.7 +FPC 3.1.1, this error 
will appear in the messages

> "Error: Internal error 2014052302".

Are you sure that you're using the most current version? Cause I had 
fixed that in r33054 at the beginning of February.


Regards,
Sven




I get it from getlazarus.org a few days ago. please see the screen 
capture below:



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


Re: [fpc-pascal] compile Link Smart option, is it -XX or -CX?

2016-03-03 Thread Dennis Poon



Sven Barth wrote:


Am 03.03.2016 09:26 schrieb "Dennis" >:

>
> According to http://www.freepascal.org/docs-html/prog/progse30.html
>
> the smartlink option on the command line is -CX
> but in Lazarus ver 1.42,
>Compilation and Linking
>   Linking
>   Link Smart is -XX

They are different. -CX tells the compiler to compile units with smart 
linking capability (though I'd need to check what exactly that 
entails), while -XX enables smart linking.


Regards,
Sven



Would you kindly elaborate?
If -XX is not set, does that mean Smart Link is disabled and even if -CX 
is set, it is ignored?


Dennis



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


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


Re: [fpc-pascal] Assign() vs AssignTo()

2016-02-11 Thread Dennis Poon



Martin Schreiber wrote:

On Friday 12 February 2016 03:17:57 Dennis wrote:

Is there any sample codes to copy published properties (via RTTI) ?
e.g. psuedo code below

for i := 0 to properties.count -1 do begin
   case properties[i].type of
  vtInteger :  properties[i].AsInteger :=
Source.PropertiesByName(Properties[i].Name).AsInteger;
 vtdouble : 
 vtString : ...
   end;
end;


MSEgui has such code for "trttistat" component, please see
https://gitlab.com/mseide-msegui/mseide-msegui/raw/master/lib/common/kernel/mserttistat.pas
although it is specialised for saving and editing options.

Martin
___


Thank you.

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


Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-01 Thread Dennis Poon



Jürgen Hestermann wrote:

Am 2016-02-01 um 19:45 schrieb Dmitry Boyarintsev:
No matter what the language is, developers still want to write C... 
for the shortness of script


Such people should simply use C.
Pascal <> C
and I am glad that this is true.


In my humble opinion, the importance of "Shortness of script" is overrated.

Ease of reading and maintaining the code is far more important.
Programmers spend most of their time debugging and modifying/extending 
existing code, not in writing the first draft of code.


Object Pascal excels in this area.  That's why I like pascal much more 
than C.


Dennis

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




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


Re: [fpc-pascal] Problem with objects

2015-12-23 Thread Dennis Poon



Santiago A. wrote:

El 23/12/2015 a las 12:13, Dennis Poon escribió:


Did you call A.Create before calling TestDerived? Maybe A.List was not
initialized (which is done in constructor Create) and contains an
invalid pointer (to dynamic array of string).
When you call SetLength, it decrements the reference count of A.List
(which is not nil) and raisesSIGSEGV.

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

It's an object, not a class inherited from Tobject, so it hasn't create
constructor.


Even if it is an object, you can still define a constructor.
A constructor should initialize the memory area of the object to 0, even 
if you don't explicitly assign List := nil;

It is safer to call this constructor before you handle the List.
The fact that it raises SIGEGV in TestDervived but not in TestSimple 
might just be a random luck in how the compiler handles the memory space 
involved.

You should not rely on this behavior.

Dennis


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

Re: [fpc-pascal] Problem with objects

2015-12-23 Thread Dennis Poon
I think for both Record or Object, you need to initialize any dynamic 
array or strings fields before using them.


If you don't use any constructor , you need to initialize the fields 
yourself.


Being an object, just gives you the added automatic zeroing of its 
content. Advanced Record does not have constructor so you must 
initialize yourself.


The documentation should state that constructor of object also clears 
the memory space.


Dennis

Santiago A. wrote:

al method


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


Re: [fpc-pascal] Problem with objects

2015-12-23 Thread Dennis Poon



Santiago Amposta wrote:

Hello:
I use fpc 2.6.4 and I have a problem of memory leaks, strange errors,
etc. Finally I have tracked it to this:

TSimpleArrayString=object
 List:array of String;
end;

TDerivedArrayString=object(TSimpleArrayString)
 other_field:integer;
end;

procedure TestSimple;
var
  A:TSimpleArrayString;
begin
   setLength(A.List,0);
end;

procedure TestDerived;
var
  A:TDerivedArrayString;
begin
   setLength(A.List,0);
end;


TestSimple; // Works Fine,
TestDerived; // rises an exception SIGSEGV on setLength

What am I doing wrong?

Did you call A.Create before calling TestDerived? Maybe A.List was not 
initialized (which is done in constructor Create) and contains an 
invalid pointer (to dynamic array of string).
When you call SetLength, it decrements the reference count of A.List 
(which is not nil) and raisesSIGSEGV.


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


Re: [fpc-pascal] Does SetLength clear its elements to zeros?

2015-12-11 Thread Dennis Poon



Jonas Maebe wrote:


Dennis wrote on Fri, 11 Dec 2015:

I just tested, SetLength a string  does not zero its elements (the 
chars).


However, SetLength a dynamic array seems to zero its elements.


Dynamic arrays are indeed zeroed when changing the length, while 
strings are not. For dynamic arrays, it is necessary anyway in case it 
has reference counted elements. Maybe for consistency, it's always done.


Additionally, changing the length of the string without afterwards 
overwriting the data between the previous and new last character seems 
something that would happen very seldom (why did you increase the 
length if you didn't need to write all characters -- any operation 
with the string, such as writing or concatenating it, will use those 
characters anyway because the length indicates they're part of the 
string).


The above are mostly guesses though.


Jonas
___


Thanks for clarifications.

Dennis

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


[fpc-pascal] how do I play mp3 files with Free Pascal?

2014-10-27 Thread Dennis Poon

I can use the windows MMSystem unit but it only plays .wav file.
How do I play .mp3 file?

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


[fpc-pascal] any generic List class other than those in fgl unit?

2014-10-24 Thread Dennis Poon
The TFPGMap in fgl unit has serious bug in the Find method. I tried but 
cannot fix it.

I am hoping to find a well tested replacement class?
Please kindly let me know.

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


Re: [fpc-pascal] any generic List class other than those in fgl unit?

2014-10-24 Thread Dennis Poon



Reinier Olislagers wrote:

On 24/10/2014 13:32, Dennis Poon wrote:

The TFPGMap in fgl unit has serious bug in the Find method. I tried but
cannot fix it.

Why don't you raise a bug in the bugtracker with an example test program
so developers can look into it?


Can you give me a link to report this bug? I have not done this before.

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


Re: [fpc-pascal] Is TFPList thread safe?

2014-10-06 Thread Dennis Poon


Michael Schnell wrote:

On 10/02/2014 03:59 PM, Xiangrong Fang wrote:
, not replace TFPList with TThreadList, for simplicity and 
performance reason...
I don't suppose it will be possible to beat TThreadList performance by 
any home-brew Pascal code, which is same is not insecure.



But I looked at the source code of TThreadList,

procedure TThreadList.Add(Item: Pointer);
  begin
LockList;
try
  if (Duplicates=dupAccept) or
// make sure it's not already in the list
(FList.IndexOf(Item)=-1) then
 FList.Add(Item)
   else if (Duplicates=dupError) then
 FList.Error(SDuplicateItem,PtrUInt(Item));
finally
  UnlockList;
end;
  end;


where

function TThreadList.LockList: TList;
  begin
Result:=FList;
System.EnterCriticalSection(FLock);
  end;


There is no special optimization at all.  It simply calls
  System.EnterCriticalSection(FLock),
so performance should be JUST THE SAME as wrapping a pair of critical 
section enter/leave around the code ourselves.


Dennis



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


[fpc-pascal] fgl unit bug in generic class TFPGMap

2014-10-03 Thread Dennis Poon

I think I found a bug in TFPGMap.
Hope some of you can verify it.

The bug seems to relate to the binary search used in the method FIND 
but it does not occur for all string key values or at all capacity of 
the map. Seems only occur at the second item added and when it is 
certain string values.


I tried to debug it but cannot step into the codes of fgl unit so cannot 
find the cause.


Please help.

Dennis

=
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
  Classes,  Forms, Controls,StdCtrls, SysUtils,  fgl;
type

  TMapOfObjects=class(specialize TFPGMap  String, TObject )
  public
function Locate(TheKey : String) : Boolean;
function GetContent  :String;
  end;

  TForm1 = class(TForm)
  public
Map :  TMapOfObjects;
Memo1 : TMemo;
ButtonAdd : TButton;
Edit1 : TEdit;
N : integer;
procedure ButtonAddClick(TheSEnder : TObject);
destructor Destroy;override;
constructor Create(TheOwner : TComponent);override;
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

function TMapOfObjects.Locate(TheKey: String): Boolean;
var i  : integer;
begin
  result := false;
  for i := 0 to count-1 do begin
if Keys[i] = TheKey then begin
  result := true;
  exit;
end;
  end;
end;

procedure TForm1.ButtonAddClick(TheSEnder: TObject);
var idx : integer;
  L : TObject;
  s : String;
begin
  inc(n);
  L := TObject.Create;
  Map.Add(Edit1.Text, L);

  if not Map.Find(Edit1.Text, idx) then begin
Memo1.lines.add('#'+IntToStr(n)+'   '+Edit1.Text+ ' was just added 
but cannot be found by method FIND ! BUG!');

if Map.Locate(Edit1.Text) then begin
  Memo1.lines.add(' BUT a simple loop of comparision can 
locate it, proving the item was added, just the method FIND is  BUGGY!');

  Memo1.lines.add(' List content = '+Map.GetContent);
end;
  end else begin
Memo1.lines.add('#'+IntToStr(n)+'   '+Edit1.Text+ ' was added and 
found as expected');

Memo1.lines.add(' List content = '+Map.GetContent);
  end;
end;

destructor TForm1.Destroy;
var i : integer;
begin
  for i := 0 to map.count-1 do
Map.Data[i].Free;
  Map.Free;
  inherited Destroy;
end;

constructor TForm1.Create(TheOwner: TComponent);
begin
  inherited Create(TheOwner);

  ButtonAdd := TBUtton.Create(self);
  ButtonAdd.Parent := self;
  ButtonAdd.Left := 10;
  ButtonAdd.Top := 5;
  ButtonAdd.Caption := 'Add';
  ButtonAdd.OnClick := @ButtonAddClick;

  Edit1 := TEdit.Create(SELF);
  Edit1.Parent := self;
  Edit1.Top := 10;
  Edit1.Left := 100;
  Edit1.Text := '';

  Memo1:= TMemo.Create(self);
  Memo1.Parent := self;
  Memo1.Left := 16;
  Memo1.Height := 342;
  Memo1.Top := 74;
  Memo1.Width := 575;
  Memo1.lines.Clear;

  Map := TMapOfObjects.Create;

  //no matter what I set below, the same bug will appear. also, 
duplicates are always added

//  Map.Duplicates:= dupError;
//  Map.Duplicates:= dupIgnore;

  n := 0;
  Edit1.Text := 'abc';
  ButtonAddClick(nil);

  Edit1.Text := 'HHIV4'; //will trigger bug;
//  Edit1.Text := 'defv4'; //but strangely if add 'defv4' wont' trigger bug
  ButtonAddClick(nil);

  Edit1.Text := 'ghiV4';  //bug seems to disappear after the 2nd item 
is added. perhaps the buy is in binary search

  ButtonAddClick(nil);
end;

function TMapOfObjects.GetContent: String;
var i :Integer;
begin
  result := '';
  for i := 0 to count-1 do begin
result := result+Keys[i]+',';
  end;
end;

end.

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


Re: [fpc-pascal] Windows type library files

2014-10-03 Thread Dennis Poon

thanks a lot.

Adriaan van Os wrote:
In case someone is interested, I put the .zip archives below for 
download at my website


http://adriaan.biz/windows-com/pas-from-sdk.zip
http://adriaan.biz/windows-com/pas-from-system32.zip

Regards,

Adriaan van Os

http://adriaan.biz/windows-com/pas-from-sdk.zip
auto-generated with midl and tlibimp from include/*.idl in the Windows 
SDK


Accessibility.pas
ActiveIMM.pas
ADHOCLib.pas
ADODB.pas
ALGLib.pas
AppHostAdminLibrary.pas
AQAdmin.pas
BackgroundCopyManager.pas
BackgroundCopyManager1_5.pas
BackgroundCopyManager2_0.pas
BackgroundCopyManager2_5.pas
BackgroundCopyManager3_0.pas
BackgroundCopyManager4_0.pas
BackgroundCopyQMgr.pas
BITSExtensionSetup.pas
CDO.pas
CERTENCODELib.pas
CertSrvSetupLib.pas
CHANNELMGR.pas
COMAdmin.pas
CommonControlObjects.pas
CONTACT.pas
CORDBLib.pas
CorpubProcessLib.pas
CorrEngineLib.pas
CorSymLib.pas
CredentialProviders.pas
DHTMLEDLib.pas
DirectDB.pas
DummyEventSystemLib.pas
EncDec.pas
ExevtsnkLib.pas
FctnDiscLib.pas
Feeds.pas
GPMGMTLib.pas
IEOpenServiceObjects.pas
IEXTagLib.pas
IMAPI2.pas
IMAPI2FS.pas
ImgUtilLib.pas
MailMsgLib.pas
ManipulationsLib.pas
MbnApi.pas
MILEffects.pas
MIMEOLE.pas
MMC20.pas
MMCVersionLib.pas
MMDeviceAPILib.pas
Mpeg2DataLib.pas
MSAATEXTLib.pas
MSDAOSP.pas
MSDAOSPT.pas
MSDATASRC.pas
MSHTML.pas
MSOPC.pas
MSRDCLib.pas
MSTIME.pas
MSVidCtlLib.pas
MSXML.pas
MSXPS.pas
MSXPSSIG.pas
MultiLanguage.pas
NATUPNPLib.pas
NETCONLib.pas
NetFwPublicTypeLib.pas
NETPROVLib.pas
NETWORKLIST.pas
PortableDeviceConnectApiLib.pas
ProcessDebugManagerLib.pas
PropSysObjects.pas
PSISLOADLib.pas
RDPCOMAPILib.pas
RENDLib.pas
RTCCORELib.pas
ScanProfilesLib.pas
SCARDSSPLib.pas
SDOIASLib.pas
SearchAPILib.pas
SensEvents.pas
SEOLib.pas
SHDocVw.pas
Shell32.pas
ShellObjects.pas
SpeechDDKLib.pas
SpeechLib.pas
StructuredQuery1.pas
SubscriptionMgr.pas
SyncMgrObjects.pas
SyncObjects.pas
TERMMGRLib.pas
ThumbCacheLib.pas
TRIEDITLib.pas
TunerLib.pas
TVRATINGSLib.pas
UIA.pas
UIAnimation.pas
UIAutomationClient.pas
UIRibbon.pas
UPnPHostLib.pas
UPNPLib.pas
VEHandlerLib.pas
VSMGMT.pas
VSSAdmin.pas
VSSProvider.pas
WbemClient_v1.pas
WbemProviders_v1.pas
WbemScripting.pas
WbemTransports_v1.pas
WbemUtilities_v1.pas
WdsTptMgmtLib.pas
WinHttp.pas
WMDRMContentEnablerLib.pas
WMIEXTENSIONLib.pas
WmiXMLTransformer.pas
WMLSS.pas
WPObjLib.pas
WSManAutomation.pas
WUApiLib.pas

http://adriaan.biz/windows-com/pas-from-system32.zip
auto-generated with midl from *.dll and *.tlb in c:\windows\system32

Accessibility.pas
AccessibilityCplAdminLib.pas
ActiveDs.pas
ADODB.pas
AMovie.pas
ATLLib.pas
AuthFWSnapin.pas
AuthFWWizFwk.pas
AZROLESLib.pas
BCDConstants.pas
BRCplLib.pas
CardSpaceApiLib.pas
CDO.pas
CERTCLIENTLib.pas
CERTENCODELib.pas
CERTENROLLLib.pas
CERTMGRLib.pas
CICLib.pas
CLBCATQLib.pas
COMPATUILib.pas
COMReplLib.pas
COMSNAPLib.pas
COMSVCSLib.pas
CRYPTEXTLib.pas
CTVLib.pas
CUSTREGLib.pas
DACCOMLib.pas
DataStore2Lib.pas
DevicePairingConfiguration.pas
DexterLib.pas
DFSSHLEXLib.pas
DiskQuotaTypeLibrary.pas
dnsHCLib.pas
Dot3BalloonDlgLib.pas
dtshLib.pas
DXTMSFTLib.pas
DXTRANSLib.pas
ElevateWlanUi.pas
EncDec.pas
EnhancedStorageAPILib.pas
EnhancedStorageShellLib.pas
EventSystemLib.pas
FctnDiscLib.pas
Feeds.pas
FindNetPrintersLib.pas
FPHCLib.pas
gameuxLib.pas
GetConnectedTasks.pas
Gpprefcl.pas
HelpPane.pas
HelpServiceTypeLib.pas
IASCoreLib.pas
IASDataStoreComServerLib.pas
IASExtensionsLib.pas
IasHelperLib.pas
IASRadiusLib.pas
icardie.pas
IClientSideRenderingLib.pas
ICSCONTENTFILTERLib.pas
IEXTagLib.pas
IMAPI2.pas
IMAPI2FS.pas
IndeoTypeLib.pas
INKEDLib.pas
IPBUSENUMLib.pas
IPNATHelperLib.pas
JetES.pas
JSGlobal.pas
L2SecHCLib.pas
MDACVer.pas
MediaManagerHCLib.pas
MediaPlayer.pas
MIMEEDIT.pas
MSAATEXTLib.pas
MSDAOSP.pas
MSDATASRC.pas
MSHelpServices.pas
MSHTML.pas
MSNETOBJLib.pas
MSSCTLB.pas
MSSITLB.pas
MSTIME.pas
MSTSCLib.pas
MSVidCtlLib.pas
MSWMDMLib.pas
MSXML2.pas
MYCOMPUTLib.pas
napcrypt.pas
naphlpr.pas
NaturalLanguage6.pas
ndfapiLib.pas
ndisHCLib.pas
NetCenterLUALib.pas
NETCONLib.pas
netcoreHCLib.pas
NetFwTypeLib.pas
NetProjWLib.pas
NETWORKLIST.pas
NetworkPolicy.pas
OLEPRNLib.pas
OPTSHOLDLib.pas
PlaLibrary.pas
PMCObjLib.pas
PNPXAssociation.pas
PortableDeviceApiLib.pas
PortableDeviceClassExtension.pas
PortableDeviceConnectApiLib.pas
PortableDeviceTypesLib.pas
PortableDeviceWMDRMLib.pas
PrintUIObjLib.pas
PSISDECDLib.pas
PSTORECLib.pas
PXWizardRegistration.pas
PXWizardTypeWin32.pas
QuartzTypeLib.pas
RasDiagHCLib.pas
RASPages.pas
RASSISTANCELib.pas
RDPCOMAPILib.pas
RegisterControlLib.pas
RelMonLib.pas
RendezvousSessionLib.pas
RPCNDFLib.pas
ScanProfilesLib.pas
SCPLib.pas
Scripting.pas
Scriptlet.pas
SCRIPTOSYSLib.pas
ScriptSigner.pas
SDOHlpLib.pas
SDOIASLib.pas
SensEvents.pas
SHDocVw.pas
Shell32.pas
SHGINALib.pas
SIGNDRVLib.pas
SLCCLib.pas
SLWmiProviderLibrary.pas
SMBLib.pas
STCLIENTLib.pas
stdole.pas
StdType.pas
SysFxUiLib.pas
TabBtnExLib.pas
TAPI3Lib.pas
TaskScheduler.pas
TERMMGRLib.pas
tom.pas
TouchxLib.pas
TSInternalCommunication.pas
TVRATINGSLib.pas
UIAnimation.pas

Re: [fpc-pascal] how do I get Run Time info from a published method?

2014-10-02 Thread Dennis Poon

Flávio


Thanks so much.

Dennis


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

[fpc-pascal] how do I get Run Time info from a published method?

2014-09-29 Thread Dennis Poon

say for example:

  type
 TmyClass = class
 published
procedure Something (sender : Tobject);virtual;
end;

var
  myClass  : TmyClass;

then somewhere

AddMethodToQueue(@myclass.Something);


Is it possible within AddMethodToQueue, I can query the Run Time Type 
Info of the method passed in ?




procedure AddMethodToQueue(const TheEvent : TNotifyEvent);
var aMethodObjectname : String;
begin
//I can already do this
 aMethodObjectName := TObject(TMethod(TheEvent).Data).ToString;

//how do I check the RTTI of TheEvent and get the name of the 
method i.e. 'Something'?

   //since it is published, it should be possible, right?

end;

Thanks in advance.

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


Re: [fpc-pascal] is it possible to kill a thread from within fpc?

2014-09-26 Thread Dennis Poon

Mark Morgan Lloyd wrote:

Dennis Poon wrote:
I want to kill a thread created by my fpc program (not killing the 
entire process).

I have to use an external win32 dll.
I am already calling it from a separate thread but still, that dll 
something goes into an infinite loop  which made my thread freezes.


Are you absolutely sure that the loop is a coding error in the DLL, or 
is there any possibility that it's either because you're not calling 
it properly, because you've not initialised something properly, or 
because you're mistakenly allocating memory using a heap manager in 
the DLL and then releasing it in the main program or vice-versa?


Noting everything that Jonas has said, and pointing out that there's 
been extensive discussion in the past relating to even calling  
Suspend  from inside the thread's own code, I'd point out that it's 
fairly common practice for programs such as Firefox to launch a 
separate process (not thread) to handle e.g. an instance of the Flash 
player. Is this something you could do, or do you have to have 
fine-grained control of multiple subroutines in the DLL?




It am quite sure it is the dll's problem because the problem happens at 
11pm everyday only. Nothing in my program has anything related to that time.
The dll is a brokerage firm's order placing system. 11pm is when the 
market closes so probably the dll has something done at that time that 
loops forever.
Using a separate process to call it is possible but exchanging data 
between my program and that process will slow down entire communication 
and time sensitivity is required for online trading program.  The 
supplier of the dll is quite irresponsive to questions or bug report.

Anyway, thanks for all your comments.

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


[fpc-pascal] is it possible to kill a thread from within fpc?

2014-09-25 Thread Dennis Poon
I want to kill a thread created by my fpc program (not killing the 
entire process).

I have to use an external win32 dll.
I am already calling it from a separate thread but still, that dll 
something goes into an infinite loop  which made my thread freezes.


How do I kill this particular thread? Just by calling MyThread.terminate 
definitely just does not work.


Is it even possible?

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


Re: [fpc-pascal] Is is impossible to extend a generic class in fpc 2..6.4?

2014-09-22 Thread Dennis Poon

Sven Barth wrote:

  generic TMyMapTKey, TData = class(specialize TFPGMapTKey, TData)
  end; 


Thanks a lot for your help.

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


[fpc-pascal] Is is impossible to extend a generic class in fpc 2..6.4?

2014-09-21 Thread Dennis Poon

Is it impossible to extend a generic class?
I tried to extend a generic class TFPGMap in fpl unit.

its original definition is:
 generic TFPGMapTKey, TData = class(TFPSMap)

I want to extend it by:
  generic TMyMapTKey, TData=class(TFPGMap )
  end;

I got this error: Generics without specialization cannot be used as a 
type for a variable



Then I tried:
  generic TMyMapTKey, TData=class(generic TFPGMapTKey, TData )
  end;

but I got Error: Identifier not found generic


I know it was not possible in the past. Just want to know whether it is 
still not possible in fpc 2.6.4.


Thanks.

Dennis

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


[fpc-pascal] how to implement a RTD server (COM Server) for windows

2014-09-17 Thread Dennis Poon

Window's DDE protocol is too old and the new one is called RTD.
I want to implement such an RTD server for Excel client to connect to.

Is there any examples of implementing COM server with fpc?

Where do I start?

Many thanks in advance.

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


[fpc-pascal] return 8 byte of return as function result via register

2014-09-12 Thread Dennis Poon
I am trying to use an external C++ dll and also privide call back 
functions to this dll to call back.
However, the dll requires my functions to return 8 byte of 'struct' via 
register and the dll author said it is not possible with Delphi.

Is that possible with fpc?

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


Re: [fpc-pascal] where to find documentation on fgl unit?

2014-09-11 Thread Dennis Poon



Michael Van Canneyt wrote:



On Thu, 11 Sep 2014, Dennis Poon wrote:


I googled and people said there isn't any.

Anyone knows?


That is because there really isn't any. It is on my todo list.

Michael.
___


Michael,

Are you the original author of fgl?


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


Re: [fpc-pascal] where to find documentation on fgl unit?

2014-09-11 Thread Dennis Poon



Michael Van Canneyt wrote:



On Thu, 11 Sep 2014, Dennis Poon wrote:




Michael Van Canneyt wrote:



On Thu, 11 Sep 2014, Dennis Poon wrote:


I googled and people said there isn't any.

Anyone knows?


That is because there really isn't any. It is on my todo list.

Michael.
___


Michael,

Are you the original author of fgl?


No, I am not. I don't use generics.
Micha Nelissen (or is it Misha ?) is the original author, I think.


It is very kind of you to add it to your to-do list.

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


[fpc-pascal] where to find documentation on fgl unit?

2014-09-10 Thread Dennis Poon

I googled and people said there isn't any.

Anyone knows?

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


Re: [fpc-pascal] Unhandled Exception

2014-09-08 Thread Dennis Poon



Steve Gatenby wrote:

I have an intermittant exception in my Lazarus app (Access violation)
My app also uses a freepascal library - I think the problem is within it

Can anybody suggest the best way to narrow this down to a unit / 
function / line ?
I believe I have the Frame stack captured, but have no idea what to do 
with it


I have read the wiki on logging exceptions, but this seems to only 
give me address info, and I cant figure how to translate this to 
something useful


Thanks - SteveG


May I ask whether you have tried enabling the debugger option?
  Project Options-Debugging-Generate Debug info for GDB
and then run the app within Lazarus.
When the AV occurs, it shall stop within lazarus and you can then go to 
View-Debug Windows-Call Stacks to see where the AV occur.


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


Re: [fpc-pascal] Improved array initialization in Delphi XE7

2014-09-03 Thread Dennis Poon



Sven Barth wrote:

Hello together!

Just today I've read that Delphi XE7 has introduced an improved array 
initialization and even in a way that I already planned to introduce 
it myself in FPC. That Embarcadero introduced this in Delphi is now of 
course a legitimate (:P) reason to introduce this in FPC as well.


For those that want to know more: 
http://tech.turbu-rpg.com/615/first-look-at-xe7


Regards,
Sven



Nice to have this new feature.

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


[fpc-pascal] how to convert C++ header to fpc

2014-08-14 Thread Dennis Poon
I don't know much about c++ and but I got this dll with the following 
header that I need to use its dll.



#define SPDLLCALL __stdcall

typedef void (SPDLLCALL *LoginReplyAddr)(long ret_code, char *ret_msg);

typedef void (SPDLLCALL *p_SPAPI_RegisterLoginReply)(LoginReplyAddr addr);


#endif

Can anyone kind enough to teach me how to translate them into pascal 
interface?


Thanks a lot.

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


Re: [fpc-pascal] how to convert C++ header to fpc

2014-08-14 Thread Dennis Poon



Victor Matuzenko wrote:


14.08.2014 19:31, Dennis Poon пишет:
I don't know much about c++ and but I got this dll with the following 
header that I need to use its dll.



#define SPDLLCALL __stdcall

typedef void (SPDLLCALL *LoginReplyAddr)(long ret_code, char *ret_msg);

typedef void (SPDLLCALL *p_SPAPI_RegisterLoginReply)(LoginReplyAddr 
addr);



#endif

Can anyone kind enough to teach me how to translate them into pascal 
interface?


type
LoginReplyAddr: procedure (ret_code: LongInt; ret_msg: PAnsiChar); 
stdcall;

p_SPAPI_RegisterLoginReply: procedure (addr: LoginReplyAddr); stdcall;

ret_code may be a parameter of type Int64 (it depends on how long type 
interpreted by C++ compiler).



Thanks so much.

Dennis

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

[fpc-pascal] why dynamic array created in constructor not automatically free in destructor

2014-08-07 Thread Dennis Poon

I have a class like;

TMyClass=class
public
  ar : array of integer;
  constructor Create;
 destructor destroy;override;
end;

TMyClass.Create;
begin
   inherited;
   SetLength(ar, 100);
end;

TMyClass.Destroy;
begin
   ar := nil;//--- this is needed otherwise a memory leak is reported!
  inherited;
end;
--

I would expect the compiler would automatically insert this ar := nil on 
my behalf because it seems like it does it for strings.

Am I missing some compiler directives?

Dennis



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


[fpc-pascal] TImage : how to avoid flickering when changing image

2014-08-05 Thread Dennis Poon
every few seconds, I want the same TImage  to load a different jpg file 
but now it flickers whenever

TheImage.Picture.LoadFromFile('new.jpg');

How do I avoid the flickering?

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


Re: [fpc-pascal] How to play H264 mp4 video using free pascal?

2014-07-23 Thread Dennis Poon



Graeme Geldenhuys wrote:

On 2014-07-22 12:19, Dennis Poon wrote:

what library (e.g. ffmpeg) should I call?

Michael van Canneyt did some work for us where we implemented libVLC
support (playing videos and sounds using the VLC backend). The code was
added to the Free Pascal project as far as I know. The GUI front-end
code (very small amount) was added to LCL and fpGUI. He code was tested
on Windows, Linux and FreeBSD systems.


Thanks Graeme,

But it seems that VLC does not utilize the GPU in raspberry pi, so the 
playback speed is too slow. :-(


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


Re: [fpc-pascal] How to play H264 mp4 video using free pascal?

2014-07-23 Thread Dennis Poon



Fabio Luis Girardi wrote:


Start omxplayer with tprocess and use pipes to do this

Em 22/07/2014 08:30, Dennis Poon den...@avidsoft.com.hk 
mailto:den...@avidsoft.com.hk escreveu:


what library (e.g. ffmpeg) should I call?
any example e.g. of it?

Actually, the target platform is Raspberry Pi (raspbian OS). It
comes with a video player that does it (omxplayer) but I don't
know how to interface with it apart from launching it.
After launch, I don't know how to pause it from my free pascal
program.

The goal is to have my program play an advertisement video as a
screen saver. When someone touches the mouse or keyboard, the
video pause and return to my program.

Thanks in advance.


Thanks.
But how do I detect that any mouse or keyboard changes by user now that 
the omxplayer is fullscreen has the focus?
I need to detect user interaction to pause the omxplayer and put my 
program back to the front.
The question in other words is how does a non-front program detect user 
inputs?


Thanks.

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

[fpc-pascal] How to play H264 mp4 video using free pascal?

2014-07-22 Thread Dennis Poon

what library (e.g. ffmpeg) should I call?
any example e.g. of it?

Actually, the target platform is Raspberry Pi (raspbian OS). It comes 
with a video player that does it (omxplayer) but I don't know how to 
interface with it apart from launching it.

After launch, I don't know how to pause it from my free pascal program.

The goal is to have my program play an advertisement video as a screen 
saver. When someone touches the mouse or keyboard, the video pause and 
return to my program.


Thanks in advance.

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


Re: [fpc-pascal] Free pascal candidate for project of the month

2014-03-27 Thread Dennis Poon



Mark Morgan Lloyd wrote:

Marco van de Voort wrote:

FYI:

Free Pascal is candidate for SF project of the month april, up against
strong candidates as subversion for windows (the server, not 
tortoise) and

smplayer.


That's a pretty strong field, but with no clear winner. I guess we 
should take that as a compliment.



Note that you need a SF login to vote:

https://sourceforge.net/p/potm/discussion/vote/thread/c38203c8/


This is the April POTM isn't it, so presumably we've got at least a 
couple of weeks to mobilise supporters. I'm sure more people have SF 
logins than can find them at short notice :-)


I'll prod a group of Delphi users I know, since while they might not 
have explored FPC I can phrase it as being good publicity for all 
variants of Object Pascal.




Thanks for the info. I just joined sourceforge just to vote for Freepascal.

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


Re: [fpc-pascal] TSQLQuery.ApplyUpdates problem with UTF-8

2014-03-25 Thread Dennis Poon




By the way, why isn't a semicolon required at the end of SET NAMES 
'utf8' command? I tried both with and without semicolon and neither 
raise an error.

Seems, that MySQL is tolerant to this.
MySQL supports MULTI_STATEMENTS, which enables client to pass multiple 
statements separated by ; in one string.
So may be, that MySQL interprets ; as delimiter between multiple 
statements on one batch.
If you use only one sql statement it is always better do not use 
terminating ; IMHO


-Laco.

The strange thing is, when we use MYSQL's interactive command line 
client, a semi colon is always required for EACH SQL Statement.


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


Re: [fpc-pascal] TSQLQuery.ApplyUpdates problem with UTF-8

2014-03-24 Thread Dennis Poon



LacaK wrote:

Dennis Poon  wrote / napísal(a):



I tried, the results are:

@@character_set_client  : utf8
@@character_set_connection  : latin1
@@character_set_database   : latin1



Dennis, do you received my reply?:

IMO @@character_set_connection is wrong and must be utf8.
I will try fix it, but first can you try as workaround this:
- after connection is established can you use 
MySQLConnection1.ExecuteDirect('SET NAMES ''utf8''');
- and then check again @@character_set_client, 
@@character_set_connection (IMO both must be utf8 ... if they will 
be, then your program should work as expected ... can you test it 
again?)


-Laco.


I tried  MYSQLConnection1.ExecuteDirect('SET NAMES ''utf8'';');
and recheck
  @@character_set_client: utf8
  @@character_set_connection : utf8
  @@character_set_database : latin1

So, it corrected one variable.

This is okay now



I re-ran my test but still  ?? after applyUpdates.

When I use your test program I receve same result as you describe.
But when I add into procedure TForm1.FormCreate(Sender: TObject);
begin
 MySQL55Connection1.ExecuteDirect('SET NAMES ''utf8''');  // -- ADDED
 SQLQuery1.Open;
end;

It works for me as expected ... so now I am confused with your 
results  ... can you try again please your test application with added 
line ...
(it will require patch for mysqlconnection in all cases, but before  
want have confirmed, that it helps)


-Laco.



Laco,

My apology. My last attempt did not recreate a fresh database table for 
testing so it started with the ruined table values and thus did not give 
the correct result.

Your Set Names command did the trick.
Thanks a lot.

By the way, why isn't a semicolon required at the end of SET NAMES 
'utf8' command? I tried both with and without semicolon and neither 
raise an error.


Dennis

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


Re: [fpc-pascal] TSQLQuery.ApplyUpdates problem with UTF-8

2014-03-20 Thread Dennis Poon



I tried, the results are:

@@character_set_client  : utf8
@@character_set_connection  : latin1
@@character_set_database   : latin1



Dennis, do you received my reply?:

IMO @@character_set_connection is wrong and must be utf8.
I will try fix it, but first can you try as workaround this:
- after connection is established can you use 
MySQLConnection1.ExecuteDirect('SET NAMES ''utf8''');
- and then check again @@character_set_client, 
@@character_set_connection (IMO both must be utf8 ... if they will be, 
then your program should work as expected ... can you test it again?)


-Laco.


I tried  MYSQLConnection1.ExecuteDirect('SET NAMES ''utf8'';');
and recheck
  @@character_set_client: utf8
  @@character_set_connection : utf8
  @@character_set_database : latin1

So, it corrected one variable.

I re-ran my test but still  ?? after applyUpdates.

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


Re: [fpc-pascal] Lazarus better than delphi

2014-03-20 Thread Dennis Poon



m...@rpzdesign.com wrote:

I have been using Delphi 7 forever.

I evaluated Delphi xe5 Update 2.

Today, I use Lazarus 1.2 and FPC 2.6.2.

Lazarus/FPC is just better than Delphi.

All development on Mac/Windows is now with Lazarus.

You FPC/Lazarus guys ROCK.

Best wishes for 2014.

md

I would like to second that. Delphi after Delphi 7 is disappointing, 
bulky and inefficient.

Thanks so much for you guys!

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


Re: [fpc-pascal] TSQLQuery.ApplyUpdates problem with UTF-8

2014-03-18 Thread Dennis Poon



LacaK wrote:

Dennis Poon  wrote / napísal(a):



Dennis Poon wrote:



Michael Van Canneyt wrote:



On Fri, 14 Mar 2014, Dennis Poon wrote:


the content appeared as garbage.

I already specified the CHARSET=utf8  in the Create Table SQL.


Did you set the TSQLConnection.Charset property to UTF8 as well ?



I set it to utf8 (UTF-8 will raise exception)  but still appears as 
garbage.


I wrote a test UI program use TDBGrid to edit the text with chinese 
and then refresh it.

The chinese text, after refreshing, appears as ???


... And
Can you please after connection is established check values of these 
system variables:

 character_set_client , character_set_connection, character_set_database
by
 select @@character_set_client , @@character_set_connection, 
@@character_set_database;

-LACO.


I tried, the results are:

@@character_set_client  : utf8
@@character_set_connection  : latin1
@@character_set_database   : latin1


Dennis


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


Re: [fpc-pascal] TSQLQuery.ApplyUpdates problem with UTF-8

2014-03-17 Thread Dennis Poon



Dennis Poon wrote:



Michael Van Canneyt wrote:



On Fri, 14 Mar 2014, Dennis Poon wrote:


the content appeared as garbage.

I already specified the CHARSET=utf8  in the Create Table SQL.


Did you set the TSQLConnection.Charset property to UTF8 as well ?



I set it to utf8 (UTF-8 will raise exception)  but still appears as 
garbage.


I wrote a test UI program use TDBGrid to edit the text with chinese 
and then refresh it.

The chinese text, after refreshing, appears as ???

Dennis


I even tried TSQLScript but it also failed and the chinese values appear 
as ??? in the updated record.
I suspect that TSQLConnection (or only when it works with MYSQL) failed 
to handle multi-byte charset.
I tried to step into the ApplyUpdates but the debugger did  not go into 
the procedure. Don't know why.


Dennis

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


[fpc-pascal] TSQLQuery.ApplyUpdates problem with UTF-8

2014-03-14 Thread Dennis Poon

Is TSQLQuery.AppleUpdate works with UTF8 string field content?

I fetched a web page and extracted part of its content and appended it 
into TSQLQuery record's string field.


The web page content is Chinese in UTF-8  encoding.
I 'writeln' the content before appending it and it appeared normal in 
the console.


The database is MYSQL 5.5 on ubuntu Intel 64-bit.

However, when I use MYSQL command to

   select * from MYTABLE;

the content appeared as garbage.

I already specified the CHARSET=utf8  in the Create Table SQL.

If I directly issue INSERT statement via MYSQL command prompt, it worked 
without garbage.


CREATE TABLE IF NOT EXISTS  `PROVIDERS` (
 `Key` int(10) unsigned NOT NULL auto_increment,
`CName` varchar(50) default '',
`Name` varchar(50) default '',

`Tel` varchar(50) default '',
`Address` varchar(200) default '',
`WebSite` varchar(80) default '',
`Email` varchar(50) default '',

`ListKey` int(10) signed default 0,
`PageNo` int(10) signed default 0,

PRIMARY KEY (`Key`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;


I suspect the problem is in TSQLQuery's  generating the Insert statement 
which did not take the string as UTF-8.


How do I confirm this suspicion? and how to solve it?

Thanks in advance.

Dennis

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


Re: [fpc-pascal] TSQLQuery.ApplyUpdates problem with UTF-8

2014-03-14 Thread Dennis Poon



Michael Van Canneyt wrote:



On Fri, 14 Mar 2014, Dennis Poon wrote:


the content appeared as garbage.

I already specified the CHARSET=utf8  in the Create Table SQL.


Did you set the TSQLConnection.Charset property to UTF8 as well ?



I set it to utf8 (UTF-8 will raise exception)  but still appears as garbage.

I wrote a test UI program use TDBGrid to edit the text with chinese and 
then refresh it.

The chinese text, after refreshing, appears as ???

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


Re: [fpc-pascal] Does TBufDataSet support Blob or memo field?

2014-01-16 Thread Dennis Poon



Dennis Poon wrote:
All the other usual types (e.g. integer, string, datetime) work except 
ftMemo and ftblob.


Yes, I have used POST

Dennis


LacaK wrote:

AFAIR this is so. (we can call it bug ;-))
Data are not there until you Post record.
After Post you will see data there, right?
-Laco.




LacaK,
My apology. You were right, values of blob/memo field of TbufDataset 
won't get updated after TDataset.POST

while other types have no such problem.

I checked my code again and I found I did post after I check the 
blob/memo field values.


I think it is probably a bug, rather than a feature as all fields should 
be the same:  values get updated even without calling post.


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


[fpc-pascal] Does TBufDataSet support Blob or memo field?

2014-01-13 Thread Dennis Poon

I created a TMemoField in TBufDataSet but no matter I do:

1) Field.asString := 'some value'
or
2) Field.LoadFromStream(someStream).

Afterwards, this F.AsString always returns ''
and
  F.LoadFromStream(someStream) always has a 0 BlobSize afterwards.

Anyone has similar experience?

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


Re: [fpc-pascal] Does TBufDataSet support Blob or memo field?

2014-01-13 Thread Dennis Poon
All the other usual types (e.g. integer, string, datetime) work except 
ftMemo and ftblob.


Yes, I have used POST

Dennis


LacaK wrote:

AFAIR this is so. (we can call it bug ;-))
Data are not there until you Post record.
After Post you will see data there, right?
-Laco.


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


Re: [fpc-pascal] cannot read /sys/class/net/eth1/address even as root user on linux

2014-01-02 Thread Dennis Poon



Michael Van Canneyt wrote:



On Thu, 5 Dec 2013, Dennis Poon wrote:


I tried to read the mac address in the captioned file path.
In terminal, I can simply 'cat' and display the mac address.

In FPC, when I tried to use TFileStream to read it,

 FS := TFileStream.Create('/sys/class/net/eth1/address', 
fmOpenRead+fmShareDenyWrite);


it raised stream read error


home: ./t
00:1f:d0:a2:df:c4

home: cat t.pp
{$mode objfpc}
{$H+}
uses sysutils, classes;

Var
  S : String;

begin
  SetLength(S,100);
  with TFileStream.Create('/sys/class/net/eth1/address', 
fmOpenRead+fmShareDenyWrite) do

try
  SetLength(S,Read(S[1],100));
  Writeln(S);
finally
  free;
end;
end.


Works fine here. Permission problem on your machine maybe ?

Michael.



So, strange.
I tried again and found that it works if I uses BaseUnix and then call 
fpRead but not with TFileStream.Read


My interface uses are:

uses
  Classes, SysUtils, DB, iniFiles;

My implementation uses:
uses md5, uStrUtils
  {$IFDEF UNIX}
 ,BaseUnix
  {$ENDIF}

  ;


function GetUnixMac(TheDevice : String) : String;
const
  UnixPath = '/sys/class/net/%s/address';
  var s,
  FileName : String;
  FS : TFilestream;

Var fHandle : cint;
len : longint;
buffer :string[255];
  begin
result := '';
FileName := Format(UnixPath,[TheDevice]);
if FileExists(FileName) then begin
//this fpread will work and give me mac address
fHandle:=fpOpen(FileName,O_RdOnly);
If fHandle  0 then
  try
len := fpRead (fHandle,buffer[1],255);
setlength(Buffer,len);

Log(TheDevice+' Mac:'+buffer);
result := StringReplace(buffer,#10,';',[rfReplaceAll]);
  finally
fpClose(fHandle);
  end;

{//strange, the following will raise stream read error
FS := TFilestream.Create(FileName, fmOpenRead+fmShareDenyWrite );
try
  if FS.Size  0 then begin
SetLength(s, FS.Size);
FS.ReadBuffer(s[1], FS.Size);
Log(TheDevice+' Mac:'+S);
result := StringReplace(s,#10,';',[rfReplaceAll]);
  end;
finally
  FreeAndNil(FS);
end;
}
end;
  end;

Why your machine works but my does not and has to rely on fpRead instead 
of TFileStream???


Dennis



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


Re: [fpc-pascal] Re: how to simplify try try except end finally end?

2013-12-27 Thread Dennis Poon


For what it's worth, I'm ambivalent. Not because I feel that try 
stacks couldn't or shouldn't be simplified, but because I feel that 
whoever overloaded  try  for two different structures should be shot.




I don't know enough about compiler. Could you kindly elaborate on the 
above please?


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


[fpc-pascal] how to simplify try try except end finally end?

2013-12-26 Thread Dennis Poon

Is there a way to further simplify the following?

I need to make the exception message more indicative of the context of 
the error and I hope to combine the 2

try blocks into one.

It seems possible in Java and C# but not in FPC.
Is there a way to combine them like

  try

  except

  finally

  end;

Dennis


Obj := TSomeObject.Create;
TheContext := 'after object creation';
try
  try
TheContext := 'Before doing task 1';
 //task 1

   TheContext := 'Before doing task 2';
   //task 2

   TheContext := 'Before doing task 3';
  //task 3
  finally
FreeAndNil(Obj);
  end;

except
  On E : Exception do begin
 E.Message := TheContext+E.Message ;
raise;
  end;
end;
-
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] FPC2.6 failed to raise compiler error Argument can't be assigned to' for Generic class' Record property in With clause

2013-12-13 Thread Dennis Poon

I think I found a bug in FPC 2.6.2.
In a method of a derived specialized class, the compiler does not raise 
error (which it should)

With record property do
   record property's field := NewValue   //it should raise error 
since it is a record property and should not be allowed to modify just 
one  field.


Please see below sample code for reproducing the error:

Dennis

--


Type

  RDevice=record
Value : String;
UpdatedAt : TDateTime;
  end;

  generic TGData TData =class(TComponent)
  private
FData :  TData;
  public
property Data : TData read FData;
  end;



  TDevice = class(specialize TGDataRDevice)
  published
procedure Test;
  end;

implementation

procedure TDevice.Test;
begin
  With Data do
Value := ''; //no Compiler Error raised !!!
  Data.Value := ''; //Compiler raised Error Argument can't be assigned to

end;





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


Re: [fpc-pascal] when will Free Pascal have a stable release of 2.7.2?

2013-12-11 Thread Dennis Poon
2.7.1 will become 2.8 sooner or later (*) and what's in trunk at that 
time will also be in 2.8.0 (and normally we don't deliberately remove 
things... ^^ ).


what is the timeframe of 'sooner or later'?  May I assume Q1 of 2014?

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


[fpc-pascal] how to define a generic subclass inheriting from another generic class?

2013-12-10 Thread Dennis Poon

What is the syntax. I could not find it in google.

e.g. in unit fgl,


generic TFPGMapTKey, TData=class(TFPSMap)

end;


How do I define a subclass TMyMap inheriting from TFPGMap without first 
specializing it?


I assumed

generic TMyMap TKey, TData = class(generic TFPGMapTKey, TData)
...
end

but fpc 2.6.2 did not accept this.

Please help.

Dennis


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


[fpc-pascal] when will Free Pascal have a stable release of 2.7.2?

2013-12-10 Thread Dennis Poon
There are quite some features I want to use there but I would wait until 
they are released a stable version.

Any idea?

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


[fpc-pascal] how to load openssl 32bit library in Lnet on centos 64 bit?

2013-12-06 Thread Dennis Poon

My ssl server program (using Lnet) was written and tested on Linux 32 bit.

The VPS I rented unfortunately is running CentOS 64 bit.

Although I have already installed the following 32 bit libs

yum install glibc.i686
yum install libstdc++.i686
yum install openssl.i686

However, when I run my ssl server program at the CentOS 64 bit, the 
program runs ok except it could not load the openssl library.


It failed at lNetSSL.ppCreateSSLContext

Can anyone teach me how to install openssl 32 bit on centos 64 bit and 
force lnet to load the 32bit openssl, not the 64 bit?



Dennis

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


[fpc-pascal] how to install sqlite server side library on CentOS

2013-12-06 Thread Dennis Poon

My server program written in fpc uses sqlite3 and
in ubuntu, I just need to
apt-get install libsqlite3-dev

but in centos, the libsqlite3-dev does not exist and the client lib after
   yum install sqlite
was not enough.

The server program still complained:  libsqlite3.so
 is missing.

Please help.


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


Re: [fpc-pascal] how to install sqlite server side library on CentOS

2013-12-06 Thread Dennis Poon



Jonas Maebe wrote:

On 06 Dec 2013, at 18:45, Dennis Poon wrote:

   

My server program written in fpc uses sqlite3 and
in ubuntu, I just need to
apt-get install libsqlite3-dev

but in centos, the libsqlite3-dev does not exist and the client lib after
   yum install sqlite
was not enough.

The server program still complained:  libsqlite3.so
is missing.
 

The default behaviour of almost all FPC database units is buggy in the sense 
that they look for *.so instead of for *.so.0, *.so.1 or similar files. The 
*.so file indeed only exists if you install the development addendum of a 
package, and it's just a symlink to the latest supported version (which is a 
*.so.0, *.so.1 or similar file). The only purpose of such a symlink is that in 
case you link to a library at compile time, the program will be linked against 
this latest installed version (under the assumption that it was also compiled 
using the .h files installed on the system, which belong to this same latest 
installed version). They should definitely never be used for dynamic loading, 
because
a) they generally do not (and should not) exist on user systems
b) they could point to any version, and the unit loading it may not support 
that version

In case of FPC, they actually shouldn't be used in case of compile-time linking 
either because of point b) above, and we should again explicitly link to 
specific versions.

Anyway, you can work around the specific problem you are having by telling the 
sqlite unit to use the specifically supported version by calling 
InitialiseSQLite('libsqlite.so.0'). It will work on both Ubuntu and CentOS and 
any other Linux distribution, and no one will have to install any -dev packages.

   


Jonas,

Thanks so much for your help but I tried putting
  InitialiseSQLite('libsqlite.so.0')
which did not work.

then I realised, you probably meant
 InitialiseSQLite('libsqlite3.so.0');

However, it then complained that SQLIte interface already initialized 
from library libsqlite3.so.0.


I seached files: sqlite3conn.pp, sqlite3dyn.pp, sqlite3.inc, dynlibs.inc 
but could not find where InitializeSQLite was called so could not 
replace that call from '.so' to '.so.0 '


However, I did find the default library name, used by the function 
InitiliseSQLite if no parameter is passed to it, which is composed of a 
default file extension defined in file dynlibs.inc

   const   SharedSuffix = 'so';

Since it is a constant, I dared not change it.

Eventually, I used command
 find / -name 'libsqlite3.so*'

and found on this CentOS 64 bit machine:

/usr/lib64/libsqlite3.so.0
/usr/lib64/sw/sqlite37/libsqlite3.so.0
/usr/lib64/sw/sqlite37/libsqlite3.so.0.8.6
/usr/lib64/libsqlite3.so.0.8.6

so, I created a symbolic link in /usr/lib64/
   ln -s libsqlite3.so.0 libsqlite3.so

and finally, it worked!

I don't know enough about database in FPC to suggest an improvement 
scheme but I do think such one is really in needed for future users.


Thanks Jonas for your help.

Dennis

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


[fpc-pascal] cannot read /sys/class/net/eth1/address even as root user on linux

2013-12-05 Thread Dennis Poon

I tried to read the mac address in the captioned file path.
In terminal, I can simply 'cat' and display the mac address.

In FPC, when I tried to use TFileStream to read it,

  FS := TFileStream.Create('/sys/class/net/eth1/address', 
fmOpenRead+fmShareDenyWrite);


it raised stream read error

If I tried to use TextFile and readln, it even halted the program.

My question is:
  Why 'cat' command can easily display this special file 'address' but 
TFileStream cannot.


I was told to use this method to get the MAC address of a network card, 
what other methods are there?


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


Re: [fpc-pascal] cannot read /sys/class/net/eth1/address even as root user on linux

2013-12-05 Thread Dennis Poon



While your method should work if that file actually exists, you probably
want to use libudev for enumerating and getting device information from
sysfs.  libudev will also enable you to get hotplug notification.

   

For your your reply.
The fact is:
1)  my linux distro starts with eth1 not eth0. Strange. I know.
2) my question was, why simply 'cat' works but I cannot read it from fpc 
usign Tfilestream or readlin(F, S);


Since I don't have time to invest in a portable solution, I am happy 
already if it works on my particular xubuntu distro.


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


Re: [fpc-pascal] paszlib problem: integer overflow

2013-11-14 Thread Dennis Poon



Dennis Poon wrote:
I downloaded the Paszlib-sg from 
http://sagsehome.net/oss/paszlib-sg.php (as suggested by Paszlib 
freepascal.org wiki).


I works fine on my Delphi 5 until I try to compress a file with size 
of 70M and it raises the exception of integer flow error.


Does anyone have this problem?

I initially thought it might be a Delphi 5 problem so I tried to use 
Lazarus with fpc 2.6.2 to compile the same problem but it kept 
complaining cannot find zstream although I already add FCL package to 
the required packages list.


Please help.

Dennis



I found the bug, it is in  zDeflat.pas
procedure fill_window

line 1595:
  Dec(s.match_start, wsize) ; //which gives integer underflow as 
s.match_start is  wsize and both paramters are defined as unit


When the file to compress is  30M in size

I am ok to avoid compressing any file that big but I just worried that 
this bug might happen in other situations as well.


Is anyone else using this paszlib?

Dennis

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


[fpc-pascal] any good data compression library for Free Pascal?

2013-11-14 Thread Dennis Poon

the paszlib has bug for large file sizes so I need another one.

Thanks.

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


Re: [fpc-pascal] paszlib problem: integer overflow

2013-11-14 Thread Dennis Poon

I works fine on my Delphi 5 until I try to compress a file with size

of 70M and it raises the exception of integer flow error.
   

That means you enabled that somehow. Integer under/overflow is generally not
enabled by default, and it is somewhat unlogical to use it with converted C
code.

   

I initially thought it might be a Delphi 5 problem so I tried to use
Lazarus with fpc 2.6.2 to compile the same problem but it kept
complaining cannot find zstream although I already add FCL package to
the required packages list.
   

Probably cause by providing external paszlib sources, in combination with
precompiled already there paszlib sources, the compiler gets confused what
depends on what.

Forget about the -sg code for Lazarus, simply use the FPC provided one only.
Turn off the range checks, and try again.

   


I'd love to just use the paszlib in Lazarus/fpc but I also need the same 
unit for Delphi 5 (Dephi 5 program will compress data and send to linux 
/lazarus/fpc program ) so both sides need to understand the same 
compress/decompress protocol.
I tried using the lazarus/fpc paszlib unit in Dephi 5 but it does not 
compile. Too many errors.
The paszlib-sg is the only pascal unit that produces compressed data 
readable by FPC's zstream and zipper units.


:-(

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


[fpc-pascal] paszlib problem: integer overflow

2013-11-13 Thread Dennis Poon
I downloaded the Paszlib-sg from http://sagsehome.net/oss/paszlib-sg.php 
(as suggested by Paszlib freepascal.org wiki).


I works fine on my Delphi 5 until I try to compress a file with size of 
70M and it raises the exception of integer flow error.


Does anyone have this problem?

I initially thought it might be a Delphi 5 problem so I tried to use 
Lazarus with fpc 2.6.2 to compile the same problem but it kept 
complaining cannot find zstream although I already add FCL package to 
the required packages list.


Please help.

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

Re: [fpc-pascal] UPnP Component

2013-11-11 Thread Dennis Poon



Dimitrios Chr. Ioannidis wrote:

Hi all,

  at work, i have a project which needs very limited UPnP 
capabilities. All it needs, is to open a port and do a port forwarding 
for a limited period of time closing it afterwards. Nowdays almost 
every Residential Gateway(Router) / ( Customer Premises Equipment ) 
support that via uPnP.


  I searched, if a portable ( i need it for windows, linux, ios and 
android ) component exists for free pascal and i didn't find anything. 
As i think that the UPnP functionality is very useful for various 
purposes, i decided to write a full implementation of UPnP for free 
pascal. But before i start, does anyone know any previous components / 
libraries that i didn't find so i don't do duplicate work ?


 regards,




I have searched for it in the past and found this:
http://www.whitebear.ch

I have not actually used it though. Don't remember why, probably because 
it does not compile without any extra work on my Delphi 5 or I did not 
understand the source code and how to use it.

You can start with this one. Please let us know your findings.

In the worst case and that did not work, you might try to use udp to do 
the upnp yourself for just that small portion of the protocol.


I would:
1) run winshark on the pc to monitor the udp traffic between the PC and 
the router,
2) launch skype or BitTorrent client and monitor what udp packets it 
exchanges with the router
3) go to the router browser page to see the upnp entries it set up after 
those packets were received by the router.


I sometimes think this reverse engineering is easier than reading the 
complex protocol which covers a lot of areas not related to my goal.


Good Luck.
Dennis

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


[fpc-pascal] any workable synapse https server (SSL) sample available?

2013-11-08 Thread Dennis Poon
I downloaded the synapse4.0 but the sample project httpSserver inside 
does not work.


When I pointed the Chrome and Firefox browser to http://192.168.1.4/

firefox reported:

Secure Connection Failed

  An error occurred during a connection to 192.168.1.4.

SSL received a record that exceeded the maximum permissible length.

(Error code: ssl_error_rx_record_too_long)

Chrome reported:


 SSL connection error

Unable to make a secure connection to the server. This may be a problem 
with the server, or it may be requiring a client authentication 
certificate that you don't have.

Error 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL protocol error.



Also, the httpserver program had Access Violations when terminated. 
(seems it forgets to call Terminate of all threads created).



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


Re: [fpc-pascal] any workable synapse https server (SSL) sample available?

2013-11-08 Thread Dennis Poon



waldo kitty wrote:

On 11/8/2013 9:59 AM, Dennis Poon wrote:
I downloaded the synapse4.0 but the sample project httpSserver inside 
does not

work.

When I pointed the Chrome and Firefox browser to http://192.168.1.4/


is that url accurate?


i can't help with that as all my synapse coding is done in console 
mode with no GUI mess at all...




Non GUI console mode sample will be great! please share.

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

[fpc-pascal] is there a way to list out all classes defined in a unit during run time?

2013-11-07 Thread Dennis Poon

I have a unit which I will incrementally add new subclasses of TCommand.

At run time, I want to get a list of subclasses of TCommand so that I 
can compare the where the user's required input (from network) matches 
the name of any TCommand.


Currently, I have to register each subclass in the initialization 
section of the unit.

Is there a way to list out all classes defined in a unit during run time?

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

[fpc-pascal] synapse + ssl on linux ,how to use libc

2013-10-22 Thread Dennis Poon
I need to use synapse + ssl on linux and it requires libc but I cannot 
locate this unit.

Can anyone help?


Also, has anyone used it before? Is it stable?
I have been using lnet + ssl but it was unstable , so wanted to try synapse.

Any comments are appreciated.

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

Re: [fpc-pascal] Re: what is the FPC equivalent of Delphi's zlib unit?

2013-10-14 Thread Dennis Poon
Please help. I am using Delphi 5's zlib procedure   
CompressBuf(src,SrcLen, Dest, DestLen);
to compress data to be decompressed by FPC's paszlib unit, but I don't 
know which one of the many procedure is the right right to use?

I tried uncompress(Dest, DestLen, Src, SrcLen) but it is obviously wrong.
It is urgent. Thanks a lot in advance.

Dennis


Reinier Olislagers wrote:

On 28/07/2013 22:53, Mark Morgan Lloyd wrote:
   

Michael Van Canneyt wrote:
 

There are 3 options:

  paszlib.pas pascal implementation of libz.

  zstream.pp  stream interface, uses paszlib.

  zlib.pp  native interface to C libz library.
   

Is any one of those more natural than the rest, because e.g. it's
already used for GIF handling?
 

paszlib/zstream
http://wiki.lazarus.freepascal.org/paszlib
used for zip support in FPC (TZipper).
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


-
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3349 / Virus Database: 3209/6528 - Release Date: 07/28/13


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

[fpc-pascal] which procedure is used for the old zlib decompression in the paszlib unit?

2013-10-14 Thread Dennis Poon

{This is a resend since the last email did not appear on the elist}

I am using the Delphi 5's zlib procedure CompressBuf (Src, SrcLen, Dest, 
DestLen)

to compress data to be decompressed by FPC's paszlib unit
but I don't know which one of the many procedure is the right one to use.

I already tried uncompress(Dest, DestLen, Src, SrcLen) but it failed.

Please kindly help.

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

Re: [fpc-pascal] [OT] sealed?

2013-10-07 Thread Dennis Poon

 It is wonderful, thank you very much Sven! :)


Well, the opinion whether this feature is wonderful or not differs 
among FPC/Delphi users :P


Regards,
Sven

May I know the usual use of such feature?  I can only think of library 
vendors want to seal a class to prevent users from modifying it without 
paying for an upgraded/better version of such class.


Dennis



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


-
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6731 - Release Date: 10/07/13



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


[fpc-pascal] is it possible to subclass a generic class?

2013-10-06 Thread Dennis Poon

I want to do something like this but the compile complains.

Type
generic TMyMapTKey, TData =class( generic TFPGMapTKey, TData)
  destructor Destroy; override;
  constructor Create;
end;


I want to override some methods and destructor before my class is 
specialized later.


Is it possible? How?

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

Re: [fpc-pascal] does Advanced Record constructor automatically zero all the memory space of that record?

2013-10-04 Thread Dennis Poon

Thanks a lot for clarification.

Dennis

Sven Barth wrote:

On 04.10.2013 14:48, Dennis Poon wrote:



You can use either FillChar as you did or use Self :=
Default(TTest); (default is a compiler intrinsics that returns a 0
value of the type you passed in, e.g. Nil for classes, '' for strings,
0 for ordinals and for records all fields are set to 0)

How can I make it so that I only do the Self := Default() once in the
parent class constructor and don't have to repeat it in all its
descendant class constructor.


Why would you want to do that? Classes are already zero initialized 
when the constructor is entered.
Also using Self := Default(...) inside a class would not do what you 
expect it to do. Self is a class reference and thus Default(...) 
of the same type would return Nil and thus set your Self for the 
current method call to Nil (so you could no longer access the class 
instance at all).



I noticed in your example, you have to specify the class name TTest but
that implies in every descendant class,  I have to replace it with the
Descendant class name.

Can I do
   self := Default(ClassType) ?
hoping it will return the descendant's class type?


Default expects a type identifier and nothing else. I currently don't 
know whether Delphi supports more. But in any way it wouldn't change 
much as Default(TObject) = Default(TSomeClass) = 
Default(TSomeChildClass) = Nil.


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


-
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6723 - Release Date: 10/04/13


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

Re: [fpc-pascal] how to directly access field/record value of TBufDataSet?

2013-10-01 Thread Dennis Poon



Michael Van Canneyt wrote:



On Tue, 1 Oct 2013, Dennis Poon wrote:

Since TBufDataSet is in-memory, to speed things up, how can I 
directly access the N'th record and M'th field's value as Variant?


Simply said: You cannot.



Can any one suggest an in-memory dataset in fpc/lazarus that allows 
direct access?


Does TMemDataset allow it?


No. The architecture of TDataset does not allow this.

The buffer mechanism is quite complicated, and there are quite some 
layers to go through.


T(Mem)Dataset is not just an array of records. The records can be at 
wildly different locations,
the values may or may not be computed. Blobs are stored entirely in 
different locations etc.


Michael.



That is too bad. I used to use TdxMemData from DevExpress and it 
allows such direct access.


The benefit is record can be accessed without CHANGING the current 
record pointer which will trigger updating of all linked DB controls 
(that could be time consuming or even confusing to the user).

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


[fpc-pascal] property TField.AutoGenerateValue missing in 2.6.2

2013-09-30 Thread Dennis Poon

I just noticed the above property is missing in FPC 2.6.2

I am porting some old delphi code to FPC and noticed it.
If I simply ignore this property value (always assume it to be arNone), 
will it cause any problem?



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

  1   2   >