Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Is this bad pratice

$
0
0
This is just an off question as i am not sure. Here is a random function i wrote.

[ autoit ]      
#NoTrayIcon ConsoleWrite(Timer()) Func Timer() $Temp = TimerInit() While Not WinExists('Notepad') If TimerDiff($Temp) > 5000 Then Return 1 sleep(250) WEnd Return 0 EndFunc

Is it bad returning a function, while being inside a Loop or should i exit the loop first before returning?

[ autoit ]      
#NoTrayIcon ConsoleWrite(Timer()) Func Timer() $Temp = TimerInit() While Not WinExists('Notepad') If TimerDiff($Temp) > 5000 Then ExitLoop sleep(250) WEnd If TimerDiff($Temp) > 5000 Then Return 1 If TimerDiff($Temp) < 5000 Then Return 0 EndFunc

Though sense functions return 0 by default, it could be this.

[ autoit ]      
#NoTrayIcon ConsoleWrite(Timer()) Func Timer() $Temp = TimerInit() While Not WinExists('Notepad') If TimerDiff($Temp) > 5000 Then ExitLoop sleep(250) WEnd If TimerDiff($Temp) > 5000 Then 1 EndFunc

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>