BPBNA Posted June 9, 2006 Posted June 9, 2006 (edited) This code is part of a shutdown script I wrote to practice my coding since I'm still learning AutoIt. I've looked over this code again and again and cant figure out why $choice always returns a 0. If they click no, it should return a 7, if they click yes it should return a 6. When it returns a 6, it should logoff/shutdown/reboot, whatever the selection is when its passed into the Shut function.Func Shut($type) Select Case $type = 0 MsgBox(36, "Log off", "All programs have been closed. Would you like to log off now?") $choice = @error Case $type = 1 MsgBox(36, "Shutdown", "All programs have been closed. Would you like to shutdown now?") $choice = @error Case $type = 2 MsgBox(36, "Reboot", "All programs have been closed. Would you like to reboot now?") $choice = @error Case $type = 4 MsgBox(36, "Log off", "All programs have been closed. Would you like to log off now?") $choice = @error Case $type = 5 MsgBox(36, "Shutdown", "All programs have been closed. Would you like to shutdown now?") $choice = @error Case $type = 6 MsgBox(36, "Reboot", "All programs have been closed. Would you like to reboot now?") $choice = @error Case $type = 9 MsgBox(36, "Shutdown", "All programs have been closed. Would you like to shutdown now?") $choice = @error EndSelect If $choice = 6 then Shutdown($type) MsgBox(0, "Error", "$choice = " & $choice, 3) Else MsgBox(0, "Error", "$choice = " & $choice, 3) Exit EndIf EndFunc;==> ShutEdit: The MsgBox in the If and Else statement is just for debugging. Edited June 9, 2006 by BPBNA
GaryFrost Posted June 9, 2006 Posted June 9, 2006 try: Func Shut($type) Select Case $type = 0 $choice = MsgBox(36, "Log off", "All programs have been closed. Would you like to log off now?") Case $type = 1 $choice = MsgBox(36, "Shutdown", "All programs have been closed. Would you like to shutdown now?") Case $type = 2 $choice = MsgBox(36, "Reboot", "All programs have been closed. Would you like to reboot now?") Case $type = 4 $choice = MsgBox(36, "Log off", "All programs have been closed. Would you like to log off now?") Case $type = 5 $choice = MsgBox(36, "Shutdown", "All programs have been closed. Would you like to shutdown now?") Case $type = 6 $choice = MsgBox(36, "Reboot", "All programs have been closed. Would you like to reboot now?") Case $type = 9 $choice = MsgBox(36, "Shutdown", "All programs have been closed. Would you like to shutdown now?") EndSelect If $choice = 6 then Shutdown($type) MsgBox(0, "Error", "$choice = " & $choice, 3) Else MsgBox(0, "Error", "$choice = " & $choice, 3) Exit EndIf EndFunc;==> Shut SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
BPBNA Posted June 9, 2006 Author Posted June 9, 2006 Perfect! Thanks! What exactly was I doing wrong? Doesn't @error return the value or is that only for actual errors?
RazerM Posted June 9, 2006 Posted June 9, 2006 @error returns the error code, which is 0 if there isn't an error My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
BPBNA Posted June 13, 2006 Author Posted June 13, 2006 Is there any way to send that value to a variable aside from returning it from a function?
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