mr-es335 Posted September 27 Posted September 27 Good day, Most of my scripts employ "Switch|Case"...however the following appears to only work as an "If|Then". ; ----------------------------------------------- ; Example4a _DoesRegKeyExist() ; ----------------------------------------------- Func _DoesRegKeyExist() Local $sKeyname = "HKEY_CURRENT_USER\Software\FabFilter" ; ----------------------------------------------- RegRead($sKeyname, "") ; ----------------- If @error = 1 Then SplashTextOn("NOTICE!!", "The registry key " & $sKeyname & " does not exist!", 800, 50, -1, -1) Sleep(3000) SplashOff() Else SplashTextOn("NOTICE!!", "The registry key " & $sKeyname & " does exist!", 800, 50, -1, -1) Sleep(3000) SplashOff() EndIf EndFunc ;==>_DoesRegKeyExist ; ----------------------------------------------- Is there any way in which to get the above to work with "Switch|Case"? For example: ; ----------------------------------------------- ; Example4b _DoesRegKeyExist() ; ----------------------------------------------- Func _DoesRegKeyExist() Local $sKeyname = "HKEY_CURRENT_USER\Software\FabFilter" ; ----------------------------------------------- Local $Result = RegRead($sKeyname, "") ; ----------------- Switch $Result Case 0 $Result = "The Registry Keys data...[" & $sKeyname & "]...does not exist!" Case 1 $Result = "The Registry Keys data...[" & $sKeyname & "]...does exist!" EndSwitch EndFunc ;==>_DoesRegKeyExist ; ----------------------------------------------- Please advise...and thank you for your time. mr-es335 Sentinel Music Studios
mr-es335 Posted September 27 Author Posted September 27 (edited) Good dya, I have been able to get this snippet to work... ; ----------------------------------------------- ; With the assistance of...and the gratitude of...ioa747! ; Date: September 15th, 2024 ; ----------------------------------------------- #include <FileConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- _CheckRegKeys() ; ----------------------------------------------- Func _CheckRegKeys() ; Source data Local $sKeyname[3] = [2] $sKeyname[1] = "HKEY_CURRENT_USER\Software\FabFilter" $sKeyname[2] = "HKEY_LOCAL_MACHINE\SOFTWARE\FabFilter" ; ----------------------------------------------- Local $sMessage = "Verify Registry Keys data..." & @CRLF & @CRLF ; ----------------------------------------------- For $i = 1 To $sKeyname[0] Local $Result = RegRead($sKeyname[$i], "") If @error = 1 Then $Result = "The registry key [" & $sKeyname[$i] & "] does not exist!" Else $Result = "The registry key [" & $sKeyname[$i] & "] does exist!" EndIf ; ----------------- $sMessage &= $Result & @CRLF Next ; ----------------------------------------------- $sMessage &= @CRLF & "Verify Registry Keys data completed..." & @CRLF ; ----------------------------------------------- SplashTextOn("NOTICE!!", $sMessage, 675, 157, -1, -1, 4, "FuturaBQ-DemiBold", 14) Sleep(3000) SplashOff() EndFunc ;==>_CheckRegKeys ; ----------------------------------------------- ...sooooo, maybe...all is Okay?!? Edited September 27 by mr-es335 mr-es335 Sentinel Music Studios
RTFC Posted September 27 Posted September 27 ConsoleWrite("This " & @CRLF) Switch @error Case 0 ConsoleWrite("works" & @CRLF) Case Else ConsoleWrite("fails" & @CRLF) EndSwitch My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O
Developers Jos Posted September 27 Developers Posted September 27 (edited) In the first post the IF tests for @error and the select case for the Returned value by the function.... which arent the same! Edited September 27 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.
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