AppInventor - Why does ".initialize" not work? - app-inventor

In my application I want to run some code when opening a screen. AppInventor has a function ".initialize" for this, but it does not seem to work.
When I open the screen the code does not run, while the code is fine because it does work when I trigger it with something else than the ".initialize" function.
I have these code blocks: https://imgur.com/a/y0ZMqa3 as you can see the code inside is exactly the same but it doesn't run when the screen initializes while it does work when I check the checkbox.

I don't think its possible to get tiny DB values when the screen initializes. Perhaps try adding another component like a clock with a timer and then using the same blocks you have on .initialize after a certain time interval of some 500 milliseconds. Since as you say it doesnt work on the .initialize block but does work when the checkbox is changed.

What's the code?
You have to give us an idea of what it is your working with for us to be able to try and help you. Trust me man the chances of your question getting answered here are slim even if you pit it perfectly.
This is way too vague for somebody to even attempt to answer.
Next time make sure you ask with specifics.

Related

Need help selecting an item from a dropdown list in HP UFT

I need some help with selecting a value from a dropdown list. The dropdown is a WebElement, and the flow works well up to the point where the value should be selected.
My code is as follows:
.Browser("Browser").Page("PageName").WebElement("DropDownList").Click
.WebList("ListOfItems").Select(itemToSelect)
Note: itemToSelect is the name of the item that needs to be selected from the list, which is being passed as a parameter within the function.
When running the code, I get an unspecified error.
The weird thing is that before the error is thrown, I can see the value being selected from the list in the browser, as upon selecting it, some fields in the form change. Also, if I press "Skip" in the error message panel, the process goes on as if nothing happened.
I am certain the error comes from .WebList("ListOfItems").Select(itemToSelect) but I do not know what to do in order to fix it.
Try this code.It works for me.
StrAllItems = Split(Browser("name:=.*").Page("title:=.*").WebList("name:=.*").GetRoProperty("all items"),";")
For intCounter = Lbound(strAllItems) to Ubound(strAllItems)-1
If Browser("name:=.*").Page("title:=.*").WebList("name:=.*").GetItem(intCounter)= "SomeValue" Then
Browser("name:=.*").Page("title:=.*").WebList("name:=.*").Select (intCounter)
Exit For
End If
Next
Please let me know if this help.
If the test behaves correctly and you're just getting an superfluous error you can just ignore this specific error. It's best of course to understand where the error comes from, you should probably contact MicroFocus support but in the meantime you can turn off error handling for the offending line.
Browser("Browser").Page("PageName").WebElement("DropDownList").Click
On Error Resume Next ' turn off error handling
Browser("Browser").Page("PageName").WebList("ListOfItems").Select(itemToSelect)
On Error Goto 0 ' turn error handling back on
BTW, I changed your code a bit to make it valid, I assume this is what your code really looks like.
Possible timing issue: You might need to wait for the hole list to appear before you select the item.
Often, the item exists, but the app is still updating its GUI.
Whenever you access the GUI with UFT while the app is not idle (f.e. not ready for user input because it is still updating its HTML), you might get all kinds of strange results, including unexpected errors, hangs, instability.
So how do you wait for the list to be complete? I don't know, because it heavily depends on the way your app is refreshing its GUI. You need to explore that, and integrate some synchronization code that waits for the right condition to be met.
Unfortunately, this is a hell of a job sometimes.
A suitable workaround (and a good way to verify if my hyphothesis is correct) might be to insert a large delay between the first click and the list item selection click. (A quick way to do a similar thing is to single-step through the code.) If that does not generate any error or issues, you can be pretty sure it is what I describe, and you can experiment with lower delay durations to find a good value.
Thanks to everyone for your replies.
The issue turned out to be due to the object not being added well to the repository.
It was eventually fixed by adding it properly.

Xcode always show variables

I'm very new to xcode.
I need to know what my variables all look like. I'm writing a program for homework that constantly takes in user input in a while loop.
During a normal breakpoint the variables are visible, however when I get into an fgets call the variable viewer window is empty while it waits for the input.
I need to know what my variables look like but I don't need a breakpoint because I need to keep passing in input. How do I do that?
Edit: guys my homework is getting due soon and I'm having trouble fixing this. I need to know the answer to this question because I'm having trouble debugging my program and Google searches haven't helped me at all

Complex code in AsyncTask freeze progressBar

I have a complex code in AsyncTask, which makes alot of I / O on SQLite and heavy calculation. This piece of code is very long and that's why I did not copy it here. When my code is commented AsyncTask works very well and update progress bar correctly, but with my code, the progress bar is frozen until at the end of my code.
Can anyone give me recommendations to respect, to write the program like mine with of course, a worker thread and a progress bar that works well?
I finished my project. in phase of development, I had no problem. but in phase testing with real data I am confronted with this problem. It's been three days that I read on a AsyncTask discussed on this forum but neither my help and I do not know what to do. I also frozen.
Thank you for your help.
The problem is resolved.
Apparently my code uses alot of CPU time and does not leave enough time for UIThread to update the screen.
So I set the portion of code that accede SQLite in another thread using a Handler and a CountDownLatch with 10ms delay to start the thread. and this delay allows android has to release time for UIThread to refresh. this way, publishProgress started working. Now I wonder if it's a good solution.

axapta thread / animation

i have a function which costs plenty of time.
this function is an sql-query called via odbc - not written in x++, since the functional range is insufficient.
while this operation is running, I want to show an animation on a form - defined in the aviFiles-macro.
trying to realize, several problems occur:
the animation doesn't start prior the function has finished.
using threads won't fulfill my hopes, since the odbc-settings are made on the server and i guess, the function is called on client-side.
besides - how am i able to get the information that the treaded task has ended up?
could anyone give me a hint, how to
play an animation on a form
do something ( in background ) and go on playing the animation until the task to perform is finished
stop the animation
coding this in exactly this order shows the behaviour mentioned above.
thanks in advance for hints and help!
You can use standard AotFind as an example:
split the work in small pieces each
piece should be executed at timer
tick
Also, you can try not to use timer, but to call infolog.yield() as often as possible.
this could potentially be done in a very complicated way with call backs and delegates if your odbc is in a vs project...
but isn't the real solution to try to find a faster/more effective way to query your data?

Is midiOutPrepareHeader a quick call?

Does midiOutPrepareHeader, midiInPrepareHeader just setup some data fields, or does it do something that is more time intensive?
I am trying to decide whether to build and destroy the MIDIHDR's as needed, or to maintain a pool of them.
You really have only two ways to tell (without the Windows source):
1) Profile it. Depending on your findings for how long it takes, have a debug-only scoped timer that logs when it suddenly takes longer than what you think is acceptable for your application, or do your pool solution. Though the docs say not to modify the buffer once you call the prepare function, and it seems if you wanted to re-use it you may have to modify it. I'm not familiar enough with the docs to say one way or the other if your proposed solution would work.
2) Step through the assembly and see. Don't be afraid. Get the MSFT public symbols and see if it looks like it's just filling out fields or if it's doing something complicated.

Resources