Author | Topic: My contribution to PageLet quotes | |
---|---|---|
Roger Donnay | My contribution to PageLet quotes on Sun, 21 Dec 2014 19:30:13 +0100 "Making software is like making babies. It doesn't get done any faster by putting more men on the job" - Roger Donnay I made some changes to MAIN.CXP and PAGELET.CXP in WebSamples because the quote of the day was often getting duplicated due to the randomization algorithm. I found that the ::data container of the CxpAbstractPage() object could be used as cargo. I then created an array named ::data:idx to store the random integers being selected so they would not be duplicated. Here is the updated code: MAIN.PRG <h1>Random collection of quotes!</h1> <% nS := MilliSeconds() ::data:idx := {} FOR n:=1 TO 5 ::RenderPage(".\pagelet.cxp", "Quote #"+AllTrim(Str(n))+" of the day!" ) NEXT n ? ::data:idx nE := MilliSeconds() %> <h2>Elapsed @(nE-nS) ms</h2> PAGELET.CXP <% aTips := {} AAdd( aTips, {"One of my most productive days was throwing away 1000 lines of code.","Ken Thompson" } ) AAdd( aTips, {"Deleted code is debugged code."," Jeff Sickel"} ) AAdd( aTips, {"Controlling complexity is the essence of computer programming.","Brian Kernigan"} ) AAdd( aTips, {"A program that produces incorrect results twice as fast is infinitely slower.","John Osterhout"} ) AAdd( aTips, {"Simplicity is prerequisite for reliability.","Edsger W. Dijkstra"} ) AAdd( aTips, {"The key to performance is elegance, not battalions of special cases.","Jon Bentley and Doug McIlroy"} ) AAdd( aTips, {"Simplicity is the ultimate sophistication.","Leonardo da Vinci"} ) AAdd( aTips, {"Unix has retarded OS research by 10 years and linux has retarded it by 20.","Dennis Ritchie"} ) AAdd( aTips, {"Hofstadter’s Law: It always takes longer than you expect, even when you take into account Hofstadter’s law.","Douglas R. Hofstadter"} ) AAdd( aTips, {"The crazier the theory, the more likely it is to be correct.","Niels Bohr"} ) AAdd( aTips, {"When working on a problem, think only how to solve it. If the solution is not simple and has no inner beauty such as art, it is wrong.","Steffen F. Pirsig"} ) AAdd( aTips, {"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction.","Albert Einstein"} ) AAdd( aTips, {"Incorrect documentation is often worse than no documentation.","Bertrand Meyer"} ) AAdd( aTips, {"The purpose of software engineering is to control complexity, not to create it.","Dr. Pamela Zave"} ) AAdd( aTips, {"Making software is like making babies. Is doesn't get done any faster by putting more men on the job.","Roger Donnay"} ) DO WHILE .t. nIdx := RandomInt(1,Len(aTips)) IF !(nIdx $ ::data:idx) EXIT ENDIF ENDDO cTitle := PValue(1) AAdd(::data:idx,nIdx) %> <div style="font-family: 'Segoe UI Light', 'Segoe UI', Verdana, Arial, Helvetica;font-size:9pt;color:white;background- color:#efefef;width:20em;padding:0px;margin:0px;"> <h1 style="background-color:#13346e; color:#efefef;padding-left:5px;font- size:11pt; margin-bottom:5px;" >@(cTitle)</h1> <div style="padding-left:5px; padding-top:2px; padding-bottom:2px; padding-right:1px;color:#13346e;"> <a href="#" style="text-decoration:none"> @(aTips[nIdx][1])<br> <small>@(aTips[nIdx][2])</small> </a> </div> <div style="margin:0px 0px 1px 0px"> </div> </div> |