For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > June 2005 > Re: [SMARTY] simple assign









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [SMARTY] simple assign
Joe Stump

2005-06-06, 4:00 pm

{math equation="a - b" a=-60 b=$posX assign="offSetX"}

That doesn't work? If not then that's a bug IMO with math. Also your
example looks good, did you try adding parenthesis? ie. {assign
var="offSetX" value=(-60 - $possX)}

--Joe

--
Joe Stump
http://www.joestump.net

On Jun 6, 2005, at 9:50 AM, dc wrote:

> how do i just get the result of a calc assigned to a variable?
>
> eg:
> {assign var='offSetX' value=-60-$posX }
>
> if posX is 30 returns:
> "-60-30"
>
> whereas i want -90
>
> math and eval dont seem to be the way to do it either...
>
> even tho i have done really tricky stuff in smarty, every time i go
> away for a day i get stumped by the syntax on variables. it really
> is kind of un-intuitive...
>
> {capture ... } ?
>
> /dc
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

dc

2005-06-06, 4:00 pm

I think it is because the equation starts off with a - sign, so it got
treated as a string concatenation. breaking it into two separate
statements solved things...

/dc

On Tue, 07 Jun 2005 01:56:01 +0900, Joe Stump <joe@joestump.net> wrote:

> {math equation="a - b" a=-60 b=$posX assign="offSetX"}
>
> That doesn't work? If not then that's a bug IMO with math. Also your
> example looks good, did you try adding parenthesis? ie. {assign
> var="offSetX" value=(-60 - $possX)}
>
> --Joe
>
> --
> Joe Stump
> http://www.joestump.net
>
> On Jun 6, 2005, at 9:50 AM, dc wrote:
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com