au3scr Posted January 18, 2009 Share Posted January 18, 2009 (edited) Hi , I am trying to make function that returns dir size 1-st msgbox (in func) shows right data,but second msgbox (in source it is beforefunc) shows me wrong info, it always shows 0 (zero) how I can make that secont msg box show right information? $sourcedir = "C:\windows" $ProgramSize = 0 _getsize($sourcedir,$ProgramSize) MsgBox(1,1,$ProgramSize) Func _getsize ($sourcedir,$ProgramSize) $ProgramSize = Round((DirGetSize($sourcedir) / 1024 )/1024,0) MsgBox(1,1,$ProgramSize) Return $ProgramSize EndFunc and How I could use it in If sentences later? i wanna do something like: IF _getsize() < 30 then _extraFunc endif I have never made any if sentences with funcs. Edited January 18, 2009 by au3scr Link to comment Share on other sites More sharing options...
Developers Jos Posted January 18, 2009 Developers Share Posted January 18, 2009 you need to byref the parameter for which you want to return its set value. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Pain Posted January 18, 2009 Share Posted January 18, 2009 Local $test $sourcedir = "C:\" _getsize($sourcedir, $test) ConsoleWrite($test) Func _getsize (ByRef $sourcedir, ByRef $ProgramSize) $ProgramSize = Round((DirGetSize($sourcedir) / 1024 )/1024,0) ;~ MsgBox(1,1,$ProgramSize) ;~ Return $ProgramSize EndFunc Link to comment Share on other sites More sharing options...
au3scr Posted January 18, 2009 Author Share Posted January 18, 2009 Thanks Link to comment Share on other sites More sharing options...
au3scr Posted January 18, 2009 Author Share Posted January 18, 2009 But whats wrong here? I want that 2nd (in source it is on 1-st place) msgbox show size and location of Microsoft .NET Framework 2.0, but function dont edit variables as needed. $ProgramSize = "N/A" $Location = "N/A" $SizeSourceRegSearch = "Microsoft .NET Framework 2.0" _getsize($SizeSourceRegSearch,$ProgramSize,$Location) MsgBox(1,1,$ProgramSize&" "&$Location ) Func _getsize (ByRef $SizeSourceRegSearch,ByRef $ProgramSize,ByRef $Location) MsgBox(1,1,$SizeSourceRegSearch) $Keyun = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" $cun = 1 Do $cun+=1 RegEnumKey($Keyun,$cun) Until @error $answerun = "" For $i= 1 to $cun $varun = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", $i) If @error <> 0 then ExitLoop $var2un = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"&$varun,"DisplayName") $var3un = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"&$varun,"UninstallString") $var4un = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"&$varun,"QuietUninstallString") If $var2un = $SizeSourceRegSearch Then $Location = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"&$varun,"InstallLocation") MsgBox(1,1,$Location) $SizeFromReg = Round (RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"&$varun,"EstimatedSize") / 1024,2) If Not $SizeFromReg = 0 Then $ProgramSize = $SizeFromReg EndIf EndIf Next ;~ Return $Location EndFunc Link to comment Share on other sites More sharing options...
Developers Jos Posted January 18, 2009 Developers Share Posted January 18, 2009 (edited) You are sure that the registry entry exists? Did you debug it by checking all returned values into $var2un? Jos Edited January 18, 2009 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
au3scr Posted January 18, 2009 Author Share Posted January 18, 2009 (edited) What u mean?This function likely repeat itself until it finds matching "DisplayName" and then it reads "InstallLocation" . MsgBox(1,1,$Location) on 25th line shows right info but msgbox on 6th line shows wrong info edit: it shows msgbox on line 25 2 times 1-st time it contains right info, 2nd time dont contain any info Edited January 18, 2009 by au3scr Link to comment Share on other sites More sharing options...
Developers Jos Posted January 18, 2009 Developers Share Posted January 18, 2009 (edited) Ok then it does find it... well when its found you will need to stop the Func and return. So add a return below the MSGBOX(). Jos Edited January 18, 2009 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
au3scr Posted January 18, 2009 Author Share Posted January 18, 2009 (edited) I tried following modification but it dont stop func.but I see MsgBox(1,1,"2nd func"&$Location) 2 times for some reason, and that 2-nd time it goes bad.If $var2un = $SizeSourceRegSearch Then $Location = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"&$varun,"InstallLocation") MsgBox(1,1,"2nd func"&$Location) $SizeFromReg = Round (RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"&$varun,"EstimatedSize") / 1024,2) If Not $SizeFromReg = 0 Then $ProgramSize = $SizeFromReg ExitLoop Edited January 18, 2009 by au3scr Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now