dyvel 20 Posted January 24, 2015 Report Share Posted January 24, 2015 Hi Do you guys have an idea about how to monitor a variable and if it has a value, then perform an action?This is my current if statement: if($comparison(#FileChooser0,"!=",$nothing)) { then { ImportCSV() comment("Clear the variable") set(#FileChooser0,$nothing,"Global") } } It works fine if I run it manually, but the point is, I want to load a file into the system without having to press a button after the file is selected. A constant loop seems like a bad idea for performance... Quote Link to post Share on other sites
pash 504 Posted January 24, 2015 Report Share Posted January 24, 2015 Not Sure Try. define ImportCsv(#FileIn) { if($file exists(#FileIn)) { then { } else { } } } Quote Link to post Share on other sites
dyvel 20 Posted January 24, 2015 Author Report Share Posted January 24, 2015 Hi pash Thanks for the suggestion, but from what I understand, a define only runs when it's called? Anyway, I tried it, but no luck.What I did: define ImportCheck(#FileChooser0) { if($file exists(#FileChooser0)) { then { ImportCSV() comment("Clear the variable") set(#FileChooser0,$nothing,"Global") } } } Quote Link to post Share on other sites
UBotDev 276 Posted January 24, 2015 Report Share Posted January 24, 2015 Dyvel, I think the only way to achieve that is to run an extra thread that would be checking that variable value and execute some code if needed. UBot and neither any of the plugins (as far as I know) support events and triggers. Quote Link to post Share on other sites
dyvel 20 Posted January 24, 2015 Author Report Share Posted January 24, 2015 I was afraid of that - perhaps that's a cue to some of the plugin developers? :-) Quote Link to post Share on other sites
deliter 203 Posted February 9, 2015 Report Share Posted February 9, 2015 so when the file is not their,the bot is idle?even asynchronous file reading must loop(I think lol) ui open file("open file",#file open)define $file added(#file added) { alert("File added!") set(#file open,"","Global") set(#back to sleep, $file wait(""),"Global")}define $file wait(#file wait) { if($comparison(#file open,"=",$nothing)) { then { wait(0.5) set(#back to sleep, $file wait(""),"Global") } else { set(#do something, $file added(""),"Global") } }}set(#start,$file wait(""),"Global") I dont know how but this works as asynchronous(i think thats what it is called,forgive me for not understanding the concept properly ) code,I can keep building other nodes and this is still working away even after pressing stop lol Anyone know why!! awesome ha ha 1 Quote Link to post Share on other sites
blumi40 222 Posted February 9, 2015 Report Share Posted February 9, 2015 Hi maybe this can help u ui html panel("<html><head> <meta charset=\"utf-8\"> <script src=\"http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js\"></script> <script> $(function()\{ $(\'#myvar\').on(\'change\', function()\{ // only one Time Dom-Search var m = $(\'#myvar\'); // look if the inputfield is not empty if(m.val() != \"\")\{ //console.log(\'works\'); // starts the define with your jobs ubot.runScript(\'do_the_job()\'); // set the input back to empty m.val(\"\"); \} \}); \}); </script> </head> <body> <input type=\"text\" id=\"myvar\"> </body> <html>", 100) define do_the_job { alert("works!") } blumi 2 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.