Re: Re[2]: [fpc-pascal] fpWeb and html and uri escaping/unescaping elements
On Tue, May 24, 2011 at 12:21, José Mejuto joshy...@gmail.com wrote: Hello FPC-Pascal, Tuesday, May 24, 2011, 10:09:03 AM, you wrote: i I've created a patch with the Escape and unEscape functions, and place it i here: http://bugs.freepascal.org/view.php?id=19407 Un/escapeHTML parsing must be in one go, specially the amp one. Test against: amp;lt; I'm not sure what you mean here. If you have already html entities you should not escape them. If you do not have html entities you should escape them. The Escaping and unescaping works well, I already tested them before I sent them. Right unescape lt;, your code . -- Best regards, José Ido ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: TimSort
In our previous episode, Mattias Gaertner said: A quick look at wikipedia will show that timsort has a disadvantage too. It needs up to N records memory, not just Log(n) records like e.g. Quicksort. It *can* be implemented to need only log(n). But the current fpc implementation of QuickSort seems to need O(n) memory on the stack. Hmm. Then that should be fixed. TimSort needs up to N/2 pointer, which is better than a simple MergeSort. For heavier sorting I usually use heapsort and quicksort routines that date back to my M2 days Usually heapsort since it is quite fast for already sorted collections. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
RE : Re[2]: [fpc-pascal] fpWeb and html and uri escaping/unescapingelements
You should not unescape recursively. Input to EscapeHTML: 'lt;' Output: 'amp;lt;' : Correct UnescapeHTML: input 'amp;lt;' Output '' Wrong. This is because you replace 'amp;' with '' resulting in 'lt;' which is translated to ' ' in the next line. Ludo -Message d'origine- De : fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part de ik Envoyé : mercredi 25 mai 2011 08:34 À : FPC-Pascal users discussions Objet : Re: Re[2]: [fpc-pascal] fpWeb and html and uri escaping/unescapingelements On Tue, May 24, 2011 at 12:21, José Mejuto joshy...@gmail.com wrote: Hello FPC-Pascal, Tuesday, May 24, 2011, 10:09:03 AM, you wrote: i I've created a patch with the Escape and unEscape functions, and place it i here: http://bugs.freepascal.org/view.php?id=19407 Un/escapeHTML parsing must be in one go, specially the amp one. Test against: amp;lt; I'm not sure what you mean here. If you have already html entities you should not escape them. If you do not have html entities you should escape them. The Escaping and unescaping works well, I already tested them before I sent them. Right unescape lt;, your code . -- Best regards, José Ido ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: RE : Re[2]: [fpc-pascal] fpWeb and html and uri escaping/unescapingelements
On Wed, May 25, 2011 at 10:09, Ludo Brands ludo.bra...@free.fr wrote: You should not unescape recursively. Input to EscapeHTML: 'lt;' Output: 'amp;lt;' : Correct UnescapeHTML: input 'amp;lt;' Output '' Wrong. This is because you replace 'amp;' with '' resulting in 'lt;' which is translated to ' ' in the next line. So you suggest to place the amp; translation last. Ludo -Message d'origine- *De :* fpc-pascal-boun...@lists.freepascal.org [mailto: fpc-pascal-boun...@lists.freepascal.org] *De la part de* ik *Envoyé :* mercredi 25 mai 2011 08:34 *À :* FPC-Pascal users discussions *Objet :* Re: Re[2]: [fpc-pascal] fpWeb and html and uri escaping/unescapingelements On Tue, May 24, 2011 at 12:21, José Mejuto joshy...@gmail.com wrote: Hello FPC-Pascal, Tuesday, May 24, 2011, 10:09:03 AM, you wrote: i I've created a patch with the Escape and unEscape functions, and place it i here: http://bugs.freepascal.org/view.php?id=19407 Un/escapeHTML parsing must be in one go, specially the amp one. Test against: amp;lt; I'm not sure what you mean here. If you have already html entities you should not escape them. If you do not have html entities you should escape them. The Escaping and unescaping works well, I already tested them before I sent them. Right unescape lt;, your code . -- Best regards, José Ido ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: TimSort
On Wed, 25 May 2011 09:02:46 +0200 (CEST) mar...@stack.nl (Marco van de Voort) wrote: In our previous episode, Mattias Gaertner said: A quick look at wikipedia will show that timsort has a disadvantage too. It needs up to N records memory, not just Log(n) records like e.g. Quicksort. It *can* be implemented to need only log(n). But the current fpc implementation of QuickSort seems to need O(n) memory on the stack. Hmm. Then that should be fixed. It must choose the smaller half for the tail call. TimSort needs up to N/2 pointer, which is better than a simple MergeSort. For heavier sorting I usually use heapsort and quicksort routines that date back to my M2 days Usually heapsort since it is quite fast for already sorted collections. Yes, but Heapsort is not stable too. Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
RE : [fpc-pascal] fpWeb and html and uri escaping/unescaping elements
This is a very minimalistic implementation covering only partial ascii character escaping. To cover ASCII only in unescapeHTML you should also add 'nbsp' which corresponds with the space character ' '. Also the format #entity_number; is missing ('lt;' or '#60;' equals '') To support iso-8859-1 which is default in most browsers you'll need a lot more. See f.e. http://www.w3schools.com/tags/ref_entities.asp Ludo -Message d'origine- De : fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part de ik Envoyé : mardi 24 mai 2011 10:09 À : FPC-Pascal users discussions Objet : Re: [fpc-pascal] fpWeb and html and uri escaping/unescaping elements On Tue, May 24, 2011 at 00:28, ik ido...@gmail.com wrote: On Tue, May 24, 2011 at 00:23, Michael Van Canneyt mich...@freepascal.org wrote: On Tue, 24 May 2011, ik wrote: Hello, Does fpWeb have any method/function that escape and un-escape html and URI elements ? Yes. in fphttpclient: Function EncodeURLElement(S : String) : String; Function DecodeURLElement(Const S : String) : String; We should maybe move them to URIParser or maybe even strutils. I can not find any HTML encode and decode, I'll make one and open a bug with the patches. Where do you think it will be best to place it (I mean the unit) ? I've created a patch with the Escape and unEscape functions, and place it here: http://bugs.freepascal.org/view.php?id=19407 Michael. Thanks, Ido ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re[4]: [fpc-pascal] fpWeb and html and uri escaping/unescaping elements
Hello FPC-Pascal, Wednesday, May 25, 2011, 8:33:57 AM, you wrote: amp;lt; i I'm not sure what you mean here. That's an already escaped html. Let it be a mini htmlpage: htmltitle-amp;lt;-/title/html i If you have already html entities you should not escape them. If you do not i have html entities you should escape them. i The Escaping and unescaping works well, I already tested them before I sent i them. The right content of title tag is -lt;- when unescaped but the code unescapehtml produce --. Explanation step by step: 1) The code looks for all 'amp;' 2) When found replace it by '' 3) title content is now -lt;- 4) Now the code looks for 'lt;' 5) When found replace it by '' 6) Now title content is -- -- Result := StringReplace(s, 'amp;', '', [rfReplaceAll]); Result := StringReplace(Result, 'lt;', '', [rfReplaceAll]); -- I hope my explanations are now understandable. -- Best regards, José ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re[2]: [fpc-pascal] Re: TimSort
Hello FPC-Pascal, Wednesday, May 25, 2011, 9:02:46 AM, you wrote: MvdV For heavier sorting I usually use heapsort and quicksort routines that date MvdV back to my M2 days MvdV Usually heapsort since it is quite fast for already sorted collections. Instead HeapSort you can use SmoothSort which is around 10-20% faster in almost all conditions (sorted or not) and have the same memory and best/worst case constraints. -- Best regards, José ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
RE : RE : Re[2]: [fpc-pascal] fpWeb and html and uriescaping/unescapingelements
So you suggest to place the amp; translation last. That would be a solution for this problem. My previous comments on the minimalistic approach of the implementation suggest a different approach: scan the source string once and replace html entities as you find them (with a look up table for example). This would scale much better when implementing iso-8859-1 or '#entity-number;' unescaping . Ludo -Message d'origine- De : fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part de ik Envoyé : mercredi 25 mai 2011 09:22 À : FPC-Pascal users discussions Objet : Re: RE : Re[2]: [fpc-pascal] fpWeb and html and uriescaping/unescapingelements On Wed, May 25, 2011 at 10:09, Ludo Brands ludo.bra...@free.fr wrote: You should not unescape recursively. Input to EscapeHTML: 'lt;' Output: 'amp;lt;' : Correct UnescapeHTML: input 'amp;lt;' Output '' Wrong. This is because you replace 'amp;' with '' resulting in 'lt;' which is translated to ' ' in the next line. So you suggest to place the amp; translation last. Ludo -Message d'origine- De : fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part de ik Envoyé : mercredi 25 mai 2011 08:34 À : FPC-Pascal users discussions Objet : Re: Re[2]: [fpc-pascal] fpWeb and html and uri escaping/unescapingelements On Tue, May 24, 2011 at 12:21, José Mejuto joshy...@gmail.com wrote: Hello FPC-Pascal, Tuesday, May 24, 2011, 10:09:03 AM, you wrote: i I've created a patch with the Escape and unEscape functions, and place it i here: http://bugs.freepascal.org/view.php?id=19407 Un/escapeHTML parsing must be in one go, specially the amp one. Test against: amp;lt; I'm not sure what you mean here. If you have already html entities you should not escape them. If you do not have html entities you should escape them. The Escaping and unescaping works well, I already tested them before I sent them. Right unescape lt;, your code . -- Best regards, José Ido ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: RE : RE : Re[2]: [fpc-pascal] fpWeb and html and uriescaping/unescapingelements
On Wed, May 25, 2011 at 14:04, Ludo Brands ludo.bra...@free.fr wrote: So you suggest to place the amp; translation last. That would be a solution for this problem. My previous comments on the minimalistic approach of the implementation suggest a different approach: scan the source string once and replace html entities as you find them (with a look up table for example). This would scale much better when implementing iso-8859-1 or '#entity-number;' unescaping . For every html entity you need a dictionary, and that's makes your program with more fat. converting number entity can be done, but you need to know what is the code page you wish to convert from/to. Ludo Ido -Message d'origine- *De :* fpc-pascal-boun...@lists.freepascal.org [mailto: fpc-pascal-boun...@lists.freepascal.org] *De la part de* ik *Envoyé :* mercredi 25 mai 2011 09:22 *À :* FPC-Pascal users discussions *Objet :* Re: RE : Re[2]: [fpc-pascal] fpWeb and html and uriescaping/unescapingelements On Wed, May 25, 2011 at 10:09, Ludo Brands ludo.bra...@free.fr wrote: You should not unescape recursively. Input to EscapeHTML: 'lt;' Output: 'amp;lt;' : Correct UnescapeHTML: input 'amp;lt;' Output '' Wrong. This is because you replace 'amp;' with '' resulting in 'lt;' which is translated to ' ' in the next line. So you suggest to place the amp; translation last. Ludo -Message d'origine- *De :* fpc-pascal-boun...@lists.freepascal.org [mailto: fpc-pascal-boun...@lists.freepascal.org] *De la part de* ik *Envoyé :* mercredi 25 mai 2011 08:34 *À :* FPC-Pascal users discussions *Objet :* Re: Re[2]: [fpc-pascal] fpWeb and html and uri escaping/unescapingelements On Tue, May 24, 2011 at 12:21, José Mejuto joshy...@gmail.com wrote: Hello FPC-Pascal, Tuesday, May 24, 2011, 10:09:03 AM, you wrote: i I've created a patch with the Escape and unEscape functions, and place it i here: http://bugs.freepascal.org/view.php?id=19407 Un/escapeHTML parsing must be in one go, specially the amp one. Test against: amp;lt; I'm not sure what you mean here. If you have already html entities you should not escape them. If you do not have html entities you should escape them. The Escaping and unescaping works well, I already tested them before I sent them. Right unescape lt;, your code . -- Best regards, José Ido ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: RE : RE : RE : [fpc-pascal] support for using an activex
2011/5/24 Ludo Brands ludo.bra...@free.fr: The following delphi articles should help creating an event sink: http://www.informit.com/articles/article.aspx?p=130494seqNum=5 This is an interesting one since it is written for Delphi 3-4 which missed a lot of the automated COM handling. This is much closer to where fpc is now. http://www.blong.com/Conferences/IConUK2000/DelphiMoreAutomation/More%20Auto mation%20In%20Delphi.htm#HandcraftedEventSink A good intruduction to connectable objects: http://www.gtro.com/delphi/comevents_e.php Thanks a lot! I'm reading it all and writing some code. But in all of those docs there the InterfaceConnect routine is usedbut I can't find it anywhere. Besides, is there something to convert the tlb to pascal? Or shall I do it manually? I might be wrong, but it seems to me that it should be possible to write a general TSimpleEventSink class which does most of all the COM work, and exposes a pascal-standard event management. The TSimpleEventSink class might have an Events property which is a dynamic array of TNotifyEvents; the client could resize it and link its event handlers. At the same time the TSimpleEventSink reacts to the server events by mapping the dispid's to the Events array index, up to its current maximum dimension. Well, I'm still quite confused besides the missing InterfaceConnect method, is there any freepascal example available? On the web I can only find delphi ones. Thanks, Roberto ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
RE : RE : RE : RE : [fpc-pascal] support for using an activex
Interfaceconnect calls Advice on the objects IConnectionPoint. I can't share Delphi code here but essentially what you do is: Get IConnectionPointContainer (CPC) from IUnknown (ActiveXObject) : ActiveXObject.QueryInterface(IConnectionPointContainer, CPC); Get IConnectionPoint (ppcp) for the IID of interest (RIID) from IConnectionPointContainer : CPC.FindConnectionPoint(RIID, ppcp); Call Advice on IConnectionPoint (ppcp) with the sink interface you created : CP.Advise(unkSink, dwCookie); That's it! Keep hold of dwCookie as it is used to disconnect later on: CP.UnAdvise(dwCookie); Ludo -Message d'origine- De : fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part de Roberto Padovani Envoyé : mercredi 25 mai 2011 13:18 À : FPC-Pascal users discussions Objet : Re: RE : RE : RE : [fpc-pascal] support for using an activex 2011/5/24 Ludo Brands ludo.bra...@free.fr: The following delphi articles should help creating an event sink: http://www.informit.com/articles/article.aspx?p=130494seqNum=5 This is an interesting one since it is written for Delphi 3-4 which missed a lot of the automated COM handling. This is much closer to where fpc is now. http://www.blong.com/Conferences/IConUK2000/DelphiMoreAutomation/More% 20Auto mation%20In%20Delphi.htm#HandcraftedEventSink A good intruduction to connectable objects: http://www.gtro.com/delphi/comevents_e.php Thanks a lot! I'm reading it all and writing some code. But in all of those docs there the InterfaceConnect routine is usedbut I can't find it anywhere. Besides, is there something to convert the tlb to pascal? Or shall I do it manually? I might be wrong, but it seems to me that it should be possible to write a general TSimpleEventSink class which does most of all the COM work, and exposes a pascal-standard event management. The TSimpleEventSink class might have an Events property which is a dynamic array of TNotifyEvents; the client could resize it and link its event handlers. At the same time the TSimpleEventSink reacts to the server events by mapping the dispid's to the Events array index, up to its current maximum dimension. Well, I'm still quite confused besides the missing InterfaceConnect method, is there any freepascal example available? On the web I can only find delphi ones. Thanks, Roberto ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: RE : RE : RE : RE : [fpc-pascal] support for using an activex
2011/5/25 Ludo Brands ludo.bra...@free.fr: Regarding the tlb to pascal conversion, AFAIK there is no support in fpc. Delphi is clearly better equiped to work with COM objects. I have also been playing around with a generic eventsink class but the problem is that events can have parameters (and a lot do). Your suggestion of using TNotifyEvents could work for events without parameters. You could leave the parameter stuff to the user of the eventsink, eventually helping him by exposing the number and type of parameters, but that means that the user has to have a reasonable good understanding of COM, including the data types compatible with COM marshalling. Thanks for the explanation. In fact, that is the reason why I called it TSimpleEventSink, meaning that it was good for simple situation. In my case, for example, the activex controls a hardware stuff which only request the user to take an action sometimes. In the C++ source code for the class Device I have: [ uuid(168F5642-5751-49F5-9AA4-B8A7A5F6A5B8), helpstring(_IDeviceEvents Interface) ] dispinterface _IDeviceEvents { properties: methods: [id(1), helpstring(method OnCommChanged)] HRESULT OnCommChanged(); [id(2), helpstring(method OnStatesChanged)] HRESULT OnStatesChanged(); [id(3), helpstring(method OnContact)] HRESULT OnContact(); [id(4), helpstring(method OnMeasUpdate)] HRESULT OnMeasUpdate(); }; where this four simple events only alert the user about a change situation; then the user takes the suitable actions. Do you think it could work for me? Now I'm trying to write by hand a minimalist tlb, looking for the definitions in the activex source code Thanks a lot!! Roberto ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: fpc-pascal Digest, Vol 83, Issue 52
El 25/05/2011 01:35 a.m., fpc-pascal-requ...@lists.freepascal.org escribió: Question out of curiosity: Is there a reason why you allocate an array by hand? Yes, getmem return NIL, when no more memory is available. SetLength, no return NIL, It is work with Exceptions. My intention was whether it could be done without using dynamic arrays and Exceptions. But two more questions: 1) At this program: Var A:Ansistring; Begin A:='Hi'; End. The literal String is at Data area. Is the A variable points to Data Segment. ? 2) My computer is little endian. (intel) When I do this: a: = $ ABFE5689 / / Little endian $ 8956FEAB, it is ok Writeln (Hi (a)) / / Show $ ABFE, it is ok Writeln (Lo (a)) / / Show $ 5689, it is ok In a Big Endian computer. What shows Hi and Lo? thanks. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
RE : RE : RE : RE : RE : [fpc-pascal] support for using an activex
The code in article http://www.informit.com/articles/article.aspx?p=130494seqNum=5 goes a long way in doing what you want to do. Unit Eventsink does pretty much of the legwork. You should remove the procedure register since that is the Delphi way to get a component on the toolbar. Remove also the {$IFDEF VER100} and {$ENDIF}. The unit actually includes the code for InterfaceConnect!! In the MainForm unit you'll have to do in a TForm1.Create EventSink1:=TEventSink.Create(Self); EventSink1.OnInvoke:=@EventSink1Invoke; because the example assumes you have dropped the component on the form and entered EventSink1Invoke in the properties box. As for the tlb conversion, in your case IEventIntfEvents = dispinterface ['{168F5642-5751-49F5-9AA4-B8A7A5F6A5B8}'] end; should do (that is for the events part). AFAIK the procedure and dispid definitions are only needed for the server. You are only concerned with dispid's. No need to create prototypes for OnCommChanged() etc. EventSink1Invoke would be a simple case DispID of 1: // do CommChanged 2: // do StatesChanged ... end; Ludo -Message d'origine- De : fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part de Roberto Padovani Envoyé : mercredi 25 mai 2011 16:01 À : FPC-Pascal users discussions Objet : Re: RE : RE : RE : RE : [fpc-pascal] support for using an activex 2011/5/25 Ludo Brands ludo.bra...@free.fr: Regarding the tlb to pascal conversion, AFAIK there is no support in fpc. Delphi is clearly better equiped to work with COM objects. I have also been playing around with a generic eventsink class but the problem is that events can have parameters (and a lot do). Your suggestion of using TNotifyEvents could work for events without parameters. You could leave the parameter stuff to the user of the eventsink, eventually helping him by exposing the number and type of parameters, but that means that the user has to have a reasonable good understanding of COM, including the data types compatible with COM marshalling. Thanks for the explanation. In fact, that is the reason why I called it TSimpleEventSink, meaning that it was good for simple situation. In my case, for example, the activex controls a hardware stuff which only request the user to take an action sometimes. In the C++ source code for the class Device I have: [ uuid(168F5642-5751-49F5-9AA4-B8A7A5F6A5B8), helpstring(_IDeviceEvents Interface) ] dispinterface _IDeviceEvents { properties: methods: [id(1), helpstring(method OnCommChanged)] HRESULT OnCommChanged(); [id(2), helpstring(method OnStatesChanged)] HRESULT OnStatesChanged(); [id(3), helpstring(method OnContact)] HRESULT OnContact(); [id(4), helpstring(method OnMeasUpdate)] HRESULT OnMeasUpdate(); }; where this four simple events only alert the user about a change situation; then the user takes the suitable actions. Do you think it could work for me? Now I'm trying to write by hand a minimalist tlb, looking for the definitions in the activex source code Thanks a lot!! Roberto ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: Suffix Trie implementation, please review
I guess you forgot the attachment? My bad... well it was midnight here ;) There you go: http://free-pascal-general.1045716.n5.nabble.com/file/n4425751/suffixtrie.zip suffixtrie.zip BTW, do you know the hashtrie component? Only ever heard of, never know the details. Thanks, this could be a lesson to learn. The improvement over hashtable seems to be in the lookup, so it still uses hashing to generate initial index which in simple case, like in the page you point, operates on the whole string (i.e. O(n)). The lookup would take additional processing. Anyway, it's not really comparable to suffix tries. Instead, it's comparable to (prefix) tries. For lookup and update, tries should perform better. But the disadvantage is that no item may get out once it gets in (at least not so easy). -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Suffix-Trie-implementation-please-review-tp4422708p4425751.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: RE : RE : RE : RE : RE : [fpc-pascal] support for using an activex
2011/5/25 Ludo Brands ludo.bra...@free.fr: The code in article http://www.informit.com/articles/article.aspx?p=130494seqNum=5 goes a long way in doing what you want to do. Unit Eventsink does pretty much of the legwork. You should remove the procedure register since that is the Delphi way to get a component on the toolbar. Remove also the {$IFDEF VER100} and {$ENDIF}. The unit actually includes the code for InterfaceConnect!! found that! great! As for the tlb conversion, in your case IEventIntfEvents = dispinterface ['{168F5642-5751-49F5-9AA4-B8A7A5F6A5B8}'] end; should do (that is for the events part). AFAIK the procedure and dispid definitions are only needed for the server. You are only concerned with dispid's. No need to create prototypes for OnCommChanged() etc. EventSink1Invoke would be a simple case DispID of 1: // do CommChanged 2: // do StatesChanged ... end; Now I am wasting time making the tlb pascal definitions. For the event part I'm fine with the dispid's Until now I was calling the activex method with variants, in and out, but now I discovered that this IDevice class has a property like: property Sensors: ISensors; which inside is a list of items like Sensor: ISensor. Can I read the sensores with a variant? Then, to see the fields inside each sensor, I think a I need a class to do that... The activex has all of these classes with the suitable dispinterfaces and uuids and so on. But if I define var device, transducers, transducer : variant; and create device := CreateOleObject('Device'); then, can i simply write the following ? transducers := device.Transducers; transducer := transducers[index]; It's a long path until I get this stuff working... R# ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] getmem
El 25/05/2011 01:35 a.m., fpc-pascal-requ...@lists.freepascal.org escribió: Question out of curiosity: Is there a reason why you allocate an array by hand? Yes, getmem return NIL, when no more memory is available. SetLength, no return NIL, It is work with Exceptions. My intention was whether it could be done without using dynamic arrays and Exceptions. But two more questions: 1) At this program: Var A:Ansistring; Begin A:='Hi'; End. The literal String is at Data area. Is the A variable points to Data Segment. ? 2) My computer is little endian. (intel) When I do this: a: = $ ABFE5689 / / Little endian $ 8956FEAB, it is ok Writeln (Hi (a)) / / Show $ ABFE, it is ok Writeln (Lo (a)) / / Show $ 5689, it is ok In a Big Endian computer. What shows Hi and Lo? thanks. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
RE : RE : RE : RE : RE : RE : [fpc-pascal] support for using an activex
Using variants you can transparently walk along the exposed objects. The variant contains the Idispatch of the object and gets the exposed methods at runtime. Properties are implemented as get and put methods or just get methods for read only properties. If you have something like Itransducers = interface .. property transducer[Index:integer]:Itransducer; end; Then you would do transducer := transducers.transducer[index]; transducer := transducers[index]; works only if transducer is the default property for Itransducers. I'm not sure if fpc supports this. Ludo -Message d'origine- De : fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part de Roberto Padovani Envoyé : mercredi 25 mai 2011 19:34 À : FPC-Pascal users discussions Objet : Re: RE : RE : RE : RE : RE : [fpc-pascal] support for using an activex 2011/5/25 Ludo Brands ludo.bra...@free.fr: The code in article http://www.informit.com/articles/article.aspx?p=130494seqNum=5 goes a long way in doing what you want to do. Unit Eventsink does pretty much of the legwork. You should remove the procedure register since that is the Delphi way to get a component on the toolbar. Remove also the {$IFDEF VER100} and {$ENDIF}. The unit actually includes the code for InterfaceConnect!! found that! great! As for the tlb conversion, in your case IEventIntfEvents = dispinterface ['{168F5642-5751-49F5-9AA4-B8A7A5F6A5B8}'] end; should do (that is for the events part). AFAIK the procedure and dispid definitions are only needed for the server. You are only concerned with dispid's. No need to create prototypes for OnCommChanged() etc. EventSink1Invoke would be a simple case DispID of 1: // do CommChanged 2: // do StatesChanged ... end; Now I am wasting time making the tlb pascal definitions. For the event part I'm fine with the dispid's Until now I was calling the activex method with variants, in and out, but now I discovered that this IDevice class has a property like: property Sensors: ISensors; which inside is a list of items like Sensor: ISensor. Can I read the sensores with a variant? Then, to see the fields inside each sensor, I think a I need a class to do that... The activex has all of these classes with the suitable dispinterfaces and uuids and so on. But if I define var device, transducers, transducer : variant; and create device := CreateOleObject('Device'); then, can i simply write the following ? transducers := device.Transducers; transducer := transducers[index]; It's a long path until I get this stuff working... R# ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: RE : RE : RE : RE : RE : RE : [fpc-pascal] support for using an activex
Always thanks! Given your evident experience on this matter, I kindly ask your advice on what is best to do. opt 1) create a fpc class with some pascal style methods, which in their implementation use variants and call the IDevice class with late-binding . meaning that there is no compiler check and if my collegue changes the dll, then I have to change these implementations opt 2) in a reference of those you sent me, there is some example code from which I take the lines below. In the tlb conversion unit, the interface and dispinterface of the class are some replicated. Then also the eventinterface is defined. The main interface class is defined without and with dispids. With the dispids, only the properties are defined and not the methods. IFileZapper = interface(IDispatch) ['{2E2FC5E0-5C0E-4C4F-8CC1-D9F6C5A92BA6}'] function Get_Directory: WideString; safecall; procedure Set_Directory(const Value: WideString); safecall; function Get_FileMask: WideString; safecall; procedure Set_FileMask(const Value: WideString); safecall; procedure BringToFront; safecall; property Directory: WideString read Get_Directory write Set_Directory; property FileMask: WideString read Get_FileMask write Set_FileMask; end; IFileZapperDisp = dispinterface ['{2E2FC5E0-5C0E-4C4F-8CC1-D9F6C5A92BA6}'] property Directory: WideString dispid 1; property FileMask: WideString dispid 3; procedure BringToFront; dispid 10; end; IFileZapperEvents = dispinterface ['{7B6F8ADD-7980-4A35-838B-E1600C43D29E}'] procedure OnSelectionChanged; dispid 1; procedure OnDirectoryChanged(const DirName: WideString); dispid 2; end; Is this somewhat the same thing as the wrapper of option 1? If I write all of this conversion (and, by the way, how to convert C++ data types to pascal?? widestring ?), then how can I use it? In the end, maybe the wiki page about COM interfaces should be update to something more than 'Word.Application.NewFile'. I can't share the activex I have, otherwise it would be a good example to see something useful to start with. Roberto 2011/5/25 Ludo Brands ludo.bra...@free.fr: Using variants you can transparently walk along the exposed objects. The variant contains the Idispatch of the object and gets the exposed methods at runtime. Properties are implemented as get and put methods or just get methods for read only properties. If you have something like Itransducers = interface .. property transducer[Index:integer]:Itransducer; end; Then you would do transducer := transducers.transducer[index]; transducer := transducers[index]; works only if transducer is the default property for Itransducers. I'm not sure if fpc supports this. Ludo -Message d'origine- De : fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part de Roberto Padovani Envoyé : mercredi 25 mai 2011 19:34 À : FPC-Pascal users discussions Objet : Re: RE : RE : RE : RE : RE : [fpc-pascal] support for using an activex 2011/5/25 Ludo Brands ludo.bra...@free.fr: The code in article http://www.informit.com/articles/article.aspx?p=130494seqNum=5 goes a long way in doing what you want to do. Unit Eventsink does pretty much of the legwork. You should remove the procedure register since that is the Delphi way to get a component on the toolbar. Remove also the {$IFDEF VER100} and {$ENDIF}. The unit actually includes the code for InterfaceConnect!! found that! great! As for the tlb conversion, in your case IEventIntfEvents = dispinterface ['{168F5642-5751-49F5-9AA4-B8A7A5F6A5B8}'] end; should do (that is for the events part). AFAIK the procedure and dispid definitions are only needed for the server. You are only concerned with dispid's. No need to create prototypes for OnCommChanged() etc. EventSink1Invoke would be a simple case DispID of 1: // do CommChanged 2: // do StatesChanged ... end; Now I am wasting time making the tlb pascal definitions. For the event part I'm fine with the dispid's Until now I was calling the activex method with variants, in and out, but now I discovered that this IDevice class has a property like: property Sensors: ISensors; which inside is a list of items like Sensor: ISensor. Can I read the sensores with a variant? Then, to see the fields inside each sensor, I think a I need a class to do that... The activex has all of these classes with the suitable dispinterfaces and uuids and so on. But if I define var device, transducers, transducer : variant; and create device := CreateOleObject('Device'); then, can i simply write the following ? transducers := device.Transducers; transducer := transducers[index]; It's a long path until I get this stuff working... R# ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal