Do Hidden Formulas Still Compute?
Recently I found myself questioning a fairly basic premise. One of those you've always "known" the answer to, but never gone as far as proving to yourself.
If you use hide-whens to hide a computed-text area does it still compute its value? If it does, this could be a needless drain on resources.
Well, the answer is no, they don't compute. To find this out I did some fairly crude testing. I added a Computed Text area with this formula:
html:=""; @For(n := 1; n <= 1000; n := n + 1; html:=html+@Text(n) ); html
The result is one really long string printed to the browser that looks like this:
1 2 3 4 5 6… …998 999 1000
Directly below it I added an image. The browser would wait until all the numbers had been printed before it triggered a separate request to the server to fetch the image. Using an HTTP sniffer it's easy to see the time difference between the request for the page and the request for the image. This difference is roughly the time taken to compute the formula.
Without any hide-whens the page took an average of 0.3s to load. With the computed area hidden it took 0.1s to load. Not very scientific, I know, but it was consistent and enough to convince me there's no need to worry.
You know, sometimes I think the more I use Domino the less I actually know. Last Thursday's post is another example of this.
Well, it only proves that it's not pumping the computed html to the browser but i guess is doing the computing part on the server.
1) Created two computed fields one below the other and the formula for the first one is @SetField("Field2";"some value")
2) Field2 has formula just Field2
3) Hide Field1
4) Open the form in browser and it shows Field2 with value "some value"
Fields are different Giri. I'd hope that they _always_ compute, whether or not they were hidden. If hidden fields didn't compute we'd be in a lot of trouble!
I was thinking about Computed Text (looks like on a form). They're used mainly for presenting text to the browser. When they're not needed and hidden I'd like to think the computations were avoided.
You're right. My tests don't show whether or not the server actually processes the formula. In a way I don't care about this as much as I do about any delay the user might perceive.
If you use a Computed Text formula that exceeds the maximum allowable memory, the server will display an error when the text is not hidden but will show the form just fine when the text is hidden. I used:
@For(i := 0; i < 1000000; i := i + 1;"";"");i
to test this. When the computed text is hidden my form loads fine. When I un-hide the text I get:
HTTP Web Server: Lotus Notes Exception - The formula has exceeded the maximum allowable memory usage.
If I put the formula in any type of field, I get the error even when the field is hidden.
It looks like hidden computed text is not evaluated.
Thanks Mike. Conclusive proof that not even the server is slowed by hidden formulae.
You are right. did the same test with computed text instead of fields to confirm that.
I never noticed (cause I never tried it) that you cannot even set a field value from within a computed text formula.
Funny enough, you can set HTTP header values. As long, as the text ist not hidden, of course ...
I don't recall the exact values to set but you can watch your @Formulas compute on the debug console. I've watched my computed values, hide whens, fields, subforms, etc., all show up with this. Its invaluable to debugging execution order which is otherwise undefined by Lotus.
For your notes.ini.
DEBUG_CONSOLE=1
DEBUG_OUTFILE=somefile.txt
DEBUG_DOCCOMPUTE=1