Sign in to follow this  
Followers 0
ancp

Array initialization

3 posts in this topic

I apologize for propably asking a old question once more - I could not find... Is possible to fast initialize array, like:

Dim $aItems[600] = 0xC1

instead of

Dim $aItems[600]
for $i = 0 to ubound($aItems) - 1
    $aItems[$i]  = 0xC1
next

And one subquestion. Are math and bitwise operations with hexadecimal values faster than decimal values?

$var = BitOR($aItem[$i], BitAND($var, 0x1F), 1))

vs

$var = BitOR($aItem[$i], BitAND($var, 31), 1))

Thanks in advance

Share this post


Link to post
Share on other sites



ancp,

1. No. You either use a loop or you have to do this:

Dim $aItems[600] = [0xC1, 0xC1, 0xC1, ...another 596 elements..., 0xC1]

which is MUCH longer! ;)

By the way, try not to use Dim. It is better practice to specifically scope your variables with Global/Local instead. :blink:

2. Given the relative slowness of AutoIt, I cannot believe it makes any difference which you use unless you have a seriously large number of such lines in your script - but I am quite prepared to be proved wrong! :P

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Thanks Melba, I understand.

2. Given the relative slowness of AutoIt, I cannot believe it makes any difference which you use unless you have a seriously large number of such lines in your script - but I am quite prepared to be proved wrong! ;)

Not much of a big numbers, but many of bitwise operations. I understand that AutoIt is not very fast but it's very comfortable :blink:

thank you for the reply.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0