For some reason I can't store a variable in a dictionary value

I can't store a variable in a dictionary value, or it will give me an error.
image
this is the layout of my code.

Here ?

image

You need to load this inside an event (like Screen.Initialise), you cannot set a variable at runtime from a variable or variables you set at runtime.

What are you doing when the error arises, which part of your blocks are you using ?

You have several other errors

  • Empty sockets
  • Blank TinyDB tags
  • Mismatched notifier choices vs choice tests

Yes and No are poor notifier choices. Instead, use more descriptive words like Save, Delete, Quit.

Be consistent in your Case choice

(From my phone)

Ok, yeah I fixed the empty slots and that stuff, but the names stuff and its a good idea because its less of a hassle with the same choice words, so I had to mess with the case. Here, does this look better?

There was a movie named Benjamin Button, about a man who lived his life backwards.

Trace the flow of data in your Screen1.Initialize event, top to bottom.

It looks like it was written by Benjamin Button.

You try to use data that was never stored into global variables or Label.Texts.
They will all be exactly what the global init blocks and the Designer say, that early in theprogram run.

Then you belatedly try to load the global variables from TinyDB, using tag parts that have not yet been given meaningful values.

Backwards is code Yours.

Another thing, regarding Notifiers.

When you are using Notifiers for different purposes, it makes coding easier to pull in extra Notifiers and rename their components to mention what decision they control (ntfQuit, ntfStartWWIII, ntfGoBack, ntfEmptytheDatabase,...) The benefit of that is getting to pull in well named event blocks to catch the different choices, without having to collect them all in one long and meandering if/then/elseif block.


thanks about the screen initalize, it probably would have gone unnoticed and i would have been wondering why doesent this save? thanks for catching that.actually, i think that is the entire reason it wouldn't save.i will test and see what happens.

Screen1.Initialize is hard to test using the Do It technique.

Here's a way to single step through the blocks you have in Screen1.Initialize:

  • Create a procedure named Initialize.

  • Pluck out all the blocks from Screen1.Initialize and put them into the new procedure.

  • Connect to the Companion, and start your app, without pressing any buttons or letting any Clocks fire, so everything is nice and fresh, with data as Screen1.Initialize would find it.

  • In the Blocks Editor, apply right-click Do It to see the data flow from right to left, top to bottom, in the procedure. Start at the top right, work your way left, then down.

  • As each data bubble pops up, check to see if it is what you expected, or a surprise. (This is the most important part.)

That should let you see what is happening in your Screen1.Initialize event.

It's not pretty.

You do not set rowsinproject until after you call it in progressDictionary...

ok, i tested and got this error.
image
i am still following AGB's process. one sec.

ok, i can't find Do It, i right click in the blocks area, a scroll bar pops up, but it doesnt have do it. i also tried searching in the top left.

Did you disable all Clocks in the Designer?

http://ai2.appinventor.mit.edu/reference/other/testing.html

im not using phone, so does that have anything to do with that

You should be able to run the Companion in an emulator.

I don't have the emulator, I'm using the MIT AI2 Companion.
Also, do MIT app inventor 1 and 2 have Do It differences? I think that I'm using MIT 1.How do you check?

AI 1 is long gone.

What is your hardware?

ok, i get it, you right click on the block. thanks ill test oh, also i found out im using MIT 2. i think Do It only works with emulators because it won,t show up. I'm still reading the link you gave me.

No, Do It works with companion app on devices (phones) and some emulators.

You need to be connected for it to work, and will not generate an output if you test Do It on a local variable, unless you supply the values.

I fixed those problems and then I tested and it didn't work.it just didn't show up.Here is the new layout since its changed a lot.

new layout