[SOLVED 2/1/24 8:53 PM EDT] Bug with integers from a local table in a loop

General
I’m making a small cookbook app (nothing fancy).
My home screen is a list_viewer connected to a local table (Recipe).

When the user click on a recipe, it opens a screen with more informations (like ingredients and instructions).

Tables
Recipes : one line per recipe with the name, description, etc. of the recipe.
Ingredients : Multiple lines per recipe, each line being one ingredient.

To prevent extensive loops, in the Recipes table, there are columns for the start and end IDs of each ingredient. For example, a recipe with ID 0 has value 0 for column “ingr_start” and a value of 5 for another column named “ingr_end”, indicating that ingredients with IDs ranging from 0 to 5 belong to recipe 0.
Truncated recipes table :
chrome_BDMF8eA8y6
Ingredients table:
chrome_v6EQifZHq1

Blocks
Here are the block for the home screen (works correctly) :
chrome_IURKbwkS3E

Here the blocks of the recipe screen:


(the final version will put the text in a list, but here I’m just working with the ids for debugging purposes).

What’s not working
As you can see in the upd_ingr function, the i variable should iterate from the ingr_start to the ingr_end (so taking the value if 0, then 1, then 2…up to 5 for the first recipe). but it does not :
chrome_KHazcDnsDr

I think the problem comes from the ingr_start property, because if I change the loop by this :


then it works ! (well i iterate from ingr_end - 5 to ingr_end)
Here is what is suppose to happen :
chrome_GPf7XhlApP

If I try from (ingr_start) to (ingr_start + 5) → doesn’t work (that’s why I suppose the problem comes from this property).

I can’t find out why this is not working and at this point, I think it’s a bug

Try adding 0.

We really need a parseInt() or toNumber() block to convert strings to ints

Tables store Val’s as strings. You can’t define the type of state held in the columns

2 Likes

Thank you !
I knew there was something wrong with the type of the variable.
Good to know that I can manipulate the variable type’s that way

1 Like

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