Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titleCOUNTset("NextId", NextId) is how we set the count value
title

COUNTset saves the new value of the custom field in the custom field value file.

Code Block
languagelua
COUNTset("NextId", NextId) 
Expand

This means we can see the NextId in the card view of the component - and we can set it too!

Image Removed
Expand
titleTo test this, we can set the component to run every 2 seconds using component.setTimer{delay=}

You can use component.setTimer{} is used here to run main every 2 seconds.

This is a complete little program to increment a custom number field:

Code Block
require "COUNT.COUNT"

function main(Data)
   --Poll the component every 2 seconds
   component.setTimer{delay=2000}
   local NextId = COUNTget("NextId")
   NextId = NextId+1
   COUNTset('NextId', NextId)
end
component.setTimer{} is used here to run main every 2 seconds.
Expand
titleThe COUNT library solves this problem by giving a convenient interface to get and set a custom field value

Remember, the Custom Fields values are stored on disc in JSON. This means we can load and save them programmatically.

This is how this library works.

...