Thursday, August 15, 2013

Diesel Macro Letter Automation...broken down

I realized that i had posted the diesel macro for letter automation, but didn't really go into the breakdown of the functionality of the macro.  So, here is my attempt at breaking it down...first let's look at the macro that was written again.

*^C^C_text;\;$m=$(if, $(<=,$(getvar,userr1),7),$(nth,$(getvar,userr1), A, B, C, D, E, F, G, H),$(if,$(>=,$(getvar,userr1),8),$(nth,$(getvar,userr3), I, J, K, L, M, N, O, P)),)$(if,$(>=,$(getvar,userr1),15),$(nth,$(getvar,userr4), Q, R, S, T, U, V, W, X),)$(if,$(>=,$(getvar,userr1),23),$(nth,$(getvar,userr5), Y, Z, AA, AB, AC, AD, AE, AF),);setvar;userr1;$M=$(+,$(getvar,USERR1),$(getvar,USERR2));setvar;userr3;
$M=$(+,$(getvar,USERR3),$(getvar,USERR2));
userr4;$M=$(+,$(getvar,USERR4),$(getvar,USERR2));
userr5;$M=$(+,$(getvar,USERR5),$(getvar,USERR2));
SETVAR;USERR3;\SETVAR;USERR4;\SETVAR;USERR5;\

First, we know that you start with the text command and go through all the prompts for it.  Then we work our way into the diesel portion of the macro...so, when developing this I found out that when using the "nth" function by itself you were limited to 7 arguments within the function.

Hence, why I embedded the "nth" function within multiple if statements.  
 Let's dissect these if statements a little:
 $m=$(if, $(<=,$(getvar,userr1),7),$(nth,$(getvar,userr1), A, B, C, D, E, F, G, H),$(if,$(>=,$(getvar,userr1),8),$(nth,$(getvar,userr3), I, J, K, L, M, N, O, P)),)

 so, in this first "if statement" I am telling it to evaluate the value of userr1.
$m=$(if, $(<=,$(getvar,userr1),7),$(nth,$(getvar,userr1), A, B, C, D, E, F, G, H),$(if,$(>=,$(getvar,userr1),8),$(nth,$(getvar,userr3), I, J, K, L, M, N, O, P)),)

 If a value of 7 or less is returned then it moves on to this nth function where i am again calling for the value of userr1.
 $m=$(if, $(<=,$(getvar,userr1),7),$(nth,$(getvar,userr1), A, B, C, D, E, F, G, H),$(if,$(>=,$(getvar,userr1),8),$(nth,$(getvar,userr3), I, J, K, L, M, N, O, P)),)

 you will find a recurring theme throughout these if statements that we are evaluating the value of userr1...here we are looking to see if the value of userr1 is greater than or equal to 8.
 $m=$(if, $(<=,$(getvar,userr1),7),$(nth,$(getvar,userr1), A, B, C, D, E, F, G, H),$(if,$(>=,$(getvar,userr1),8),$(nth,$(getvar,userr3), I, J, K, L, M, N, O, P)),)

 If it returns a value of 8 or greater then it will move on to the next nth statement where we call for the value of userr3.
 And this process repeats 2 more times with userr4, and userr5.  One thing that you should notice is that the value to be returned from userr1 increase by a value of 8 with each "if statement".
 Now that we are done with the if statements we can move  on to the easier portions of the macro...how the values of the userr variables increase with each repetition of the command.
 setvar;userr1;$M=$(+,$(getvar,USERR1),$(getvar,USERR2))
 This code will be repeated four times...you will just have to copy and paste and then replace userr1 with userr3, userr4 or userr5.
 And then the prompting for user input of the userr variables finishes out the macro.


 Hope that this helped to clarify the process of the macro.

No comments:

Post a Comment