Okay, so the $()$ syntax can only be used within a macro...gotcha; Thanks!
On Friday, 22 May 2020 19:31:07 UTC-4, Mark S. wrote: > > The substitution forms (e.g. $variable$, $(external variable)$ only work > INSIDE a macro. So you have to > put > > <div style=<<nowandthen m:11 v:2>>><<nowandthen m:11 v:"$(bgcol)$"> > >"$(bgcol)$"</div> > > inside its own macro like: > > \define misnamedmacro() > <div style=<<nowandthen m:11 v:2>>><<nowandthen m:11 v:"$(bgcol)$"> > >"$(bgcol)$"</div> > \end > > and call it: > > > <$set name=bgcol value="7"> > <<misnamedmacro>> > </$set> > > Of course, there could be other things inside the JS macro that are wrong, > but that's what's wrong out of the box. > > Good luck! > > > > > On Friday, May 22, 2020 at 4:01:24 PM UTC-7, leeand00 wrote: >> >> Hi, >> >> I'm trying to pass a value to a variable to a javascript macro I'm trying >> to write; the result keeps coming back NaN, and I belive it is because I am >> passing "$(bgcol)$" instead of "7" for v: >> >> Is there some other way I ought to be passing this argument? >> >> <$set name=bgcol value="7"> >> <div style=<<nowandthen m:11 v:2>>><<nowandthen m:11 v:"$(bgcol)$"> >> >"$(bgcol)$"</div> >> </$set> >> >> /*\ >> title: $:/core/modules/macros/nowandthen.js >> type: application/javascript >> module-type: macro >> >> Macro to return a formatted version of the current time >> >> \*/ >> (function(){ >> >> /*jslint node: true, browser: true */ >> /*global $tw: false */ >> "use strict"; >> >> /* >> Information about this macro >> */ >> >> exports.name = "nowandthen"; >> >> exports.params = [ >> {name: "m"}, >> {name: "v"} >> ]; >> >> /* >> Run the macro >> >> m: is the highest value in the data set. >> v: is the value to render. >> */ >> exports.run = function(m, v) { >> >> let out = "background-color: rgb("; >> >> try { >> m = parseFloat(m); >> v = parseFloat(v); >> console.log("m:" + typeof(m)); >> console.log("m:" + m); >> console.log("v:" + typeof(v)); >> console.log("v:" + v); >> let huh = v/m; >> let where = huh*255; >> console.log("huh: " + typeof(huh)); >> console.log("huh: " + huh); >> console.log("where: " + typeof(where)); >> console.log("where: " + where); >> >> } catch(e) { >> console.log("error: " + e); >> } >> >> for(var i =0; i < 3; i++) { >> let wha = ((parseFloat(v)/parseFloat(m))); >> out = out + (Math.floor(wha*255)) + ", "; >> } >> >> out = (out.slice(0,-2)) + ");color:rgb(150,150,150);"; >> >> return out; >> }; >> >> })(); >> >> >> -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/990708ce-64fb-4a73-bf1b-f44d11148839%40googlegroups.com.