[TYPO3-english] ST template checkboxes

Jigal van Hemert jigal at xs4all.nl
Thu Dec 29 14:11:21 CET 2011


Hi Sergey,

On 28-12-2011 17:39, Sergey Alexandrov wrote:
> I thought about something like that, but it will not work:

You were right, there were some flaws. I liked the challenge and wanted 
it to simply work, so here's a working example:


5 = LOAD_REGISTER
5.options = 42  # 32 + 8 + 2: bits 5,3,1

8 = TEXT
8 {
	value = bit5-
	if {
		value {
			prioriCalc = intval
			cObject = TEXT
			cObject.insertData = 1
			cObject.value = {register:options}%64
		}
		isLessThan = 31
		isGreaterThan = 64
	}
}

9 = TEXT
9 {
	value = bit4-
	if {
		value {
			prioriCalc = intval
			cObject = TEXT
			cObject.insertData = 1
			cObject.value = {register:options}%32
		}
		isLessThan = 15
		isGreaterThan = 32
	}
}

10 = TEXT
10 {
	value = bit3-
	if {
		value {
			prioriCalc = intval
			cObject = TEXT
			cObject.insertData = 1
			cObject.value = {register:options}%16
		}
		isLessThan = 7
		isGreaterThan = 16
	}
}
20 = TEXT
20 {
	value = bit2-
	if {
		value {
			prioriCalc = intval
			cObject = TEXT
			cObject.insertData = 1
			cObject.value = {register:options}%8
		}
		isLessThan = 3
		isGreaterThan = 8
	}
}
30 = TEXT
30 {
	value = bit1-
	if {
		value {
			prioriCalc = intval
			cObject = TEXT
			cObject.insertData = 1
			cObject.value = {register:options}%4
		}
		isLessThan = 1
		isGreaterThan = 4
	}
}
40 = TEXT
40 {
	value = bit0-
	if {
		value {
			prioriCalc = intval
			cObject = TEXT
			cObject.insertData = 1
			cObject.value = {register:options}%2
		}
		isLessThan = 0
		isGreaterThan = 2
	}
}

The % (modulo) operator cuts of the higher bits. The tricky part is the 
way the if properties actually swap the operand around the operator:

if.value = 10
if.isGreaterThan = 11

will result in TRUE because the value of isGreaterThan is greater than 
the base value.

-- 
Kind regards / met vriendelijke groet,

Jigal van Hemert.


More information about the TYPO3-english mailing list