Bettylou Posted May 25, 2016 Posted May 25, 2016 Just checking --- I'm calling a function within a function is this code correct? Func _Java() Local $JV = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Auto Update", "AUVersion") Local $Ver = StringTrimLeft($JV, 2) If @OSVersion = "WIN_XP" Then _XPJAVA() Else If $Ver < 8.91 Then FileWrite($hLogFile, "Java" & " (version " & $Ver & ")" & " is *out of Date*" & @CRLF) Else FileWrite($hLogFile, "Java" & " (version " & $Ver & ")" & @CRLF) EndIf EndIf EndFunc Func _XPJAVA() Local $Ver If $Ver < 7.80 Then FileWrite($hLogFile, "Java" & " (version " & $Ver & ")" & " is *out of Date*" & @CRLF) Else FileWrite($hLogFile, "Java" & " (version " & $Ver & ")" & @CRLF) EndIf EndFunc
BrewManNH Posted May 25, 2016 Posted May 25, 2016 Func _XPJAVA() Local $Ver If $Ver < 7.80 Then FileWrite($hLogFile, "Java" & " (version " & $Ver & ")" & " is *out of Date*" & @CRLF) Else FileWrite($hLogFile, "Java" & " (version " & $Ver & ")" & @CRLF) EndIf EndFunc This code will never work as you want it to, you redeclare the $Ver variable so $Ver will always be less than 7.8. You're not referencing the variable $Ver from the _Java function, in that function, you're referencing the Local version of it. Other than that, calling one function from within another function is valid. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
AutoBert Posted May 26, 2016 Posted May 26, 2016 Func _Java() Local $JV = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Auto Update", "AUVersion") Local $Ver = StringTrimLeft($JV, 2) If @OSVersion = "WIN_XP" Then _XPJAVA($Ver) Else If $Ver < 8.91 Then FileWrite($hLogFile, "Java" & " (version " & $Ver & ")" & " is *out of Date*" & @CRLF) Else FileWrite($hLogFile, "Java" & " (version " & $Ver & ")" & @CRLF) EndIf EndIf EndFunc ;==>_Java Func _XPJAVA($Ver) If $Ver < 7.80 Then FileWrite($hLogFile, "Java" & " (version " & $Ver & ")" & " is *out of Date*" & @CRLF) Else FileWrite($hLogFile, "Java" & " (version " & $Ver & ")" & @CRLF) EndIf EndFunc ;==>_XPJAVA But why a second func? Func _Java() Local $JV = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Auto Update", "AUVersion") Local $Ver = StringTrimLeft($JV, 2) If @OSVersion = "WIN_XP" Then If $Ver < 7.80 Then FileWrite($hLogFile, "Java" & " (version " & $Ver & ")" & " is *out of Date*" & @CRLF) Else FileWrite($hLogFile, "Java" & " (version " & $Ver & ")" & @CRLF) EndIf Else If $Ver < 8.91 Then FileWrite($hLogFile, "Java" & " (version " & $Ver & ")" & " is *out of Date*" & @CRLF) Else FileWrite($hLogFile, "Java" & " (version " & $Ver & ")" & @CRLF) EndIf EndIf EndFunc ;==>_Java
Bettylou Posted May 27, 2016 Author Posted May 27, 2016 Thanks BrewManNH. After pulling my hair out for hours I figured that out too. Thanks AutoBert that's just what I was looking for.
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