emmanuel Posted May 7, 2004 Posted May 7, 2004 (edited) I run the command prompt like so: crit-patch-reboot.exe /custtext "" "I'd like it to use the default text for the title, and custom text for the window text" Select Case $cmdline[0] = 1 And ($cmdline[1] = '/h' Or $cmdline[1] = '/?' Or $cmdline[1] = '/custtext') MsgBox(0, "crit patch reboot", $hlpmsgtxt) Exit Case $cmdline[0] > 1 And $cmdline[1] = '/custtext' If $cmdline[2] Not '"' Then;this way, if they put "" for the title the default is used. $title = $cmdline[2] Else EndIf If $cmdline[3] Not '"' Then;this way, if they put "" for the text the default is used. $text = $cmdline[3] Else EndIf EndSelect but I get the following error: --------------------------- AutoIt Error --------------------------- Line 0: If $cmdline[2]Not '"' Then ;this way, if they put "" for the title the default is used. If ^ ERROR Error: Error in expression. --------------------------- OK ---------------------------I choose to have it check for " since that's what $cmdline[2] has if the second param is "" ... make sense? Edited May 7, 2004 by emmanuel "I'm not even supposed to be here today!" -Dante (Hicks)
CyberSlug Posted May 7, 2004 Posted May 7, 2004 (edited) The problem is not with the quotes but with the IF statements.You have three options:If $cmdline[2] <> '"'If Not ($cmdline[2] = '"')If Not ($cmdline[2] == '"')<> is the standard not-equals operatorNot (... = ...) negates the result of an equality test; functionally the same as <>Not (... == ...) negates the result of a case-sensitve equality testOther things to be careful about--that I sometimes forget:If $x = 1 or 2 or 3 ;WILL NOT workYou need to say If $x = 1 or $x = 2 or $x = 3Use parenthese when there might be confusion with multiple operators. For example:Question: Which of the following does If Not $x = 1 And $y = 2 mean?If Not ($x = 1 And $y = 2)If (Not $x = 1) And $y = 2If (Not $x) = 1 And $y = 2Andwer, always use parentheses so there is never any doubt what you mean.Hope that helps Edited May 7, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
emmanuel Posted May 7, 2004 Author Posted May 7, 2004 you guys are awesome, while you wrote those replies I went at it again, from a slightly different angle. (still thinking it was the " causing issues) expandcollapse popupAutoItSetOption("TrayIconHide", 1) Break(0) HotKeySet("^q", "bye") $hlpmsgtxt = 'designed by Emmanuel Pleshe <emmanuel.pleshe@pse.com> to prompt users to close all apps after crit patch and before reboot.' & @CRLF & '/? or /h summons this dialog' & @CRLF & ' /custtext "window title" "window text" adds custom window title and text' & @CRLF & 'putting * in place of either the text or the title will use the default text or title' & @CRLF & ' /custtext * "title is default, text is custom"' & @CRLF & 'press ctrl-q to escape without rebooting, just wait for the msgbox to timeout' ;don't think this part will work: ; & @CRLF & 'use @CRLF for next line, only in window text' ;default window title and text $defaulttitle = 'PSE IT Critical Patch' $defaulttext = 'A critical patch has been applied to your computer and you must reboot.' & @CRLF & 'Save all work that needs to be saved and close all applications then click OK' & @CRLF & 'Clicking OK will reboot your computer' Select Case $cmdline[0] = 1 And ($cmdline[1] = '/h' Or $cmdline[1] = '/?' Or $cmdline[1] = '/custtext') MsgBox(0, "crit patch reboot", $hlpmsgtxt) Exit Case $cmdline[0] > 1 And $cmdline[1] = '/custtext' If $cmdline[2] = '*' Then;this way, if they put * for the title the default is used. $title = $defaulttitle Else $title = $cmdline[2] EndIf If $cmdline[3] = '*' Then;this way, if they put * for the text the default is used. $text = $defaulttext Else $text = $cmdline[3] EndIf EndSelect $click = 0 Do $click = MsgBox(4144, $title, $text & @CRLF & 'This message box will repeat every thirty seconds until you reboot.', 30) Until $click = 1 If $click = 1 Then Shutdown(6) EndIf Func bye() Exit 0 EndFunc ;==>bye "I'm not even supposed to be here today!" -Dante (Hicks)
emmanuel Posted May 7, 2004 Author Posted May 7, 2004 oh, and thanks for clearing things up on the operators, I think I'll take another go at this in the morning. "I'm not even supposed to be here today!" -Dante (Hicks)
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