I just got here from the other forum.
Here is a Unit Test that I just built for testing the functionality of the FTP extension.
Result: The extension works great, no problems for what I need to do.
Hitch: Of course, if you call it over and over quickly, you will not like your results, it is non-blocking.
Solution: Using a method like this you can Queue requests and fire them when ready, in order.
SKILL LEVEL: NOVICE
(others can show you a much better way, but this is simple and it works for Unit Tests)
(The picture is high definition, open in new tab and zoom if you want to see it)
Since the functions are not blocking (which is good!) it is possible to crash them into each other. Lets say you have a button called “Create Directory”. IF you press that once. Great. If you press that 3 times fast, undefined behavior. This can be illustrated better by creating numbered directories using a for loop. If you try to create 20 directories quickly, you may get 3 or 10.
Adding a delay is awful. Dont do it.
Adding a blocking function is awful. Dont do it
The whole idea is to do other stuff (or sleep the CPU) between processing tasks which must be executed in order. If your code is nowhere doing nothing, THAT IS GOOD.
[SCREEN SHOT REMOVED]
What I do is queue up button requests
The first request is acted on
The next request can not be acted on until the first completes… (but it is not lost or crashed)
If you press the button 5 times, you will get 5 consecutive FTP actions with no collision.
I also dump logs to the terminal
Drawback: This can create a nasty user interface, so don’t do this If you do, set limits to how far in the hole your user can get. Nobody likes a bunch of stuff happening 20 seconds later (sigh).
Things of note: I process returns differently. Sometimes we expect an action to fail, sometimes we want to take drastic action if it does.
Decomposing the output: (Same picture as above)
[SCREEN SHOT REMOVED]
Create a new file
Try to create it again (fails of course)
delete the directory (works)
Try again (Throws Critical Error, blows out buffer)
Press Create 3 times in a row fast (all three run, runs as expected
I guess this is why Python folks have the concept of TRY.
Some things work
Some things may or may not work
Some things do not work
Some things must work (or you want to start over)
… A framework like this is how you can get past simple hurdles of testing. I am not saying it is good, I am saying that it works.
… End of the day? MIT AI2 is absolutely a TOOL and not a TOY. Ignore anyone who teases. Folks acted the same way about LabView, and LabView is a VERY POWERFUL tool.
(not posting the .aia because it requires a plugin to run)