Find the closest match in the Tiny DB if tag not found

Dear all, I have been writing a correction factor lookup table for a transducer which is not linear.

For example the query is as below-
Tags Value stored in Tiny DB
1 0
10 1
100 2
200 3
200 4
400 5

suppose if the tag is not present then query should retrieve the previous tag stored value

if search is say 140, then the 2 (for tag 100) should be retrieved.
and for 160(for tag 200), then 3 should be retrieved.
Basically I need to find the closest match in the Tiny DB, if tag not found

Please attach .aia file for example.

blocks

FindClosest.aia (2.2 KB)

image

4 Likes

I am on my phone so I can not provide code.

Numbers make terrible TinyDB tags, because they sort alphabetically, not numerically.

You need a table (list of lists), and if you need persistence store it under a name tag you mentioned in your post and I just forgot.

You will need a loop through the table similar to the loop to place a score in a high scores table, without the clipping to shorten the table.

Search this board for Top 5

2 Likes

Yes thnx. :grinning:....

P.S. That get closest function would work nicely with the taglist of a separate TinyDB Namespace devoted to your calculations.

Separation is needed to avoid numeric comparison to typical TinyDB tags like user and password.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.