Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2009-08-26 00:34:33

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: adi_calc – Calculator for TXP variables

hi Adi,
thanks for replying.

No, it doesn’t happen if I initialize some other variable :)
I’m on PHP 5.2.6-3ubuntu4.2


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#12 2009-08-26 00:51:15

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,254
Website

Re: adi_calc – Calculator for TXP variables

maniqui wrote:

No, it doesn’t happen if I initialize some other variable :)

Good, I’ll produce a fix but in the meantime please use the “initialiase a variable” workaround.

Offline

#13 2010-05-17 17:05:02

aswihart
Member
From: Pittsburgh, PA
Registered: 2006-07-22
Posts: 345
Website

Re: adi_calc – Calculator for TXP variables

This is a wonderful plugin, and I think it would be a very useful feature to allow rounding up to the next whole number with remainders from division operations. Any way you could add this feature, Adi? I know I can use smd_if, but it would be nice to not have to install that for this single purpose. Or is there a way to do this as is?

Offline

#14 2010-05-17 17:26:25

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: adi_calc – Calculator for TXP variables

+1 for the rounding option.

And, while here, I would like to ask for another feature: to make adi_calc perform basic math operations on other stuff that may not be a txp:variable.
Suppose we are using some of those crazy smd_ plugins that include some {replacement} tags.

<txp:adi_calc value="{width}" add="5" display="1" />

Or maybe, easier/better, to have a container mode to use it:

<txp:adi_calc add="5" display="1">{width}</txp:adi_calc>

I think it could be useful to have a way to do some basic math operations without having to do them inside txp:php.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#15 2010-05-18 01:35:57

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,254
Website

Re: adi_calc – Calculator for TXP variables

aswihart wrote:

… a very useful feature to allow rounding up to the next whole number …

Sounds useful, I’ll look into it.

maniqui wrote:

… make adi_calc perform basic math operations on … some of those crazy … {replacement} tags.

Hi Julián. Now that’s an interesting suggestion. I’ll have a ponder on that too.

Offline

#16 2010-05-18 03:01:44

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: adi_calc – Calculator for TXP variables

Sorry, for offtopic.

maniqui wrote:

+1 for the rounding option.
<txp:adi_calc add=“5” display=“1”>{width}</txp:adi_calc>

<txp:aks_evar calc="/3" round="2">77</txp:aks_evar>

Other samples

Last edited by makss (2010-05-18 03:35:33)


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#17 2010-05-18 22:25:06

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,254
Website

Re: adi_calc – Calculator for TXP variables

makss wrote:

<txp:aks_evar calc="/3" round="2">77</txp:aks_evar>

It’s an arms race!

Offline

#18 2010-05-24 10:38:44

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,254
Website

Re: adi_calc – Calculator for TXP variables

Version 0.3 now available for download:

  • fixed: error if adi_calc is the first person to set a TXP variable (thanks maniqui)
  • new attribute: ‘ceiling’ to always round up the result of integer division (for aswihart)

Offline

#19 2010-05-26 13:16:46

aswihart
Member
From: Pittsburgh, PA
Registered: 2006-07-22
Posts: 345
Website

Re: adi_calc – Calculator for TXP variables

Thank you Adi, this update is working perfectly.

Offline

#20 2010-07-19 00:23:46

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,254
Website

Re: adi_calc – Calculator for TXP variables

adi_calc bumped up to version 1.0 which is now available

New attributes:

  • ‘precision’ to switch into floating point mode
  • ‘result’ variable set to result of calculation, original variable left unchanged
  • ‘reset’ to automatically reset value to zero
  • ‘reset_name’ to count the number of resets

Enhancements:

  • container tag mode
  • no longer complains if an initial value not found – if all else fails, default to zero
  • can operate without TXP variables entirely

Offline

Board footer

Powered by FluxBB