Kalin 0 Posted September 28, 2010 In au3, what does the -1 number mean. It's a number so frequently used in autoit. Can anyone share with me what it is, what it's used for? < purposes Share this post Link to post Share on other sites
MattyD 22 Posted September 28, 2010 usually its used to represent a default value. inside the fuction there will be an if statement say: If $param = -1 Then $Param = $SomeConstant Share this post Link to post Share on other sites
Kalin 0 Posted September 28, 2010 usually its used to represent a default value. inside the fuction there will be an if statement say:If $param = -1 Then $Param = $SomeConstantCan you give more detail please?Thank you for helping in all, but the value -1 isn't really explained at all in the helpfile.So I'll need full detail please. Share this post Link to post Share on other sites
omikron48 0 Posted September 28, 2010 It depends on the context, what -1 may mean. As a condition parameter, it may mean the number value negative one or just a non-zero value to mean True. As a Step parameter in a For...Next loop, it means that the loop goes in a decreasing increment of one. As an @error or @extended value, it may mean whatever the function designer wants it to indicate. Share this post Link to post Share on other sites
Kalin 0 Posted September 28, 2010 It depends on the context, what -1 may mean.As a condition parameter, it may mean the number value negative one or just a non-zero value to mean True.As a Step parameter in a For...Next loop, it means that the loop goes in a decreasing increment of one.As an @error or @extended value, it may mean whatever the function designer wants it to indicate.Finally! Someone gave me a answer without thinking I'm trying to be offensive, thank you good sir. Share this post Link to post Share on other sites
water 2,384 Posted September 28, 2010 (edited) As an example please see the help file for GUICreate. -1 means "center" if specified for the "left" or "top" parameter for this function. -1 might mean something completely different for another function. Edited September 28, 2010 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
MattyD 22 Posted September 28, 2010 (edited) Ok so lets take say, GUICtrlCreateEdit GUICtrlCreateEdit ( "text", left, top [, width [, height [, style [, exStyle]]]] ) The default style is: BitOR($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL) Lets say I want to keep the default style but set a different parameter for exstyle. I can write this: GUICtrlCreateEdit("text", 0, 0, 200, 200, BitOR($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL), $WS_EX_CLIENTEDGE) Or I can write this: GUICtrlCreateEdit("text", 0, 0, 200, 200, -1, $WS_EX_CLIENTEDGE) -1 is not a magic number in autoit. It will only work on functions that specifically are coded to interpret it as a default value. If i wanted my function to interpret "pink elephant" as a default value i could but -1 is probably better . Edit: Woah lots of posts were made in the mean timeFinally! Someone gave me a answer without thinking I'm trying to be offensive, thank you good sir.Didn't think that way at all... sorry if thats what it sounded like. Edited September 28, 2010 by MattyD Share this post Link to post Share on other sites
Kalin 0 Posted September 28, 2010 As an example please see the help file for GUICreate. -1 means "center" if specified for the "left" or "top" parameter for this function. -1 might mean something completely different for another function.Awww, I'm this is going to be a hard little code to learn.So many variations. @_@Thanks guise! Share this post Link to post Share on other sites
Kalin 0 Posted September 28, 2010 Ok so lets take say, GUICtrlCreateEdit GUICtrlCreateEdit ( "text", left, top [, width [, height [, style [, exStyle]]]] ) The default style is: BitOR($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL) Lets say I want to keep the default style but set a different parameter for exstyle. I can write this: GUICtrlCreateEdit("text", 0, 0, 200, 200, BitOR($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL), $WS_EX_CLIENTEDGE) Or I can write this: GUICtrlCreateEdit("text", 0, 0, 200, 200, -1, $WS_EX_CLIENTEDGE) -1 is not a magic number in autoit. It will only work on functions that specifically are coded to interpret it as a default value. If i wanted my function to interpret "pink elephant" as a default value i could but -1 is probably better . Thank you, this should be enough for now that I can look into. If I need any more help with this subject I will be sure to bump this thread. Share this post Link to post Share on other sites
omikron48 0 Posted September 28, 2010 (edited) I also use -1 as a default parameter for some of my functions that also take values 0 to positive infinity. In that particular case, -1 is easier to account for than just any random negative number. Kinda like a search function that I coded, one of the parameters I use is the search depth or how many folders deep should the search function run. I used 0 to indicate only within the starting folder, any positive number to indicate how many folders deep in particular, then -1 to indicate that the search should go until whatever the deepest folder level is. Edited September 28, 2010 by omikron48 Share this post Link to post Share on other sites
Kalin 0 Posted September 28, 2010 You all are so awesome. Share this post Link to post Share on other sites
Melba23 3,452 Posted September 28, 2010 Kalin,There is another use for -1 when you are addressing controls. If you use -1 in place of the ControlID, it means "use the last created control":#include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hLabel_First = GUICtrlCreateLabel("", 10, 10, 100, 20) GUICtrlSetData(-1, "First") ; <<<<<<<<<<<<<<<<<< $hLabel_Second = GUICtrlCreateLabel("", 10, 50, 100, 20) GUICtrlSetData(-1, "Second") ; <<<<<<<<<<<<<<<<<< GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndSaves a lot of wear and tear on the typing fingers if you use long variable names! 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 Share this post Link to post Share on other sites
987learner 0 Posted September 28, 2010 -1 should be documented in the help file, really. So many meaning yet no info in help file Share this post Link to post Share on other sites
trancexx 1,013 Posted September 28, 2010 -2 too. ♡♡♡ . eMyvnE Share this post Link to post Share on other sites
czardas 1,269 Posted September 28, 2010 (edited) Dim $ambiguity = -2 MsgBox(0, "???", $ambiguity & " = " & 4^.5) Edited September 28, 2010 by czardas operator64 ArrayWorkshop Share this post Link to post Share on other sites
Kalin 0 Posted October 11, 2010 There are ALOT of things they need to include in the helpfile, hopefully they will be updating it soon. Share this post Link to post Share on other sites
Kalin 0 Posted October 11, 2010 Dim $ambiguity = -2 MsgBox(0, "???", $ambiguity & " = " & 4^.5) lol wat... Share this post Link to post Share on other sites
MvGulik 86 Posted October 12, 2010 There are ALOT of things they need to include in the helpfile, hopefully they will be updating it soon.Assuming with "They" you mean the volunteers that mainly keep updating/upgrading AutoIt.Your free in trying to do some preliminary work in the ALOT area if you like. "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)"Believing what you know ain't so" ...Knock Knock ... Share this post Link to post Share on other sites
Kalin 0 Posted October 12, 2010 Assuming with "They" you mean the volunteers that mainly keep updating/upgrading AutoIt.Your free in trying to do some preliminary work in the ALOT area if you like.Did I say that I didn't mean "They" so you foreclaim?God, seriously people, stop trying.And sounds good to me. I can help. Share this post Link to post Share on other sites
MvGulik 86 Posted October 12, 2010 And sounds good to me. I can help.Great. Just hope you know what a valik is. "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)"Believing what you know ain't so" ...Knock Knock ... Share this post Link to post Share on other sites