FaridAgl Posted January 6, 2012 Share Posted January 6, 2012 You know, in AutoIt we don't need to declare datatype, BTW we have something like Number(), Int(), Hex(), String() etc that are useful in some cases,I was thinking about Bool() as well.Why? Let me explain.I have a GUI (It's just an example), it has some CheckBoxes on it, i want to save each CheckBox's values on Exit:If Checked Then IniWrite(1) Else IniWrite(0)And then read it on Start:If IniRead() = 1 Then Checked Else UncheckedIt's OK right?But if we have a Bool() command we can do it like this:IniWrite(Bool(CheckBox))And on Start:same as previus.I know in AutoIt 0 = False and any other numbers are True.Maybe it doesn't make any sense in this example, but i'm sure there are so many better usage for it.I'm wondering why there isn't a Bool() command while we have Int(), Number() etc.It's simple to make a User-Function for it, in fact i'm doing it for myself, but i just want to know do you thing it can be a good option for AutoIt or not? http://faridaghili.ir Link to comment Share on other sites More sharing options...
jaberwacky Posted January 6, 2012 Share Posted January 6, 2012 (edited) Something like this?:Func Bool(Const $var) If $var = 0 Then Return 0 Return 1 EndFunc Maybe even:Func Bool(Const ByRef $checkbox) If GUICtrlRead($checkbox) = $GUI_CHECKED Then Return 1 ElseIf GUICtrlRead($checkbox) = $GUI_UNCHECKED Return 0 EndIf EndFunc #include <GuiConstantSex.au3> GUICreate ('', 100, 100, 500, 500) Global Const $cb = GUICtrlCreateCheckbox("Click Me", 10, 10) Global Const $display = GUICtrlCreateLabel ('', 10, 40, 10, 20) GUISetState(@SW_SHOWNORMAL) display_state(Bool($cb)) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cb display_state(Bool($cb)) EndSwitch WEnd Func Bool(Const ByRef $checkbox) If GUICtrlRead($checkbox) = $GUI_CHECKED Then Return 1 ElseIf GUICtrlRead($checkbox) = $GUI_UNCHECKED Then Return 0 EndIf EndFunc Func display_state(Const $state) GUICtrlSetData($display, $state) EndFunc Edited January 6, 2012 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...
JohnOne Posted January 6, 2012 Share Posted January 6, 2012 I'm sure you meant this. If Return True ElseIf Return False AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jaberwacky Posted January 6, 2012 Share Posted January 6, 2012 Well, I was thinking he wanted an integer to write to an ini file. 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...
JohnOne Posted January 6, 2012 Share Posted January 6, 2012 You are probably right about that. But the question is, is this a good suggestion for a native Autoit function? For me it is not, since it's trivial to make it yourself. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
FaridAgl Posted January 6, 2012 Author Share Posted January 6, 2012 Well, thanks. I coded something like that. I noticed that AutoIt counts strings as True, is it OK? $var = "blah blah blah" If $var Then MsgBox(0, '', '') And it shows the MsgBox. http://faridaghili.ir Link to comment Share on other sites More sharing options...
FaridAgl Posted January 6, 2012 Author Share Posted January 6, 2012 (edited) You are probably right about that.But the question is, is this a good suggestion for a native Autoit function?For me it is not, since it's trivial to make it yourself.There are so many good Functions in AutoIt that we can code them ourselves, what about removing all of them from AutoIt? Edited January 6, 2012 by D4RKON3 http://faridaghili.ir Link to comment Share on other sites More sharing options...
jaberwacky Posted January 6, 2012 Share Posted January 6, 2012 I think it evaluates the ascii number of the strings or something and so like you said anything other than zero is True. 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...
JohnOne Posted January 6, 2012 Share Posted January 6, 2012 Or an empty string $var = "" If $var Then MsgBox(0,0,0) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted January 6, 2012 Share Posted January 6, 2012 There are so many good Functions in AutoIt that we can code them ourselves, what about removing all of them from AutoIt?It's a question if nothing elsemy answer is no.If they did, what do you think autoit would be? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 6, 2012 Moderators Share Posted January 6, 2012 Hi all,AutoIt uses the following conventions for true/false:Numbers: 0 = False, everything else = TrueStrings: "" = False, any string with content = TrueBoolean: Well you can guess that! Basically you must be careful with strings (which are returned by several AutoIt functions) as a literal string "0" will be regarded as True. If you want store a Boolean in a file as 0/1, you need to use Number on it when you read it back to make sure you get the correct interpretation. 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...
FaridAgl Posted January 6, 2012 Author Share Posted January 6, 2012 Thanks Malba,The information you gave us is enough for me to understand how AutoIt handles Boolean.I'm going to play with that.End of Thread of me. http://faridaghili.ir Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 6, 2012 Moderators Share Posted January 6, 2012 D4RKON3,I thought I posted a reply - who is this Malba guy? Just kidding - glad I could help. 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...
FaridAgl Posted January 6, 2012 Author Share Posted January 6, 2012 Oh sorry, i meant Melba, Actually i'm searching for a good glasses, maybe i made another thread for it!!! Thanks again. http://faridaghili.ir Link to comment Share on other sites More sharing options...
ur Posted December 13, 2019 Share Posted December 13, 2019 How about passing the values as strings and checking their values. If StringCompare(StringStripWS(StringLower($CmdLine[2]), $STR_STRIPLEADING + $STR_STRIPTRAILING + $STR_STRIPSPACES ),"true")=0 then // Endif Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 13, 2019 Moderators Share Posted December 13, 2019 @ur You've been around long enough to know better than to resurrect old threads, especially after just shy of 8 years. I doubt the OP, who hasn't even been online for a year, is still trying to find the answer to this. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Recommended Posts