Last active
June 18, 2019 15:20
Star
You must be signed in to star a gist
ColdFusion Operator Shortcut to Return Remainder throws error (depending on spacing)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- | |
ColdFusion Operator Shortcut to Return Remainder throws error (depending on character spacing) | |
5/22/2019: Not sure where this came from; dated ~2017. Operator shortcut throws error in ColdFusion 2016/2018, but not CF10/11.) | |
Unsure if actually reported to Adobe, but this is when I tweeted it: https://twitter.com/gamesover/status/1131335207427149824 | |
6/18/2019: Appears to be fixed in CF2018??? CF2016 is not end-of-core or end-of-life. Hopefully it gets fixed too. | |
NOTE: If you manually add spaces around the "%" operator, the error is resolved. | |
https://gist.github.com/JamoCA/2bd7d96af851df7648c661e97fceaac1 | |
https://trycf.com/gist/2bd7d96af851df7648c661e97fceaac1/acf2016?theme=monokai | |
---> | |
<cfscript> | |
// Function to print Excel column name for a given column number | |
function printString(n){ | |
str = ''; | |
while (n>0){ | |
// Find remainder | |
try { | |
rem = n%26; | |
} catch (any e){ | |
return 'Fail: ' + e.message; | |
} | |
// If remainder is 0, then a 'Z' must be there in output | |
if (rem==0){ | |
str = 'Z' & str; | |
n = (n\26)-1; | |
} else { | |
str = chr(64 + rem) & str; | |
n = n\26; | |
} | |
} | |
return str; | |
} | |
writeoutput('26: ' & printString(26)); | |
writeoutput('<br>'); | |
writeoutput('51: ' & printString(51)); | |
writeoutput('<br>'); | |
writeoutput('52: ' & printString(52)); | |
writeoutput('<br>'); | |
writeoutput('80: ' & printString(80)); | |
writeoutput('<br>'); | |
writeoutput('676: ' & printString(676)); | |
writeoutput('<br>'); | |
writeoutput('702: ' & printString(702)); | |
writeoutput('<br>'); | |
writeoutput('705: ' & printString(705)); | |
</cfscript> | |
<cfdump var="#Server#" label="Server" expand="false"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment