Forum Moderators: phranque
I am trying to develop a snippet of code that tests if an existing value given is greater or less than a certain numbered scale of values.
This is the code I have so far. I'm not that keen to state every value separately because the page gets quite high traffic and will probably make the server slow.
Can any one off any advice to getting these equations to work reliably.
Any value from 0 to down to -60
<!--#if expr="(${w5d.day1.min}<= 0) && (${w5d.day1.min}>= -60)" -->
<!--#set var="mincolbg1" value="#99ccff" -->
<!--#endif -->
Any value from 1 up to 24
<!--#if expr="(${w5d.day1.min}>= 1) && (${w5d.day1.min}<= 24)" -->
<!--#set var="mincolbg1" value="#ffff98" -->
<!--#endif -->
Any value from 25 up to 60
<!--#if expr="(${w5d.day1.min}>= 25) && (${w5d.day1.min}<= 60)" -->
<!--#set var="mincolbg1" value="#ff9641" -->
<!--#endif -->
Many thanks for any help offered with this
mat
For example your first condition turned into a regex will look like this:
<!--#if expr="${w5d.day1.min} = /^(0¦-([1-9]¦[0-5][0-9]¦60))$/" -->
See the the mod_include documentation [httpd.apache.org] and search the web for details on the Regular Expressions.
Thanks for the speedy reply!
I used your pointers/URL and got to the following result. It covers all the agreed values and makes the site look a lot better!
Thank you very much for your help mate.
<!--#if expr="${w5d.day1.min} = /^[1-9]¦1[0-9]¦2[0-4]$/" -->
<!--#set var="mincolbg" value="vartemp124" -->
<!--#elif expr="${w5d.day1.min} = /^2[5-9]¦[3-6][0-9]$/" -->
<!--#set var="mincolbg" value="vartemp2560" -->
<!--#endif -->
<!--#if expr="${w5d.day1.min} = /^-/" -->
<!--#set var="mincolbg" value="vartemp060" -->
<!--#endif -->
<!--#if expr="${w5d.day1.max} = /^[1-9]¦1[0-9]¦2[0-4]$/" -->
<!--#set var="maxcolbg" value="vartemp124" -->
<!--#elif expr="${w5d.day1.max} = /^2[5-9]¦[3-6][0-9]$/" -->
<!--#set var="maxcolbg" value="vartemp2560" -->
<!--#endif -->
<!--#if expr="${w5d.day1.max} = /^-/" -->
<!--#set var="maxcolbg" value="vartemp060" -->
<!--#endif -->
:)mat