LotusScript for Colour-Coding "Views"
If you look at the DEXT homepage (there's a perma-link to it on the tabs above!) and scroll to about half way down you should see something like the image to the right.
This is the LotusScript alternative to the view-based method of colour-coding document, based on their age, which I talked about last week.
The view-based method has numerous shortcomings, which this LotusScript version avoids. Not only that but the LS version is accurate to the second, whereas the view version is only accurate to the day!
The demo I cooked up for this version works the other way round to last week's demo. Now we're making new (hence "hot") documents red and older ones white.
The trouble with the whole approach is that there's no one-size-fits-all solution I can code. How you use the concept depends entirely on the scenario you'll use it in.
For now I'll leave you with the demo as I don't have time to discuss the ported code. You'll see the code if you download the DEXT app after I've made a new version available tomorrow.
One thing I will say about the code is that it produces CSS values such as rgb(255,977,977) which is of course wrong, but I can't see an equivalent of @Min() in LotusScript, so I've left it as is. The browsers don't seem to mind accepting the value of white. It's Daz white in fact (a joke for the Brits there!).
>> no equivalent in LotusScript
Then use Evaluate (if appropriate).
Now now Jake, surly it's not beyond you to right your own Min function?
;)
--
Kerr
Both using Evaluate and writing my own if-then-else "function" crossed my mind, but I wanted to keep it as pure as possible. It just seems wrong to over-complicate the code for such a trivial thing and using evaluate is always a last resort for me.
By leaving it as it is it's my own little protest against the lack of a Min() function. Why isn't there one?
Mybe @min was provided in formula at a time when it couldn't perform iterative statements, where as Lotusscript could, so it seemed a trivial excercise to include it.
just a thought.
Ok, I gave in and added an extra line:
if percent_red>255 then percent_red=255
I know what you're thinking - "What was all the fuss about? It's only one extra line!". I'm wondering the same too. I'm such a dufus sometimes.
Hope you don't mind the question, but why is Evaluate the last resort for you? It's quicker than sh1te off a shovel; and even if it isn't the most elegant solution, you can pretty much assume that if a future developer can read script, they understand formula language too?
Don't mind the question at all Andrew. I just don't know if I can answer it to your satisfaction. The only answer is that I'm weird like that. I do use Evaluate. All the time. It just felt wrong on this occasion. See what I mean, weird.
It would have been wrong -- icky, even -- in this case. @Min would have involved either building an array (which could either use the Formula engine's inefficient list literal method or a call to an extra function, @Explode) or passing a document handle, in addition to the overhead of calling an external library (even if the engine is in memory, you'd still need to locate the function pointer, etc.). Let's face it, we're not talking about @DbColumn here.