Administrators Jon Posted August 27, 2014 Author Administrators Share Posted August 27, 2014 Jon, why is this error:$a = 1 A($a + 5) Func A(ByRef $x) EndFunc I'll check. I rewrote a lot of that code Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 27, 2014 Moderators Share Posted August 27, 2014 Hi,Pardon my ignorance, but can someone please explain why passing such a parameter ByRef should not be an error? Surely the main purpose of passing a parameter ByRef is to allow the function to alter the value of the original - how can than happen when the parameter is a construct? 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...
JohnOne Posted August 27, 2014 Share Posted August 27, 2014 I thought the primary reason for ByRef was so a copy was not made. Rightly or wrongly, I would have thought that the param would be treated as const and only give an error if an attempted change of the value was made. 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...
Richard Robertson Posted August 27, 2014 Share Posted August 27, 2014 I thought the primary reason for ByRef was so a copy was not made. Rightly or wrongly, I would have thought that the param would be treated as const and only give an error if an attempted change of the value was made. Reference parameters pass the handle to the original object store (variable, property, another parameter, any L-Value, etc) so that changes made are stored to the original and no copy is made for complex objects. I don't know why trancexx would expect an R-Value to work. Link to comment Share on other sites More sharing options...
Administrators Jon Posted August 27, 2014 Author Administrators Share Posted August 27, 2014 There's no reason it couldn't just pass the value and throw away any modifications. Which is what the com code does with byref in some cases iirc. czardas 1 Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
DXRW4E Posted August 27, 2014 Share Posted August 27, 2014 (edited) Reference parameters pass the handle to the original object store (variable, property, another parameter, any L-Value, etc) so that changes made are stored to the original and no copy is made for complex objects.I don't know why trancexx would expect an R-Value to work.I'm not a pro of the C++ indeed I know little, but what do I know that is not Rvalue or Lvalue that is a temporary object (that must be destroyed when no longer needed), and a temporary object is const, all standart library have already func (with paramenter) in pointer and reference and const and non-const (Operator and Function Overloading, if not this does not work after (1 + (2 + 3)) or ("String1" + ("Sring2" + "String3")) etc etc), so is not wrong to send a temporary object as (const) byref Ciao. Edited August 27, 2014 by DXRW4E trancexx 1 Link to comment Share on other sites More sharing options...
JohnOne Posted August 27, 2014 Share Posted August 27, 2014 Don't forget kids, we;re talking about AutoIt here not C or C++. 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...
DXRW4E Posted August 27, 2014 Share Posted August 27, 2014 (edited) @OffTopicDon't forget kidsAre you kidding me???? you're kidding right ???? we;re talking about AutoIt here not C or C++.discussion is in general (see hereeeeeee ) and C++ is the best example that explains it Ciao. Edited August 27, 2014 by DXRW4E Link to comment Share on other sites More sharing options...
JohnOne Posted August 27, 2014 Share Posted August 27, 2014 No, I'm not kidding, were talking about what should or should not happen within an AutoIt script, not the internal C++ workings of the AutoIt interpreter. 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...
trancexx Posted August 27, 2014 Share Posted August 27, 2014 Reference parameters pass the handle to the original object store (variable, property, another parameter, any L-Value, etc) so that changes made are stored to the original and no copy is made for complex objects. I don't know why trancexx would expect an R-Value to work.Because since 6 years ago AutoIt allows rvalues passed as argument byref. It's documented behaviour.$a = 1 A(($a + 5)) ; notice extra parentheses Func A(ByRef $x) EndFunc...or if it would be more obvious:A(77) Func A(ByRef $x) EndFunc Besides, the example I showed earlier indeed produces unexpected behaviour, which can be seen if you look at some standard UDFs and their definitions. For example take function _WinAPI_StringLenA(). Param is Const Byref, That means I can't do this:$tStr = DllStructCreate("char[100]") $pStr = DllStructGetPtr($tStr) DllStructSetData($tStr, 1, "QWERTZ") $iLen = _WinAPI_StringLenA($pStr + 1) ; one character ahead ConsoleWrite($iLen & @CRLF)... That example must print 5 to console, and currently it can't even be run. The person who added "Const Byref" to function definition obviously didn't expect interpreter to error-out on something like that. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jpm Posted August 27, 2014 Share Posted August 27, 2014 I can agree Const Byref make sense but Just ByRef updating the value cannot be done so for me it is an error Link to comment Share on other sites More sharing options...
trancexx Posted August 27, 2014 Share Posted August 27, 2014 I can agree Const Byref make sense but Just ByRef updating the value cannot be done so for me it is an errorWho are you? Really, who are you?For your information developer Jpm added the feature to the language. Are you that Jpm or someone else? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
mLipok Posted September 7, 2014 Share Posted September 7, 2014 I've starting uploading the beta docs as well. Beta docs: https://www.autoitscript.com/autoit3/files/beta/autoit/docs/ Script breaking changes: https://www.autoitscript.com/autoit3/files/beta/autoit/docs/script_breaking_changes.htm I see there is now v3.3.13.20 (Beta) doc Is it mean that OnLine version of Beta Doc is updated much often / many more times then beta CHM version ? Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 7, 2014 Moderators Share Posted September 7, 2014 mLipok,No, as a Beta version is released the various files in the repository automatically update to the next version number. The files to which Jon has linked were pulled directly from the repository and so have that number. 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...
Inververs Posted September 13, 2014 Share Posted September 13, 2014 FileOpen with $FO_UTF16_LE or $FO_UTF16_BE or $FO_UTF8 Or $FO_UTF8_NOBOM return binary now? Is a bug or feature? #include 'FileConstants.au3' $h = FileOpen('test.txt', $FO_OVERWRITE + $FO_UTF8_NOBOM) FileWrite($h, 'ddddddddddddd') FileClose($h) test(0) test($FO_BINARY) test($FO_UTF16_LE) test($FO_UTF16_BE) test($FO_UTF8) test($FO_UTF8_NOBOM) test($FO_UTF8_FULL) Func test($FO) $h = FileOpen('test.txt', $FO_READ + $FO) $data = FileRead($h) FileClose($h) ConsoleWrite($data & @CRLF) EndFunc In console: ddddddddddddd 0x64646464646464646464646464 0x6464646464646464646464 0x6464646464646464646464 0x64646464646464646464 0x64646464646464646464646464 ddddddddddddd Link to comment Share on other sites More sharing options...
Iczer Posted September 21, 2014 Share Posted September 21, 2014 hmm... considering no one answered to previous post for over a week, it seems like global conspiracy Link to comment Share on other sites More sharing options...
JohnOne Posted September 21, 2014 Share Posted September 21, 2014 I'l go with bug, features are normally documented. 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...
jchd Posted September 21, 2014 Share Posted September 21, 2014 UTF8 w/o BOM is nothing but ANSI since the content is all below 0x80. $h = FileOpen('test.txt', $FO_OVERWRITE + $FO_UTF8_NOBOM) FileWrite($h, 'ddddddddddddd') FileClose($h) ; result from beta test(0) ; 0 ANSI, correct test($FO_BINARY) ; 16 correct test($FO_UTF16_LE) ; 32 questionable: no valid BOM found (eats first 2 bytes) test($FO_UTF16_BE) ; 64 questionable: no valid BOM found (eats first 2 bytes) test($FO_UTF8) ; 128 questionable: no valid BOM found (eats first 3 bytes) test($FO_UTF8_NOBOM) ; 256 wrong test($FO_UTF8_FULL) ; 16384 correct Func test($FO) $h = FileOpen('test.txt', $FO_READ + $FO) $data = FileRead($h) ConsoleWrite($FO & @TAB & '--> ' & $data & @CRLF) FileClose($h) EndFunc Beta returns: 0 --> ddddddddddddd 16 --> 0x64646464646464646464646464 32 --> 0x6464646464646464646464 64 --> 0x6464646464646464646464 128 --> 0x64646464646464646464 256 --> 0x64646464646464646464646464 16384 --> ddddddddddddd Release returns: 0 --> ddddddddddddd 16 --> 0x64646464646464646464646464 32 --> ?????? 64 --> ?????? 128 --> ddddddddddddd 256 --> ddddddddddddd 16384 --> ddddddddddddd which is correct in every case. The recent "fix" in read modes isn't correct. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
jaberwacky Posted September 22, 2014 Share Posted September 22, 2014 (edited) When I use With / EndWith in this function it works fine until I rearrange some cases. I can't make a reproducer because I have no idea how to in this case. ; Works fine Func controller_main_gui_messages(Const $this) Local Const $message = GUIGetMsg() With $this If Not .GUIMessages($message) Then Return False EndIf If Not .ActionMessages($message) Then Return False EndIf If Not .VersionsFileMenu($message) Then Return False EndIf If Not .MainTabActions($message) Then Return False EndIf EndWith Return True EndFunc ; doesn't work Func controller_main_gui_messages(Const $this) Local Const $message = GUIGetMsg() With $this If Not .MainTabActions($message) Then Return False EndIf If Not .GUIMessages($message) Then ; Error: (115) : Unknown name. Return False EndIf If Not .ActionMessages($message) Then Return False EndIf If Not .VersionsFileMenu($message) Then Return False EndIf EndWith Return True EndFunc The full code for this is SciTE Customization GUI in my signature. That code is kinda large but I don't think it's my code though. Anyways, I know you can't do anything without a reproducer. I thought I'd put this out there because I discovered that order seems to have a play in the issue. Well, kthxbye. Edited September 22, 2014 by jaberwacky 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...
RichardL Posted September 27, 2014 Share Posted September 27, 2014 In String.au3 the function _StringEncrypt has gone, but the name is still in the #CURRENT# ... ; _StringBetween ; _StringEncrypt ; _StringExplode ... 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