Trying to replace the evaluate function. Having an issue with 1 particular case - coldfusion

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]#.

Related

Using IFS and REGEXMATCH Fails

I'm trying to use the following IFS statement
=IFS(REGEXMATCH(B2,"football"),"brown",REGEXMATCH(B2,"baseball"),"white")
but Google Sheets keeps saying the syntax is wrong. What is wrong with this?
Column B is a text column.
Other similar posts did not work for me.
The formula works fine.
You probably need to change it (depending on your locale) to:
=IFS(REGEXMATCH(D2;"football");"brown";REGEXMATCH(D2;"baseball");"white")
Another improvement you may make is to wrap it in the IFNA function
=IFNA(IFS(REGEXMATCH(D2,"football"),"brown",REGEXMATCH(D2,"baseball"),"white"),"No match")

Is there a way to exact match "truthy" and "falsey" values in ColdFusion

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.

openoffice calc use contents of a cell as the formula for another

I searched for this and couldn't find how to do it. I have a cell that has an equation like: ".25 + .33" which I want displayed exactly like that. In the cell next to it, I want it to give me the result of that equation, ie, to turn that into "=.25 - .33" and show the result. I know I could do it the other way around, typing the formula out, and then using =FORMULA() and REPLACE() to remove the '=' or even use macros. But that's not what I want in this case. Is there a way to do this? I tried looking at functions like =INDIRECT() but no joy.
Given the constraints you have chosen, in a word, No.

IFERROR STATEMENT WITHIN VLOOKUP

I asked for help on another formula earlier which has lead to another head scratcher for me. I'm sure there is probably a way to use IFERROR somewhere in the formula below, but I can't seem to figure out where. I have a few columns returning #N/A that I just need to be blank.
Everything is working how it should except for the error. I have another formula feeding off of the results of this formula that I need to populate either Y or N based on the results. The #N/A is throwing some of them off.
=IF(J2="",VLOOKUP(B2,Sheet1!B:F,5,FALSE),"PICKED UP")
Just wrap it like this:
=IF(J2="",IFERROR(VLOOKUP(B2,Sheet1!B:F,5,0),"Error msg here"),"PICKED UP")
IFERROR will evaluate the first expression (here, it's the VLOOKUP) and if it returns an error, it will return the second part of the formula, which is Error msg here in this case. Change it to whatever you want to.
Also, you can use 0 to mean FALSE in excel (and 1 to mean TRUE).
=IF(J2="", IF(ISNA(VLOOKUP(B2,Sheet1!B:F,5,FALSE)), "", VLOOKUP(B2,Sheet1!B:F,5,FALSE)),"PICKED UP")

coldfusion IIF error - Invalid CFML construct found

I am getting an an error "Invalid CFML construct found"
iif(stImages[id][1]["seolink"] is not "", stImages[id][1]["seolink"], stImages[id][1]["url"]) />
what i am doing here wrong?
Try:
iif(stImages[id][1]["seolink"] is not "", DE(stImages[id][1]["seolink"]), DE(stImages[id][1]["url"])) />
For those readers playing from home (as it were), IIF can be an unruly beast because of the double evaluation it does. So
#IIF(myVal EQ "", "thisThing", "thatThing")#
LOOKS like it will simply return the first or second strings, but in fact it will return the content of the VARIABLES "thisThing" or "thatThing" (or throw an error that they don't exist). So say it with me: "IIF() and DE() GO TOGETHER LIKE MUTUALLY BENEFICIAL PARASITIC LIFEFORMS". "DE" as in "Delayed Evaluation". So if you want the above statement to return the first or second string, you need:
#IIF(myVal EQ "", DE("thisThing"), DE("thatThing"))#
Now, you can certainly use this feature to evaluate a field twice and NOT use "DE()", but that means you're using some kind of dynamic variable name, and it could be argued that doing that isn't best practice. Not that I haven't done that exact thing, but it should be copiously commented, because if you don't the person who maintains the code after you will probably want to kill you.
By the way, there's no mystery to "DE()". These two statements are equivalent:
#DE("thisThing")#
#"""thisThing"""#
See what's going on? "DE()" simply puts double quotes around something. So one set of quotes gets "stripped off" the first time it gets evaluated, and then the quoted string gets returned from the function. Clear as mud?
See why people don't like IIF? It's very handy in certain situations, but is a contextual mess and contributes to code that makes people go "HWUUUH??" So that's why people say to avoid it if possible.
I would avoid iif where you can,
iif(stImages[id][1]["seolink"] is not "", DE(stImages[id][1]["seolink"]), DE(stImages[id][1]["url"])) />
<cfif stImages[id][1]["seolink"] is not "">#stImages[id][1]["seolink"]#<cfelse>#stImages[id][1]["url"]#</cfif>
or if you have ColdFusion 9
<cfset stImages[id][1]["seolink"] is not "" ? #stImages[id][1]["seolink"]# : #stImages[id][1]["url"]# />