On Monday, December 29, 2014 9:31:55 AM UTC-8, Stephen Kimmel wrote:
>
> Inputs: offset = 6 a= 1 mdate=1/12/2015
> The values for a and mdate are correct but offset is not the right number.
> As you can see from the code, offset is used but not modified. Even so, the
> number that comes out of the routine is not the number I put in. I'm not
> good enough to know if the problem is in the Javascript, how I've done the
> macro or if it is in the $macrocall.
> Can someone tell me what I'm doing wrong?
>
The problem is that you are using "=" in your conditional tests. A single
"=" sign means "assignment"... to *compare* values, you need to use TWO
equal signs (e.g., "=="). When you use an assignment operator in the
conditional, the value of the conditional is equal to the value assigned...
and any non-zero value is considered to be "true"... Thus, in this line:
if (out = 7) { out = 0 };
The conditional value is always "7" (regardless of the actual value of
'out'), so the conditional is always invoked, and out is ALWAYS set to 0.
Similarly, in this line:
if ( offset = 7 - n ) {output= Workout[1]};
"offset=7" evaluates to "7"... and then 'n' is subtracted. If 'n' has a
value of "7", then the conditional will have a value of "0" (i.e.,
"false"), and will not be invoked. However, if 'n' has ANY other value,
then the conditional will be a non-zero value and the code will be invoked.
To fix your code, change the single "=" in the conditionals to "==", like
this:
if (out == 7) { out = 0 };
if ( offset == 7 - n ) {output= Workout[1]};
Let me know how it goes...
enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
YOUR DONATIONS ARE VERY IMPORTANT!
HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY BOOK PROJECT:
"Inside TiddlyWiki: The Missing Manual"
https://www.indiegogo.com/projects/inside-tiddlywiki-the-missing-manual/x/8816263
Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:
http://www.TiddlyTools.com/#Contact
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.