johnmcloud Posted December 30, 2011 Share Posted December 30, 2011 (edited) I don't have idea, but i have two equal code, but give me two different result This script work, and i have at finish the MsgBox Func A() $Path = GUICtrlRead($FolderInput_LvA) $Pre = "Test.exe" $Command = "-e -p" $Folders= _FileListToArray($Path, '*', 1) $Folders[0] = "@echo off" & @CRLF For $i = 1 to UBound($Folders) -1 $Success = $Folders[$i] = RunWait(@ComSpec & " /c " & $pre & " " & $command & " " & " " & '"' & $Path & "\" & $Folders[$i] & '"', @TempDir, @SW_HIDE) Next If GUICtrlRead($FolderCheckbox) = $GUI_CHECKED Then Test() EndIf If $Success Then MsgBox(0,"Information","Success") FileDelete(@TempDir & "\Test.txt") EndIf Return 1 EndFunc This do the @ComSpec command but i don't have the MsgBox, because the result is different ( i have try to make "If Not $Success Then" and i have the MsgBox) I have only change the $FolderInput_LvB and the command, i have both code in the same script, but two different Func() Func B() $Path = GUICtrlRead($FolderInput_LvB) $Pre = "Test.exe" $Command = "-f -p" $Folders= _FileListToArray($Path, '*', 1) $Folders[0] = "@echo off" & @CRLF For $i = 1 to UBound($Folders) -1 $Success = $Folders[$i] = RunWait(@ComSpec & " /c " & $pre & " " & $command & " " & " " & '"' & $Path & "\" & $Folders[$i] & '"', @TempDir, @SW_HIDE) Next If GUICtrlRead($FolderCheckbox) = $GUI_CHECKED Then Test() EndIf If $Success Then MsgBox(0,"Information","Success") FileDelete(@TempDir & "\Test.txt") EndIf Return 1 EndFunc What is the problem? Thanks Edited December 31, 2011 by johnmcloud Link to comment Share on other sites More sharing options...
spudw2k Posted December 30, 2011 Share Posted December 30, 2011 (edited) upon examination it looks to me (without testing) that perhaps the -f flag is the culprit. If you run the command in a cmd prompt do you get the results you'd expect? Also, not too sure about the following statement$Success = $Folders[$i] = RunWait(.....) I've never seen a statement with an $var1 = $var2 = Func Edited December 30, 2011 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
johnmcloud Posted December 30, 2011 Author Share Posted December 30, 2011 (edited) upon examination it looks to me (without testing) that perhaps the -f flag is the culprit. If you run the command in a cmd prompt do you get the results you'd expect? Also, not too sure about the following statement$Success = $Folders[$i] = RunWait(.....) I've never seen a statement with an $var1 = $var2 = Func Mmm how strange... I have changed to this for second script: $Folders[$i] = RunWait(@ComSpec & " /c " & $pre & " " & $command & " " & " " & '"' & $Path & "" & $Folders[$i] & '"', @TempDir, @SW_HIDE) $Success = $Folders[$i] i have the MsgBox for FuncB(), but if i try to apply THE SAME THING to FuncA() don't work, i have message for B and not for A, before i have MsgBox for A and not for B... Edited December 30, 2011 by johnmcloud Link to comment Share on other sites More sharing options...
jaberwacky Posted December 30, 2011 Share Posted December 30, 2011 (edited) Check that these values are correct:$Path = GUICtrlRead($FolderInput_LvA) $Path = GUICtrlRead($FolderInput_LvB) Is variable $Success a global? If so, do you assign any values to variable $Success within function Test()? Edited December 30, 2011 by LaCastiglione Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
johnmcloud Posted December 30, 2011 Author Share Posted December 30, 2011 (edited) I have resolved, this time without your hand guys I have changed this part like this and work for both code: $Success = $Folders[$i] = RunWait(@ComSpec & " /c " & $pre & " " & $command & " " & " " & '"' & $Path & "" & $Folders[$i] & '"', @TempDir, @SW_HIDE) Next If GUICtrlRead($FolderCheckbox) = $GUI_CHECKED Then Test() EndIf If $Success = 1 Then MsgBox(0,"Information","Success") FileDelete(@TempDir & "Test.txt") Else MsgBox(16,"Error","Error") FileDelete(@TempDir & "Test.txt") EndIf Return 1 Thanks anyway for support Edited December 30, 2011 by johnmcloud Link to comment Share on other sites More sharing options...
kylomas Posted December 30, 2011 Share Posted December 30, 2011 johnmlcoud, Congrats! $Success = $Folders[$i] = RunWait(@ComSpec & " /c " & $pre & " " & $command & " " & " " & '"'... This is kind of an unusual construct. $success seems to evaluate to true or false depending on the results of the 2nd and third parts of this construct. Is this your intent? How did you arrive at this? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
johnmcloud Posted December 30, 2011 Author Share Posted December 30, 2011 (edited) johnmlcoud, Congrats! $Success = $Folders[$i] = RunWait(@ComSpec & " /c " & $pre & " " & $command & " " & " " & '"'... This is kind of an unusual construct. $success seems to evaluate to true or false depending on the results of the 2nd and third parts of this construct. Is this your intent? How did you arrive at this? kylomas Thanks for congrats, but i'm only a noob respect of all guru of this forum. Yes, was my intent, I got there at random attempts and seem work fine for my script Work like $success is 1 if $Folders[$i]=1 if RunWait=1 If one of there is 0 the result is 0, i think Edited December 30, 2011 by johnmcloud Link to comment Share on other sites More sharing options...
kylomas Posted December 30, 2011 Share Posted December 30, 2011 johnmcloud, All the better for you! If everyone was willing to dig a bit...well that is not relevant here. I wonder what a dev thinks of that construct???? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
jaberwacky Posted December 30, 2011 Share Posted December 30, 2011 (edited) Here's what I get:Global $Success = '' Global $Test = '' $Success = $Test = 123 ConsoleWrite("$Success: " & $Success & @CRLF & "$Test: " & $Test & @CRLF) $Success: False $Test: My guess is that $Test is not being assigned to and so it returns false which gets assigned to $Success. Edited December 30, 2011 by LaCastiglione Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
kylomas Posted December 30, 2011 Share Posted December 30, 2011 LaCastiglione,Tried the same with local $a = 10, $b = 20, $c = 30 $a = $b = $c consolewrite($a & @lf & $b & @lf & $c & @lf)which resulted in false2030kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 30, 2011 Moderators Share Posted December 30, 2011 Kylomas,I wonder what a dev thinks of that construct????This Mod thinks it is an abomination and it only works by pure luck. johnmcloud,I would strongly advise against using non-standard contructs of that sort - you will only get bitten by one not working as you expect one day. And will you be able to remember how it is supposed to work when you look again at the script in several months time? Go for simplicity - AutoIt is slow enough that any time you save will be minimal, and large enough when compiled that you do not save much in size terms by condensing assign statements like that. Finally anything involving Booleans should be simple as possible as getting their logic right is difficult enough as it is M23 johnmcloud 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
kylomas Posted December 30, 2011 Share Posted December 30, 2011 @M23, Thanks, suspected as much... kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
kylomas Posted December 30, 2011 Share Posted December 30, 2011 (edited) @m23, Interesting though that this resolves to True Local $a = 5, $b = 6, $c = 6 $a = $b = $c ConsoleWrite($a & @LF & $b & @LF & $c & @lf) kylomas edit: conjecture...ternary ops come to mind! Edited December 30, 2011 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
johnmcloud Posted December 30, 2011 Author Share Posted December 30, 2011 Ok guys, is only fortune You are more expert then me, someone can show the "right" way to do that script? I have do it that way because i can't find different solution for both code in the same script Thanks Link to comment Share on other sites More sharing options...
BrewManNH Posted December 30, 2011 Share Posted December 30, 2011 It evaluates as true because $b equals $c, they're both 6. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 30, 2011 Moderators Share Posted December 30, 2011 kylomas,Ternary ops have been brought up several times in other closed parts of the forum - the last time it was sort of agreed that in a language that strives for ease of use they were an unneccesary complication. Although I did like one pro-ternary comment in particular (and it did not come from the person you might think!): I still don't find that just because it's easier to cut your head off with a chainsaw than an axe that a chainsaw isn't a viable tool. Yes it can turn the situation ugly much faster than an axe, but that's all up to the user. You can't save people from stupid.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
BrewManNH Posted December 30, 2011 Share Posted December 30, 2011 $a = $b = $C isn't any different than doing something like If $B = $C Then <do something>. It's evaluating whether or not $B equals $C and if it does (True), do something. The initial value of $a is overwritten by the boolean comparison result. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
kylomas Posted December 30, 2011 Share Posted December 30, 2011 brewmanNH, OF course, my conjecture was only that the form was vaguely reminiscent of ternary ops..@m23,I still don't find that just because it's easier to cut your head off with a chainsaw than an axe that a chainsaw isn't a viable tool. Yes it can turn the situation ugly much faster than an axe, but that's all up to the user. You can't save people from stupid.my new mantrakylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
jaberwacky Posted December 30, 2011 Share Posted December 30, 2011 (edited) $a = $b = $C isn't any different than doing something like If $B = $C Then <do something>. It's evaluating whether or not $B equals $C and if it does (True), do something. The initial value of $a is overwritten by the boolean comparison result. I think BrewManNH is right because:Global $Success = '' Global $Test = 123 $Success = $Test = 123 ConsoleWrite("$Success: " & $Success & @CRLF & "$Test: " & $Test & @CRLF) I still think of AutoIt in terms of a low-level language. Edited December 30, 2011 by LaCastiglione Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Dana Posted December 30, 2011 Share Posted December 30, 2011 Of course if you really want one line you could make it less ambiguous by using $a = ($b = $c), no?I sometimes use redundant parentheses to make things more clear (or more ovbious).Now this may be a stupid question, but how does AutoIt know that $a = $b = $c means "assign to $a the result of the comparision $b=$c", rather than "set $a equal to $b, and then compare to $c (since per the helpfile when two operators have the same precedence the expression is evaluated left to right.)? It looks like an equal sign that's the first operator on any line is assumed to be assignment, whereas any other use of equal is assumed to be comparison? 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