set RGBlist to choose color set htmlColor to "" as Unicode text repeat with i in RGBlist tell ((round ((i div 256) / 50) rounding as taught in school) * 50) to set RGBcolor to it + (it div 50) -- the perl script does the dec -> hex conversion set htmlColor to htmlColor & text -2 thru -1 of ("0" & (do shell script "perl -e 'printf(\"%X\", " & RGBcolor & ")'")) end repeat htmlColor --> e.g. 6600CC
There is not a “ROFL” large enough to convey what I’m doing right now. Oh, Apple, you never cease to amuse.
Never seen this bit of the language before. Thanks, Stefan.
tell ((round (i div 256) / 50) * 50) to set RGBcolor to it + (it div 50)
does the same, but I really love this expression
That’s why it’s hysterical. In reality, it’s not good practice, but it’s still really funny to imagine that day in the Apple offices:
“Hey Jim, let’s add some comical verbosity to the command.”
“Bob, I think you’re on to something here.”
The reason the conditional “as taught in school” was added was to make the results of a rounding match with what is/was generally taught in school. This would be instead of always rounding up or down.
Great Code StefanK, It was helpful for a small AS App I made…
Very simple and handy, thanks for the code!