One question: How do I make wikiCalc + MansLibrary with a custom field show a default message when the field is missing? <<wikiCalc "MANS.gradeMe(%0)" "poi...@johnsmith" >> Works fine when there is a fieldvalue for points - but if it is missing the macro shows an error. Something like "No points" as a default message would be nice.
Regards Måns On 10 Dec., 17:58, "Mark S." <[email protected]> wrote: > I wouldn't try to shovel that into an evaluated expression. Instead, > create your own library tiddler, like MANS_Library, and tag it > systemConfig. Put this in it: > > MANS = {} ; > MANS.gradeMe=function(grade){ > if(grade<25) return "F" ; > if(grade<37) return "Fx" ; > if(grade<48) return "E" ; > if(grade<59) return "D" ; > if(grade<66) return "C" ; > if(grade<71) return "B" ; > return "A" > > } > > Save and reload. I think you can see how this works enough to tweak it > for different brackets. > > Then, assuming you use wikiCalc at all, you can create a tiddler with > contents like: > > Your grade is <<wikiCalc "MANS.gradeMe(%0)" [[Students::JohnSmith]] >> > > HTH > Mark > > On Dec 10, 8:42 am, Måns <[email protected]> wrote: > > > > > Thanks Mark > > I thought I did that - but of course you were right :-) > > > Do you happen to know how to define intervals in the conditional > > expression and make several of them? > > Eg if the number is between 1-4 then A or 4-5 then B etc ? > > > Måns > > > On 10 Dec., 15:01, "Mark S." <[email protected]> wrote: > > > > The veggie example worked fine for me after I straightened out the > > > line-wrapping. If you look at the text of your tiddler in an external > > > editor, you want everything inside of each quote section within the > > > wikiCalc macro to be on one line: > > > > <<wikiCalc "stuff all on one line" parameter1 >> > > > > Hmm, apparently I need to watch my diet ... > > > > HTH > > > Mark > > > > On Dec 9, 4:15 pm, Måns <[email protected]> wrote: > > > > > Hi TwWizards (and Eric) > > > > > I read this old > > > > post:http://groups.google.dk/group/tiddlywiki/browse_thread/thread/4f1a8c9... > > > > > I tried it out: > > > > <<wikiCalc "%0/%1" [[MyFood::Vegetables]] [[MyFood::Hamburgers]]>> > > > > Your diet is <<wikiCalc "(%0/%1)<1?'unhealthy... eat more > > > > vegetables':'healthy... keep it > > > > up'"[[MyFood::Vegetables]] [[MyFood::Hamburgers]]>> > > > > |Vegetables|5| > > > > |Hamburgers|6| > > > > > It doesn't seem to work.. > > > > I wonder if the extra two lines of code has been removed again?: > > > > > >I've just added a minor tweak (only two lines) to the existing plugin > > > > >code, it can now assemble a javascript expression from slice values > > > > >(automatically retrieved by the core's macro handler) and then also > > > > >'eval' that expression to compute a new value before it is output as > > > > >wiki-formatted content. > > > > > Or I have made some kind of misspelling in the syntax ?? > > > > > YS Måns Mårtensson -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/tiddlywiki?hl=en.

