mr-es335 Posted yesterday at 03:17 PM Share Posted yesterday at 03:17 PM 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 Link to comment Share on other sites More sharing options...
mr-es335 Posted 23 hours ago Author Share Posted 23 hours ago (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 23 hours ago by mr-es335 mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
RTFC Posted 23 hours ago Share Posted 23 hours ago 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 Link to comment Share on other sites More sharing options...
Developers Jos Posted 23 hours ago Developers Share Posted 23 hours ago (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 23 hours ago 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...
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