Forum > General
what on Earth was I trying to do ? ( FOREACH )
(1/1)
lazer:
Hi,
I am porting something I wrote under TPW ( yeah, that means about 30y ago ! ) to Lazarus
I found a snip of code I can't make sense of . It looks like garbage but I'm pretty sure this is the final working code I used.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure Tspellwin.showbits(flag:word); procedure showbit(bit:Pwindowsobject); far; begin bit^.show(flag); end;begin foreach(@showbit); if questool<>NIL then questool^.show(sw_hide);end; {showbits}
It's something about hiding/showing a a bunch of controls but I can't make sense of the use foreach.
Can anyone explain that syntax ?
TIA.
Fred vS:
https://engineertips.wordpress.com/2020/04/26/delphi-foreach/
ccrause:
Is Tspellwin perhaps derived from TCollection? It has a foreach method.
lazer:
thanks ccrause, that does seem to explain this zany syntax.
Tspellwin isn't but I'll have to check back on what it was before I ported the code. That does seem to explain what I did decades ago, I should be able to fix it now.
Many thanks.
Navigation
[0] Message Index