I'm reviewing some code inside of a cfmodule it got me scratching my head.
The cfmodule is being called like:
<cfmodule template="/cfmods/mod1.cfm" mode="breadcrumbs">
and the code inside has a series of cfelse statements but this one is the one that gave me pause.
<cfelseif isdefined("attributes.mode")
AND NOT comparenocase("breadcrumbs", attributes.mode)>
Can someone translate this into spoken words? I know CompareNoCase will return a negative number, 0, or a positive number as a result. So what does adding the the word not do, check for the opposite of what was returned from CompareNoCase?
AND (CONDITION) checks if the condition is TRUE.
AND NOT (CONDITION) checks if the condition is FALSE.
So that statement is saying:
If Attributes.Mode exists as a variable and attributes.mode IS EQUAL to Breadcrumbs regardless of case, THEN...
Related
HELP! I'm getting a "too many arguments for this function" error.
=IF(B13>149,000,"T1",IF(B13>180,000,"T2",IF(B13>210,000,"T3",IF(B13>240,000,"T4",IF(B13>270,000,"T5",IF(B13>300,000,"T6"))))))
Remove the commas from the numbers; Excel thinks "comma" means "new argument." Like this...
=IF(B13>149000,"T1",IF(B13>180000,"T2",IF(B13>210000,"T3",IF(B13>240000,"T4",IF(B13>270000,"T5",IF(B13>300000,"T6"))))))
...but your code will still not do what you want it to do because assuming B13 is greater than 149000, we'll never get past evaluating your first IF and setting to T1, because it looks like the function parser stops after it finds a true condition (like B13 being greater than 149000; whether or not other IFs in your function would also evaluate to true doesn't matter to Excel - it already found a true condition). The solution is to reverse the order, like this:
=IF(B13>300000,"T6",IF(B13>270000,"T5",IF(B13>240000,"T4",IF(B13>210000,"T3",IF(B13>180000,"T2",IF(B13>149000,"T1"))))))
I am having a heck of a time trying to figure this out. I'm trying to replace this evaluate function.
<cfoutput>
#evaluate('#qry#.#editVal#')#
</cfoutput>
But I just can't seem to work it out. Both qry and editVal are in the variables scope and when using evaluate it returns a value for instane the value of
#qryVitals.PULSE#
I just can't seem to get the notation right to interpret it. Any help would be greatly appreciated.
#evaluate('#qry#.#editVal#')# is equivalent to #VARIABLES[qry][editVal]#.
As noted by #Leigh, if VARIABLES[qry] is of type query, you have to specify the row number as well, e.g. #VARIABLES[qry][editVal][1]#.
I recently had the need to match against two strings in ColdFusion and ran into this scenario during my loop:
<cfif "0" IS NOT "NO">
Generally during the loop it looks something like this:
<cfif "AM" IS NOT "BA">
Now both of these values were variables (I wasn't just typing it out for fun) and I was using "0" as a default value for the first variable to match against (since the second variables would never be 0) but both of these values changed in the loop I was running. I easily fixed this by setting my default value to -- instead of 0 but I tried researching and found nothing indicating there was a way to get around the falsey nature of strings when evaluating them.
Is there no Operator or trick to match on the strings themselves and ignore their truthyness or falseyness in ColdFusion?
The compare function will help you. This:
writedump(compare("0", "NO"));
returns -1.
This page will tell you what that means.
I can't find an example close enough to this one on StackOverflow so here goes:
I want to return a message "Type?" if cell X is blank and cell Y has any text. But I'm trying to nestle it into an existing set of IFs.
Existing :
=IF($G241="Evo";M241*L241;IF($G241="Free";M241*L241;IF($G241="GN";M241*L241))))
Nestling this into the above:
=IF(AND(NOT(ISBLANK($J234));ISBLANK(G234));"Type?";"OK")
I tried this but it returns FALSE, maybe due to the AND I'm using, which I need since I'm creating a return based on two cells two cells.
=IF($G240="Evo";M240*L240;IF(AND(NOT(ISBLANK($J240));ISBLANK(G240);"Type?";"OK");IF($G240="Free";M240*L240;IF($G240="GN";M240*L240))))
getting Error:
AND expects boolean values. But 'Type?' is a text and cannot be coerced to a boolean.
IF(and(isblank(cell x),iferror(isstring(cell y),false)),"Type?","OK")
That should do it for you I think. you will need to replace cell x and cell y with the appropriate references. The iferror statement is there to catch what happens when evaluating a blank cell y.
The problem with this formula
=IF($G240="Evo";M240*L240;IF(AND(NOT(ISBLANK($J240));ISBLANK(G240);"Type?";"OK");IF($G240="Free";M240*L240;IF($G240="GN";M240*L240))))
is you are trying to check G240 for different values when it cant. Lets simplify your formula. We will replace your empty cell check with FORMULA 1
=If($G240="EVO", Do True Condition, Do Formula 1, IF(G$240=Free, Do Free True Condition, Do Free False Condition)
The problem is since you already did something (Formula 1) when G240 = "EVO", you cant start another check on what G240 after the fact with the way you have embedded your formula. a batter way of thinking of it is how to do a second check when G240="EVO" is false. Remember the general format of an if statement is:
IF(CONDITION,True Result, False Result)
There are only 3 things that go into an if statement. you tried putting in 3.
Try rearranging to this:
=If($G240="EVO", Do True Condition, IF(SOME CHECK to determine DO FOMULA 1 or CHECK for G240 = FREE, Do Formula 1, IF(G$240=Free, Do Free True Condition, Do Free False Condition)))
Basically break down what you want to check for in G240 and do it in sequence with your IF statement. Right now with what you have written, I cant tell how you want to determine if you want to run your formula 1 or if you want to check if G240="free" since you have two different outcomes if G240="Free"/
OK I think i found the issue. The IF(AND(NOT(ISBLANK works on it's own since there are no other IFs in the formula. I do want to test two different cells for text(letters) in order to show a warning if one cell was blank while the other not. But as soon as you insert the (AND into a string of multiple IFs it doesn't work.
Simply removing the (AND was all I needed to do. Another way to achieve a test for more than one blank cell was to simply add multiple IF(ISBLANKs.
EG: =IF(ISBLANK(A1)+IF(ISBLANK(A2)>2;condition true;condition false)
ForwardEd thanks very much for your help!
Regards
I have a piece of code in front of me that iterates through a long list of urls and something is going wrong when those urls include a certain type of document. I don't want to see every iteration, so I've set up a conditional breakpoint.
The trouble is that I'm not a C++ programmer so I'm slightly having to fish around to work out how to do what I want and I may be doing something obviously wrong.
My current condition is thus:
(strstr( url, "xlsx") == 0x00000000)
This should mean every time the url ( which is a UNICODE_char* ) doesn't contain the literal "xlsx" strstr will return a null pointer which should match the condition, as I understand it. I actually want it the other way round in the long term, but as there are only a couple of "xlsx" urls and I want to check it is working I have it this way up for now.
Well, my condition is not being met or at least the breakpoint is not being triggered.
Assuming that I was doing something wrong I copied the same value as a watch expression and set an unconditional breakpoint on the line before. The result looks like this as I step past my coinditional breakpoint:
Name | Value
================================================
(strstr( url, "xlsx") == 0x00000000) | true
So apparently my condition can be true as far as the watch window is concerned but not trigger the conditional breakpoint.
In order to experiment further I tried flipping the condition over so it was
(strstr( url, "xlsx") != 0x00000000)
As far as the conditional breakpoint is concerned this is also false, which seems a bit funny as that would mean it neither equalled nor didn't equal the null pointer value.
Is this some unusual property of null values in C++? Is there something really obvious I'm missing or some quirk of the language that is causing me to totally miss the boat on this one?
If your url is a unicode string, have you tried using wcsstr?