Kalin Posted September 28, 2010 Share 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 Link to comment Share on other sites More sharing options...
MattyD Posted September 28, 2010 Share 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 Link to comment Share on other sites More sharing options...
Kalin Posted September 28, 2010 Author Share 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. Link to comment Share on other sites More sharing options...
omikron48 Posted September 28, 2010 Share 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. Link to comment Share on other sites More sharing options...
Kalin Posted September 28, 2010 Author Share 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. Link to comment Share on other sites More sharing options...
water Posted September 28, 2010 Share 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
MattyD Posted September 28, 2010 Share 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 Link to comment Share on other sites More sharing options...
Kalin Posted September 28, 2010 Author Share 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! Link to comment Share on other sites More sharing options...
Kalin Posted September 28, 2010 Author Share 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. Link to comment Share on other sites More sharing options...
omikron48 Posted September 28, 2010 Share 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 Link to comment Share on other sites More sharing options...
Kalin Posted September 28, 2010 Author Share Posted September 28, 2010 You all are so awesome. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 28, 2010 Moderators Share 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 Link to comment Share on other sites More sharing options...
987learner Posted September 28, 2010 Share Posted September 28, 2010 -1 should be documented in the help file, really. So many meaning yet no info in help file Link to comment Share on other sites More sharing options...
trancexx Posted September 28, 2010 Share Posted September 28, 2010 -2 too. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
czardas Posted September 28, 2010 Share Posted September 28, 2010 (edited) Dim $ambiguity = -2 MsgBox(0, "???", $ambiguity & " = " & 4^.5) Edited September 28, 2010 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Kalin Posted October 11, 2010 Author Share Posted October 11, 2010 There are ALOT of things they need to include in the helpfile, hopefully they will be updating it soon. Link to comment Share on other sites More sharing options...
Kalin Posted October 11, 2010 Author Share Posted October 11, 2010 Dim $ambiguity = -2 MsgBox(0, "???", $ambiguity & " = " & 4^.5) lol wat... Link to comment Share on other sites More sharing options...
MvGulik Posted October 12, 2010 Share 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 ... Link to comment Share on other sites More sharing options...
Kalin Posted October 12, 2010 Author Share 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. Link to comment Share on other sites More sharing options...
MvGulik Posted October 12, 2010 Share 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 ... 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