[twsocket] Original way of iterating thru all the bits in an integer
Hi ! I wrote an article about an original way of iterating thru all the bits of an integer. This is the kind of fancy code one could write using recent version of Delphi. I would like to apply this kind of code in ICS, but if I do, it wont work anymore with the old D7. The final code looks like this: var OneBit : Boolean; begin for OneBit in TBitIterator.Create(1234) do Write(Ord(OneBit)); end; You can read the article at http://francois-piette.blogspot.be/2013/01/original-method-to-iterate-bits-w ithin.html -- francois.pie...@overbyte.be Embarcadero MVP http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Original way of iterating thru all the bits in an integer
Hi Francois, I was just wondering, what would be a practical application of this routine? Also, being familiar with Assembly, I have to ask: wouldn't it be more efficient to just shift the value to the left directly without the abstraction of the enumerator? dZ. On Jan 05, 2013, at 15:21, François Piette wrote: Hi ! I wrote an article about an original way of iterating thru all the bits of an integer. This is the kind of fancy code one could write using recent version of Delphi. I would like to apply this kind of code in ICS, but if I do, it won’t work anymore with the old D7. The final code looks like this: var OneBit : Boolean; begin for OneBit in TBitIterator.Create(1234) do Write(Ord(OneBit)); end; You can read the article at http://francois-piette.blogspot.be/2013/01/original-method-to-iterate-bits-w ithin.html -- francois.pie...@overbyte.be Embarcadero MVP http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
[twsocket] Posting
Hi, I was recently looking at ICS and considering it as a replacement for Indy for an application which works as an interface for a web application. I wanted to give it a quick try and see how it handles performing a simple login so I put this together using the code from the OverbyteIcsHttpPost project: var stl: AnsiString; begin try stl := 'Action=UserToDo=LoginUsername=' + UrlEncodeToA(Trim(act.Username)) + 'Password=' + UrlEncodeToA(Trim(act.Password)); http.SendStream := TMemoryStream.Create; http.SendStream.Write(stl[1], Length(stl)); http.SendStream.Seek(0, 0); http.RcvdStream := TMemoryStream.Create; http.URL := Trim(act.Domain); http.ContentTypePost := 'application/x-www-form-urlencoded'; http.PostASync; except end; The code wasn't succeeding since the web side was routing it to the default controller so I attempted listing all post data received and found it wasn't receiving post data. I know it must be a problem with my code, something I must have missed as when I tested the same server with the same post output using your sample post application it works fine but for the life of me I don't see where the difference lies. I'm hoping someone may see something I'm missing. Thanks, Stewart -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Original way of iterating thru all the bits in an integer
I was just wondering, what would be a practical application of this routine? As you probably don't know, I'm doing a lot of process control with Delphi. And I frequently have to process bit collections. wouldn't it be more efficient to just shift the value to the left directly without the abstraction of the enumerator? Yes, that's what I said in the article. Most abstractions, if not all are always slower than specially crafted code. However frequently efficiency is not the most interesting factor: ease of write and readability of code tend to be more important than speed. Usually, speed isn't an issue when you have an i7 processor at 2GHz as it is when you have a 8 bits microcontroller running at 1MHz :-) And as I said in the article, this code has the advantage of being very simple and help people learn what they can do with an enumerator and how they can use it in their own application. http://francois-piette.blogspot.be/2013/01/original-method-to-iterate-bits-w ithin.html -- francois.pie...@overbyte.be The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be