[pmwiki-users] zap - save math output to a variable

Karl kharris at bnin.net
Thu Sep 20 15:24:54 CDT 2007


Thank you, that explains what I didn't understand.

Karl

The Editor wrote:
> On 9/20/07, Karl <kharris at bnin.net> wrote:
>   
>> Thx for the message
>>
>> So in the example you gave, is math the name of a variable?
>>     
>
> Yes and no. It is the name of the field (in zap, special fields are
> called commands). When saved though, it also becomes the name of a
> page text variable.
>
>   
>> here is the syntax of my current zap form:
>>
>> --------------------------------
>> (:input text E1 {$:E1} size=4:)
>> (:input text E2 {$:E2} size=4:)
>> (:input text E3 {$:E3} size=4:)
>> (:input text E4 {$:E4} size=4:)
>> (:input text E5 {$:E5} size=4:)
>> (:input text E6 {$:E6} size=4:)
>> (:input text E7 {$:E7} size=4:)
>>
>> Total {(math
>> '{$:E1}+{$:E2}+{$:E3}+{$:E4}+{$:E5}+{$:E6}+{$:E7}')}
>> --------------------------------
>>
>> what I want to do is assign the output of the math calculation to another
>> variable for use in another calculation.
>>     
>
> Try something like this:
>
> (:input text E1 {$:E1} size=4:)
> (:input text E2 {$:E2} size=4:)
> (:input text E3 {$:E3} size=4:)
> (:input text E4 {$:E4} size=4:)
> (:input text E5 {$:E5} size=4:)
> (:input text E6 {$:E6} size=4:)
> (:input text E7 {$:E7} size=4:)
>
> (:zap math="{E1}+{E2}+{E3}+{E4}+{E5}+{E6}+{E7}":)
> (:zap Esum="{math}":)
> (:zap savedata="E1,E2,E3,E4,E5,E6,E7,Esum":)
>
> Basically it calculates the sum then assigns that value to the field
> Esum (you could just save it as math of course). So in the page
> {$:Esum} should give you the total.
>
> Dan
>
>
>
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/pmwiki-users/attachments/20070920/8d9e6349/attachment.html 


More information about the pmwiki-users mailing list