# How to create nutrition app with ocr scanner?

**URL:** <https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955>\
**Category:** Questions about Thunkable X\
**Created:** [February 21, 2021, 5:28pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955 "2021-02-21T17:28:00Z")\
**Posts on this page:** 20\
**Page:** 7

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [March 12, 2021, 4:04pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/122 "2021-03-12T16:04:01Z")

</div>

You can see an example of proper JSON parsing (just one way to do it but a good way) here:

> [@Get body part from an URL to use the data](https://community.thunkable.com/t/get-body-part-from-an-url-to-use-the-data/1161179/11):
>
> @gcesar.sotodi1u I tried the URL you provided and it is a list of tickets or something like this. I made this quick app to get the data This will show the first 3 tickets from the list. This is a sample output

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 12, 2021, 5:12pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/123 "2021-03-12T17:12:45Z")

</div>

Many thanks @tatiang

I highly appreciate your praise to my work.

---

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 12, 2021, 8:46pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/124 "2021-03-12T20:46:23Z")

</div>

Thank you for all the help! I’m going to work on it and I’ll show you what I come up with in a couple of hours.

---

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 13, 2021, 1:15am UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/125 "2021-03-13T01:15:20Z")

</div>

Should it be something like this?

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/9/4900f39420be6c5028a7240638f1a2b3da89033a.png)

---

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 13, 2021, 4:06pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/126 "2021-03-13T16:06:55Z")

</div>

Can someone please help me fix these errors, I need to finish this app today?

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 13, 2021, 4:14pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/127 "2021-03-13T16:14:03Z")

</div>

You are using a variable `carb` and you have assigned it the object of the API response.

Then you try to compare this object with simple numbers. This will never yield true.

The other issue, you need to keep in mind that `else if` condition evaluation is progressive which means it will check the first condition and if it happens to be true then no more conditions will be checked or tested. However, if the first condition comes up false, the next `else if` will be tested and again the next condition will only be tested when the current condition is false.

The way you listed the condition in the code does not follow this role and therefore will not work properly.

---

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 13, 2021, 4:19pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/128 "2021-03-13T16:19:04Z")

</div>

What should I replace for the object of the api response instead of the variable carbs?

---

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 13, 2021, 4:27pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/129 "2021-03-13T16:27:43Z")

</div>

Also is this how I should keep my **if/else** blocks?  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/6/76928e58d41cf3121945c47ea046a12941ade825.png)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 13, 2021, 4:36pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/130 "2021-03-13T16:36:43Z")

</div>

Let’s do what they call it dry run.

Assume the number you have from your API is 19.

What will happen with the blocks?

The first block is testing if the number is greater than or equal 12.5 so this will be true. And the label `Very health` will have the text “Very healthy” showing on it.

Let’s see the next condition, is the number (19) greater than or equal18, the answer is yes and the label `Somewhat healthy` will show the text “Somewhat healthy” on it.

Let’s proceed to the third block, is the number less than or equal 19, the answer is no and the label will not get updated.

Now the app is confusing the user. It has two labels with text in them. One saying “Very healthy” and the other saying “Somewhat healthy”.

This is not good.

---

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 13, 2021, 4:42pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/131 "2021-03-13T16:42:19Z")

</div>

I changed the **if/else** statements, but it still shows an error with the blocks. Are the **get properties** parsed wrong? Or is there another error?

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/b/bb159febde1c5cedb2f85f362f0cceab856370e9.png)

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [March 13, 2021, 4:43pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/132 "2021-03-13T16:43:22Z")

</div>

You’ve written nutriments instead of nutrients.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/5/e54233f81b6e1f5a3099f8ba213034795a4dedd3.png)

---

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 13, 2021, 4:45pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/133 "2021-03-13T16:45:28Z")

</div>

They called it “nutriments”.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/d/dd0a1655a9735d8be5e9f492a84fd2a91b4c7c4f.png)

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [March 13, 2021, 4:46pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/134 "2021-03-13T16:46:23Z")

</div>

Sorry, my bad. Didn’t notice.

---

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 13, 2021, 4:46pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/135 "2021-03-13T16:46:41Z")

</div>

That’s okay! Thanks for helping!

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [March 13, 2021, 4:47pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/136 "2021-03-13T16:47:20Z")

</div>

So basically, the food is healthy if the carbs are **less** than 12.5?

---

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 13, 2021, 4:47pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/137 "2021-03-13T16:47:52Z")

</div>

Yes, it is

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [March 13, 2021, 4:49pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/138 "2021-03-13T16:49:33Z")

</div>

OK, then you’ve done it the other way around. You’ve done  
if app variable carbs ≥ 12.5

but it’s actually  
if app variable carbs **≤** 12.5

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [March 13, 2021, 4:50pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/139 "2021-03-13T16:50:20Z")

</div>

Also, the food is unhealthy if the carbs are more than 19, right?  
If so, then you need to change the symbols like in my last post.

---

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 13, 2021, 4:51pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/140 "2021-03-13T16:51:49Z")

</div>

I changed the signs for both of them but it still says that there is an error with the blocks.

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [March 13, 2021, 4:52pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/141 "2021-03-13T16:52:39Z")

</div>

Can you share a screenshot of that error?

[Previous page](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955.md?page=6)

[Next page](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955.md?page=8)
