Skip to first unread message

aumandg

unread,
Dec 24, 2018, 6:21:09 PM12/24/18
to MIT App Inventor Forum
This is a continuation of this thread https://groups.google.com/forum/#!category-topic/mitappinventortest/general-questions-about-app-inventor-programming/mit-appinventor-2/Kb_rpiKm8QU

I know its been a while but I did not solve my problem.  I currently have these blocks below.  With these blocks I am testing to see if I can get the result that I need to up date an existing app that I have that is not working any longer do to the api call changing format after the app was created and working.  I need to be able to take what is listed in TextBox1 and find it in the list and then pull the price associated with it.

Example:  From the API call below  find BTC witch would be in the Textbox1 and pull just the price (4104.27619264) so I may use it to do a math problem.

My thought was that If I could find BTC in the list and then find its index and then use a look up in pairs to get the price, but I can not get any solution to work as what ever I try the blocks indicate that BTC is not in the list.  I have checked to see if the dataList is a list and I get "true" so I am very confused why its comes back and says that BTC is not in the list when I test this with the "is in list" block.

screen shot 1.png


screen shot 2.png



TimAI2

unread,
Dec 24, 2018, 8:07:48 PM12/24/18
to MIT App Inventor Forum
I ran your url:


to get the json data, seems you are "mining" deep enough to get down to just one key?

BLOCKS

blocksmining.png


I could be missing something though...


aumandg

unread,
Dec 24, 2018, 10:08:40 PM12/24/18
to mitappinv...@googlegroups.com
Hello TimAI2,

I am looking to pull the price of any item, it may not be ID1, might be 2 or 34.....

TimAI2

unread,
Dec 25, 2018, 7:47:30 AM12/25/18
to MIT App Inventor Forum
So in my example simply replace "1" with the ID you are after, in global Decode3, using a list generated from the json of all the IDs

ABG

unread,
Dec 25, 2018, 12:24:18 PM12/25/18
to MIT App Inventor Forum
I left you a general purpose tree search routine
containing_object
in the project JSON_Finder in post 

If you pass it parameters "symbol" and "BTC" within the "data" tree,
it should return the subtree with id 1 (in this sample).

From there you have 3 hops into the tree using lookup in pairs:
quotes
USD
price

ABG


Capture.PNG
blocks.png

TimAI2

unread,
Dec 25, 2018, 1:46:19 PM12/25/18
to MIT App Inventor Forum
No doubt ABG's example is better, but reworked my first example to find the symbol from selected ID (as per the OP!), getting the price should then follow on from there

blocksFindSymbol2.png


ABG

unread,
Dec 25, 2018, 7:01:29 PM12/25/18
to MIT App Inventor Forum
Here's a working sample, more powerful ...

Don't break apart the procedures, they are meant to be used whole.
See the Books section of the FAQ for how to use value procedures.

ABG

ABG

unread,
Dec 26, 2018, 2:17:26 PM12/26/18
to MIT App Inventor Forum
I just improved the app and doc to use List Pickers
instead of text boxes, for ease of use.

If you downloaded from the Gallery, delete the project and download it again
to get the new one.

revised Doc:

ABG


aumandg

unread,
Dec 27, 2018, 8:43:43 AM12/27/18
to MIT App Inventor Forum
Thank you ABG, I will take a look at this week and see if I can understand it.

aumandg

unread,
Dec 27, 2018, 4:28:34 PM12/27/18
to MIT App Inventor Forum
I believe I understand how it works, I will see If I can implement it into my app.

aumandg

unread,
Dec 27, 2018, 4:43:40 PM12/27/18
to MIT App Inventor Forum
As I test this API today there is a message at the top that says "it will shortly be depreciated" great now I get to look at different one, I guess it will keep me on my toes.

Reply all
Reply to author
Forward
0 new messages