Proportion_Solver.aia (294.8 KB)
I took a look in your json file.
It maps phrases into other target languages, in a nested targetLanguage/phrase/translaton.
Nice.
proceeding into your code ...
I found your File component:
The default scope attribute can be set to point to the assets folder, if all you do with this component is load json files.
That would avoid having to include the // file name prefix for the MyDict load.
I am reading Clock1.Timer and Screen1.Initialize.
They need to be divorced from each other.
Beside mucking around with MDict, is there any other branch of Clock1.Timer that needs to run at startup?
It is ironic that your app teaches math functions, but you never use a value function in your app, and never parametrize.
I went looking for where valasztott_nyelv (the current language code) is set in your code, and found a couple of hundred tests of it.
That should have been hidden under layers of value function calls.
I am finding your use of global variables for signalling too complex for me, like a game of Jenga.
I recommend splitting up Clock1.Timer into a few separate well named Clock components with their own simpler single functions. Swiss Army knives are awful.
In Screen1.Initialize,
The FirstTime TinyDB tag/value is superfluous.
You could have asked for the TinyDB value at tag 'MyDict', with default an empty dictionary.
Drop it into global MyDict regardless, then test global MyDict against the value Empty Dictionary.
It is always simpler to lose global variables and flags, if you you can get your status information directly. Fewer wires to cross.
The code you want to execute in Screen1.Initialize after you are sure global variable MyDict has been loaded should be moved into a separate procedure, call it Initialize_Phase_2.
You would choose to call it from after you verified that global MyDict is ready, either early in Screen1.Initialize after MyDict came back full from TinyDB, or in the File1.GotText event, after you used the JSON data to load up TinyDB and the MyDict global variable.
I regret your code is too fragile for me to do that for you. I might break something amidst its nest of swords.
I went looking for old examples of applying translation techniques to lists of components.
Here's one of them.
No, there is no other branch of Clock1.Timer that needs to run at startup.
Please explain this to me in more detail so I can understand.
I did. Indeed, it's much simpler and clearer this way. By the way, I somehow didn't think that the Clock1 element could be renamed.
How can I make sure that the MyDict global variable is loaded?
I am attaching pictures of the blocks involved:

Until I know how to make sure that the MyDict global variable is loaded, I will not put the Initialize_Phase_2 part, which would be responsible for displaying the text values of the user interface elements, into a separate procedure.
I am trying this APK file on my phone.
Before installing the next copy after modifying the code, I delete my application data and the application itself (Proportion Solver) from my phone.
The video below shows that the error message appears when I run my application for the first time after installation, but when I run my application for the second time, my application works almost fine.
The video of my application.
Where am I wrong?
Is there a
Is Dictionary empty
block?
No, but empty list block on a dictionary seems to work OK
Now the error message mentioned in the title does not appear when I first run my application, however the text translations of the UI elements are not yet displayed, although a pop-up message indicates that the json file was loaded successfully.
Again, the element texts only appear when I run my application for the second time.
I am attaching a link to the video of the first and second run.
Application's first run.
Application's second run.
That must have something to do with what you are doing after setting global MyDict with the data.
Where can one find the 'Is Dictionary empty' block?
As I said above, there isn't one. The isListEmpty block (in Lists blocks) should do it OK
After setting up the global MyDict, I only use the MyDict data (regardless of whether it's the first or second run of my application - i.e. the code is the same every time I run my application) to display the text of the UI elements in the appropriate language.
So, if the code doesn't change on any run of my application, i.e. it works the same, then I don't understand why it doesn't work on the first run of my application (when the text elements from my MyDict dictionary need to appear on the elements), and why it works on the second, third, etc. run of my application (when the text elements from my MyDict dictionary also need to appear on the elements)?
Since the code is the same, I thought that this error (that the texts do not appear on the first run, but only on the second run) might be due to a timing problem. No?