youtuber Posted June 25, 2016 Share Posted June 25, 2016 2 writes and how returning? $var1 = "1.variable" $var2 = "2.variable" $var3 = "3.variable" For $i = 1 To 3 Step 1 MsgBox(0,"test Message header",$var1) Next For $i = 1 To 3 Step 1 MsgBox(0,"test Message header",$var2) Next If ($var2 = 2) Then Return $var1 For $i = 1 To 3 Step 1 MsgBox(0,"test Message header",$var3) Next Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 25, 2016 Moderators Share Posted June 25, 2016 @youtuber you use Return to exit a function with the desired value. I'm not sure what you're trying to do from your code, but a typical return would be something like this: #include <MsgBoxConstants.au3> MsgBox($MB_OK, "Example", Example(8)) Func Example($iVal) Local $x = 0 Switch $iVal Case 4 $x = "Four" Case 8 $x = "Eight" Case 12 $x = "Twelve" EndSwitch Return "You chose the number " & $x EndFunc youtuber 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
youtuber Posted June 25, 2016 Author Share Posted June 25, 2016 @JLogan3o13 Thank you I understand better now thanks to the return command then how can I get value if? #include <MsgBoxConstants.au3> MsgBox($MB_OK, "Example", Example(8)) If Example = 4 Then MsgBox(0,"test","Example 4") ElseIf Example = 8 Then MsgBox(0,"test","Example 8") ElseIf Example = 12 Then MsgBox(0,"test","Example 12") EndIf Func Example($iVal) Local $x = 0 Switch $iVal Case 4 $x = "Four" Case 8 $x = "Eight" Case 12 $x = "Twelve" EndSwitch Return "You chose the number " & $x EndFunc Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 25, 2016 Moderators Share Posted June 25, 2016 I still don't understand what you're trying to do. The String returned from the function will be "You chose the number" and then the string representation of whatever number you pass to the function. So Example is never going to = 4 or 8. You need to explain in detail what you're trying to accomplish, as you aren't being very clear. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
youtuber Posted June 25, 2016 Author Share Posted June 25, 2016 (edited) I want to do something like If Example = 4 Then Run("notepad.exe") else Run("mspaint.exe") Edited June 25, 2016 by youtuber Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 25, 2016 Moderators Share Posted June 25, 2016 So something like this: ShellExecute(Example(12)) Func Example($iVal) Local $sApp Switch $iVal Case 4 $sApp = "notepad.exe" Case 8 $sApp = "mspaint.exe" Case 12 $sApp = "calc.exe" EndSwitch Return $sApp EndFunc youtuber 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
youtuber Posted June 26, 2016 Author Share Posted June 26, 2016 yes you can show this, but I want to return with an if statement Can you show me an example of the if statement thank you Link to comment Share on other sites More sharing options...
Synapsee Posted June 26, 2016 Share Posted June 26, 2016 #include <MsgBoxConstants.au3> $test = Example(12) Switch $test Case "qsdsqdqsdqsd.exe" ;... Case Else MsgBox(0,"test","Example " & $test) EndSwitch Func Example($iVal) Local $sApp Switch $iVal Case 4 $sApp = "notepad.exe" Case 8 $sApp = "mspaint.exe" Case 12 $sApp = "calc.exe" EndSwitch MsgBox($MB_OK, "Example", $iVal) Return $sApp EndFunc youtuber 1 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