...
Expand |
---|
title | Create a custom number field called 'NextId' and set it to the value 1 in your card. |
---|
|
See Custom Fields |
Expand |
---|
title | The COUNT library solves this problem by giving a convenient interface to GET/SET a custom field value |
---|
|
Remember Custom Fields the values for these are stored on disc in JSON. This means we can load and save them programmatically. This is what this library does. |
Image Added |
Expand |
---|
title | local NextId = COUNTget("NextId") is how we fetch the data |
---|
|
This is how we get the data from a custom field called NextId. Code Block |
---|
local NextId = COUNTget("NextId") |
|
...
Expand |
---|
title | It means we can see the NextId in the card view of the component - and we can set it too! |
---|
|
Image Added |
Expand |
---|
title | This is a complete little program to increment a custom number field |
---|
|
Code Block |
---|
require "COUNT.COUNT"
function main(Data)
--Poll the component every 52 seconds
component.setTimer{delay=50002000}
local NextId = COUNTget("NextId")
NextId = NextId+1
COUNTset('NextId', NextId)
end |
|
Expand |
---|
title | The COUNT library solves this problem by giving a convenient interface to GET/SET a custom field value |
---|
|
Remember Custom Fields the values for these are stored on disc in JSON. This means we can load and save them programmatically. This is how this library works. |
This is a very useful pattern for lots of ‘feeder’ interfaces.