In MIT App Inventor, an argument in a procedure is a variable that receives a value when the procedure is called. It acts as a placeholder for data that you want the procedure to use to perform its task.
Key Concepts
Parameter vs. Argument: The terms are often used interchangeably, but there's a technical distinction. In App Inventor, the variable defined in the procedure block is a parameter. The value or variable you provide when you call that procedure is the argument.
Input for Procedures: Arguments allow you to make a procedure more flexible and reusable. Instead of creating a separate procedure for every slightly different task (e.g., one to calculate the area of a 5x5 square and another for a 6x6 square), you can create a single procedure that accepts the side length as an argument.
Scope: The argument variable is local to the procedure. This means it can only be used and its value can only be accessed within the blocks of that specific procedure. It doesn't exist outside of it.
Example
Imagine you want to create a procedure that calculates the area of a rectangle.
Without Arguments: You would have to hard-code the length and width inside the procedure.
This procedure would only ever calculate the area of a 10x20 rectangle. It's not reusable.
With Arguments: You create a procedure with two arguments, length and width.
Now, when you call this procedure, you provide the actual length and width values.
When you call the procedure and provide the values 5 and 8, the length argument receives the value 5 and the width argument receives the value 8, and the procedure then calculates 5 \times 8 = 40.
This single procedure can now calculate the area for any rectangle you specify, making your code more efficient and organized.
I have understood the explanation.
Getting back to original code above:
bgTimer does not have any parameters, so no arguments.
But MyFGprocess also does not have any parameters, then why x argument there ??
Also, in the image provided by you, process "run" does not have any parameters, then why x argument there?
So, while I was making an app designed to detect movement and then send a notification to the phone, I realized that the code did not happen more than once. I wanted to know if it is possible to start the entire code from the movement detection until the notification once again? This is all I did for the looping function and I don't really get how to do it.. if it is possible... Thanks.
How do you loop an entire system using Itoo extension?
So, while I was making an app designed to detect movement and then send a notification to the phone, I realized that the code did not happen more than once. I wanted to know if it is possible to start the entire code from the movement detection until the notification once again? This is all I did for the looping function and I don't really get how to do it.. if it is possible... Thanks.
So, the idea is for the detector to detect movement while the app is closed until the user decides to stop it, so I was hoping for it to continue performing its processes everytime it detects movement. However, when I tested it, it tests for movement once, does all its procedures once, and doesn't do it again. For reference it starts from here:
After it senses shaking, it does this:
This builds and sends the notification and it is here where I try to implement the loop. So, I do want to try the button thing you said.. but wouldn't that only loop it when the button is pressed? I did try it but I still don't know what I'm doing... this notification has extra buttons which send a message when pressed btw. Don't know if thats needed but yeah.
Use that example and restart from there
You create the process only once on button click
It starts the background process... somehow the process must start...and after starting the process then the sensor is activated to listen in the background
@Jimis your blocks are mostly ok, you are adding item "1" to the list, you only forgot to store the new list via StoreProperty method again, so later you see the difference after button click in the user interface... don't forget to open the listview there
Also there is no user interface in the background
EDIT: what you are doing is no real background processing, you are only creating the process, so this is not really a test if something is working in the background or not...
Oh I see, thank you, I was following an example from a different discussion. If I may ask as well, can itoo fetch a local variable in other procedures from another procedure if it is stored in itoo? Thanks.
EDIT: do you expect to get both evemts twice (one from the background, the other from the foreground?
what do you get if you deactivate the 2 phone call events (foreground)?
For a more useful test let me suggest to do a background test, close the app and use the Notifier Loginfo method for debgging and check the log using logcat
Thank you for you helpful comments and questions - And I am sorry that I just noticed your post yesterday
First of all, I apologize for this sloppy example/case. It was based on a test case that contained two Player components: one in the UI and another in the Itoo process. I suppose I was attempting to show that the UI Player PhoneCall events responded to a phone call but the Itoo events did not...
I would have expected the PhoneCall events that were registered in the Itoo process to respond to the call and not the UI built-in blocks...however because of how it actually behaved (the UI built-in events responded in place of the itoo registered events, it was confusing..
Yes - another sloppy job on my part... Because the text block "Join" would not accept the "status" variable, rather than solving that problem, I just put in the "constant" value... I have now decoded status using this procdure/function:
I have done separate tests for both of these variations. In all tests the app was started, then the player started, then a phone call was made but not answered - caller hangs up. Here is a brief description and summary of results.:
It appears that somehow the Itoo registered events are not being associated with the player running in the Itoo process - they are not called in any of the test...OR perhaps the player is not actually running in the Itoo process???
Are the process/thread ids from the logcat output of any use in determining this? Any test I can do to gather more information?