Sign in to follow this  
Followers 0
mdwerne

A smarter way to write an array...

4 posts in this topic

So I am sequencially calling an array of MSI ID's to uninstall all versions of a program. As you can see from the array below, adding a new MSI ID to the array is starting to get long and tedious...

How might I re-write the array below using a regex or two so that I can specify the range of numbers between the start and end points? In other words, a regex that covers all the MSI numbers below...no more, no less.

If there is a forum page you can point me too that does something similar, I'd be more than happy to take a stab at it myself.

$MSIArray = StringSplit("{26A24AE4-039D-4CA4-87B4-2F86416019FB},{26A24AE4-039D-4CA4-87B4-2F86416020FB}," & _
"{26A24AE4-039D-4CA4-87B4-2F86416021FB},{26A24AE4-039D-4CA4-87B4-2F86416022FB},{26A24AE4-039D-4CA4-87B4-2F86416023FB}," & _
"{26A24AE4-039D-4CA4-87B4-2F86416024FB},{26A24AE4-039D-4CA4-87B4-2F86416025FB},{26A24AE4-039D-4CA4-87B4-2F86416026FB}," & _
"{26A24AE4-039D-4CA4-87B4-2F86416027FB},{26A24AE4-039D-4CA4-87B4-2F86416028FB},{26A24AE4-039D-4CA4-87B4-2F86416029FB}," & _
"{26A24AE4-039D-4CA4-87B4-2F86416030FB},{26A24AE4-039D-4CA4-87B4-2F86416031FB},{26A24AE4-039D-4CA4-87B4-2F86416032FB}," & _
"{26A24AE4-039D-4CA4-87B4-2F86416033FB},{26A24AE4-039D-4CA4-87B4-2F86416034FB},{26A24AE4-039D-4CA4-87B4-2F86416035FB}," & _
"{26A24AE4-039D-4CA4-87B4-2F86416036FB},{26A24AE4-039D-4CA4-87B4-2F86416037FB},{26A24AE4-039D-4CA4-87B4-2F86416038FB}," & _
"{26A24AE4-039D-4CA4-87B4-2F86416039FB},{26A24AE4-039D-4CA4-87B4-2F86416040FB},{26A24AE4-039D-4CA4-87B4-2F86416041FB}," & _
"{26A24AE4-039D-4CA4-87B4-2F86417000FB},{26A24AE4-039D-4CA4-87B4-2F86417001FB},{26A24AE4-039D-4CA4-87B4-2F86417002FB}," & _
"{26A24AE4-039D-4CA4-87B4-2F86417003FB},{26A24AE4-039D-4CA4-87B4-2F86417004FB},{26A24AE4-039D-4CA4-87B4-2F86417005FB}," & _
"{26A24AE4-039D-4CA4-87B4-2F86417006FB},{26A24AE4-039D-4CA4-87B4-2F86417007FB},{26A24AE4-039D-4CA4-87B4-2F86417008FB}", ",")

Thanks for any suggestions,

-Mike

Share this post


Link to post
Share on other sites



mdwerne,

Something like this should help: ;)

#include <Array.au3>

$iStart = 6019
$iEnd = 7008
$iRange = $iEnd - $iStart + 1

Global $aArray[$iRange]

For $i = 0 To $iRange - 1
    $aArray[$i] = "{26A24AE4-039D-4CA4-87B4-2F8641" & ($iStart + $i) & "FB}"
Next

_ArrayDisplay($aArray)

All clear? :)

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

mdwerne,

Something like this should help: ;)

#include <Array.au3>

$iStart = 6019
$iEnd = 7008
$iRange = $iEnd - $iStart + 1

Global $aArray[$iRange]

For $i = 0 To $iRange - 1
$aArray[$i] = "{26A24AE4-039D-4CA4-87B4-2F8641" & ($iStart + $i) & "FB}"
Next

_ArrayDisplay($aArray)

All clear? :)

M23

Perfectly clear, thank you!!

Share this post


Link to post
Share on other sites

mdwerne,

My pleasure as always. :)

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

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