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

Function within a func ?

$
0
0
Ok im probably guessing this will be a no but ill ask anyway

I have 4 small functions that are all for one task which is checking windows updates

These are the functions

[ autoit ]         
Func _CollectPatches()     Local $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")     #forceref $oMYError     Local $objSearcher = _CreateSearcher(_CreateMSUpdateSession())     $colNeeded = _GetNeededUpdates($objSearcher)     $objSearcher = 0     Return $colNeeded EndFunc   ;==>_CollectPatches Func _CreateSearcher($objSession)     If Not IsObj($objSession) Then Return -1     Return $objSession.CreateUpdateSearcher EndFunc   ;==>_CreateSearcher Func _CreateMSUpdateSession($strHost = @ComputerName)     Local $objSession = ObjCreate("Microsoft.Update.Session", $strHost)     If Not IsObj($objSession) Then Return 0     Return $objSession EndFunc   ;==>_CreateMSUpdateSession Func _GetNeededUpdates($objSearcher)     SplashTextOn("Please Wait", "Checking For Updates", 220, 40, -1, -1, 18, "Tahoma", 11)     If Not IsObj($objSearcher) Then Return -5     $colNeeded = $objSearcher.Search("IsInstalled=0 and Type='Software'")     SplashOff()     Sleep(800)     Return $colNeeded EndFunc   ;==>_GetNeededUpdates

It would be great if i could include the secondary functions in a sub func so that they are contained within the main function

This is just an example to give you the idea of what i mean

[ autoit ]         
Func _CollectPatches()     Local $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")     #forceref $oMYError     Local $objSearcher = _CreateSearcher(_CreateMSUpdateSession())         Func _CreateSearcher($objSession)             If Not IsObj($objSession) Then Return -1             Return $objSession.CreateUpdateSearcher         EndFunc   ;==>_CreateSearcher         Func _CreateMSUpdateSession($strHost = @ComputerName)             Local $objSession = ObjCreate("Microsoft.Update.Session", $strHost)             If Not IsObj($objSession) Then Return 0         Return $objSession EndFunc   ;==>_CreateMSUpdateSession     $colNeeded = _GetNeededUpdates($objSearcher)     $objSearcher = 0         Func _GetNeededUpdates($objSearcher)             SplashTextOn("Please Wait", "Checking For Updates", 220, 40, -1, -1, 18, "Tahoma", 11)             If Not IsObj($objSearcher) Then Return -5             $colNeeded = $objSearcher.Search("IsInstalled=0 and Type='Software'")             SplashOff()             Sleep(800)             Return $colNeeded         EndFunc   ;==>_GetNeededUpdates     Return $colNeeded EndFunc   ;==>_CollectPatches

Its just a question does this exist in coding in general and hopefully AutoIT

Viewing all articles
Browse latest Browse all 12506

Trending Articles



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