Jump to content

Recommended Posts

  • Moderators
Posted

This seems to come up pretty regularly. Would it be worth a line in the Help file - "Always enclose the expression in () when using NOT - If NOT($iFred < 9)"?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • Replies 41
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted

No, I would argue that you should always write the expression correctly to begin with. If Not ($iFred < 9) is really If $iFred >= 9 which is about 703 times clearer to the reader.

  • Moderators
Posted

I am just glad Richard came up with the question first!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

If've got a question whether this ... If Not $iDimension > 0 Then ...is really good code?

Personally, I've always treated NOT as a function in whatever language I've used, so I would instinctively write that as If Not( $iDimension > 0 ) Then... and so would not have written it this way. So, I agree that it is not really good. That's NOT(really) good, rather than NOT(really good), just to be clear.
Posted (edited)

Is it faster to pass large arrays by reference rather than by value?

Did you not read the ByRef documentation? (hint: the answers to both questions are the same :mellow:.)

$mArray = [ONE MILLION ITEMS!]

DoSomethingDumb($mArray)
DoSomethingSmart($mArray)

Func DoSomethingDumb($aArray)
ConsoleWrite($aArray[999123])
EndFunc

Func DoSomethingSmart(ByRef $aArray)
ConsoleWrite($aArray[999123])
EndFunc

One copies the entire array to the local $aArray. The other just uses a reference to the existing array. It's much faster and uses less memory.

Edited by JRowe
Posted (edited)

Common guys, this shouldn't be a discussion thread for all that stuff. :mellow:

Three topics are handled here:

1) Not... is that good code? Answered : Yes, I think so.

2) _ArrayUnique performance! Answered : Not completely. FMPOV, there should be a rewrite for better performance in case

a ) to strip down huge arrays

b )dealing with already stripped arrays

3) ByRef or ByValue! Answered : Yes, I think so.

Thanks!

Mega

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Posted

Did you not read the ByRef documentation?

Well, my answer was mostly rhetorical - Richard asked why the OP was passing an array by reference, I would have thought that the default behaviour should be to always pass arrays by reference unless the function always needs to modify a temporary copy of the array.
Posted

One copies the entire array to the local $aArray. The other just uses a reference to the existing array. It's much faster and uses less memory.

Kind of anyway :mellow: You'll find that AutoIt uses copy-on-write optimization for arrays, so that unless the array is modified in the the function, the array never actually gets copied. In that case, the performance difference between ByRef and non-ByRef array parameter passing is absolutely negligible. There probably is still a tiny bit of overhead for not passing ByRef to functions that perform read-only operations on the array, but we're talking microseconds/milliseconds even over many iterations.

[ WinINet.au3 | Array.au3 (Optimized) | _UnixTimeParse() ]

Posted

Man, just when I think I know something about anything. So an array isn't copied, even if it's not passed ByRef, unless it's manipulated inside a function?

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...