Sign in to follow this  
Followers 0
gcue

determine columns missing in array

15 posts in this topic

#1 ·  Posted (edited)

hello.

i am trying to identify which columns are missing in an array:

example array (missing columns are 2, 3, and 5):

$TS_RIM_Templates[0][0] = "7"

$TS_RIM_Templates[0][1] = "Agent Maintenance"

$TS_RIM_Templates[0][4] = "Resolved"

$TS_RIM_Templates[0][6] = "NO"

$TS_RIM_Templates[1][0] = "1000000163"

$TS_RIM_Templates[1][1] = "Agent Maintenance"

$TS_RIM_Templates[1][4] = "4000\4-Minor/Localized"

$TS_RIM_Templates[1][6] = "NO"

$TS_RIM_Templates[2][0] = "1000000162"

$TS_RIM_Templates[2][1] = "Agent Maintenance"

$TS_RIM_Templates[2][4] = "4000\4-Low"

$TS_RIM_Templates[2][6] = "NO"

$TS_RIM_Templates[3][0] = "1000000881"

$TS_RIM_Templates[3][1] = "Agent Maintenance"

$TS_RIM_Templates[3][4] = "No Further Action Required"

$TS_RIM_Templates[3][6] = "NO"

$TS_RIM_Templates[4][0] = "1000000164"

$TS_RIM_Templates[4][1] = "Agent Maintenance"

$TS_RIM_Templates[4][4] = "Low"

$TS_RIM_Templates[4][6] = "NO"

$TS_RIM_Templates[5][0] = "1000000169"

$TS_RIM_Templates[5][1] = "Agent Maintenance"

$TS_RIM_Templates[5][4] = "0"

$TS_RIM_Templates[5][6] = "NO"

here's what i have so far:

$new_columns = the total number of columns there should be

$output_array = the example array above

$new_columns = "7"

    For $x = 0 To $new_columns - 1
        $iIndex = _ArraySearch($output_array, "][" & $x & "]", 0, 0, 0, 1)
        If @error Then
            MsgBox(0, "missing", $x)
        EndIf
    Next

so im able to determine which columns are missing but not at which record numbers in the array

thanks in advance.

Edited by gcue

Share this post


Link to post
Share on other sites



gcue,

When you declare the array, all elements are set to "" - so just see which ones still are: ;)

Global $TS_RIM_Templates[6][7]

$TS_RIM_Templates[0][0] = "7"
$TS_RIM_Templates[0][1] = "Agent Maintenance"
$TS_RIM_Templates[0][4] = "Resolved"
$TS_RIM_Templates[0][6] = "NO"

$sList = ""
For $i = 0 To 6
    If $TS_RIM_Templates[0][$i] = "" Then $sList &= $i & ", " ; Add empty elements
Next
$sList = StringTrimRight($sList, 2) ; Remove the final ", "

MsgBox(0, "Missing", $sList)

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

that works great - thanks Melba.

i am trying to figure out which rows exist though...

for instance, in the example above 0,1,2,3,4,5 exist.

Share this post


Link to post
Share on other sites

Now thats just not trying .....

Global $TS_RIM_Templates[6][7]

$TS_RIM_Templates[0][0] = "7"
$TS_RIM_Templates[0][1] = "Agent Maintenance"
$TS_RIM_Templates[0][4] = "Resolved"
$TS_RIM_Templates[0][6] = "NO"

$sList = ""
For $i = 0 To 6
    If Not $TS_RIM_Templates[0][$i] = "" Then $sList &= $i & ", " ; Add empty elements
Next
$sList = StringTrimRight($sList, 2) ; Remove the final ", "

MsgBox(0, "There", $sList)

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

thats not what i was looking for.. the array example you have only has 0

the example i show above has 0-5

maybe now you know what numbers im after =)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

my reverse of Melbas example returns 0, 1, 4, 6 -- ahh for all dimensions. maybe im reading bad...

Like this:

Global $TS_RIM_Templates[6][7]

$TS_RIM_Templates[0][0] = "7"
$TS_RIM_Templates[0][1] = "Agent Maintenance"
$TS_RIM_Templates[0][4] = "Resolved"
$TS_RIM_Templates[0][6] = "NO"

$TS_RIM_Templates[1][0] = "1000000163"
$TS_RIM_Templates[1][1] = "Agent Maintenance"
$TS_RIM_Templates[1][4] = "4000\4-Minor/Localized"
$TS_RIM_Templates[1][6] = "NO"

$TS_RIM_Templates[2][0] = "1000000162"
$TS_RIM_Templates[2][1] = "Agent Maintenance"
$TS_RIM_Templates[2][4] = "4000\4-Low"
$TS_RIM_Templates[2][6] = "NO"

$TS_RIM_Templates[3][0] = "1000000881"
$TS_RIM_Templates[3][1] = "Agent Maintenance"
$TS_RIM_Templates[3][4] = "No Further Action Required"
$TS_RIM_Templates[3][6] = "NO"

$TS_RIM_Templates[4][0] = "1000000164"
$TS_RIM_Templates[4][1] = "Agent Maintenance"
$TS_RIM_Templates[4][4] = "Low"
$TS_RIM_Templates[4][6] = "NO"

$TS_RIM_Templates[5][0] = "1000000169"
$TS_RIM_Templates[5][1] = "Agent Maintenance"
$TS_RIM_Templates[5][4] = "0"
$TS_RIM_Templates[5][6] = "NO"



$sList = ""
For $i = 0 To 6
For $k = 0 To 5
    If Not $TS_RIM_Templates[$k][$i] = "" Then $sList &= $TS_RIM_Templates[$k][$i] & ", " ; Add empty elements
Next
Next
$sList = StringTrimRight($sList, 2) ; Remove the final ", "



MsgBox(0, "There", $sList1)
Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

iamtheky,

Now thats just not trying .....

Thanks for the support. Nice to see others share my opinion of the OP's complete lack of initiative. :)

gcue,

As all the first dimension elements in your array only ever use the same columns in the second dimension, I thought my simple solution would suffice.

As you are obviously too lazy to amend the basic code which I posted for yourself, here is a version that does look at all the first dimension elements and also reverses the empty/full check. To prevent any further complaints from you, I have made it as generic as I can:

; Create and fill array to be checked
Global $TS_RIM_Templates[6][7]

$TS_RIM_Templates[0][0] = "7"
$TS_RIM_Templates[0][1] = "Agent Maintenance"
$TS_RIM_Templates[0][4] = "Resolved"
$TS_RIM_Templates[0][6] = "NO"

$TS_RIM_Templates[1][0] = "1000000163"
$TS_RIM_Templates[1][1] = "Agent Maintenance"
$TS_RIM_Templates[1][4] = "4000\4-Minor/Localized"
$TS_RIM_Templates[1][6] = "NO"

$TS_RIM_Templates[2][0] = "1000000162"
$TS_RIM_Templates[2][1] = "Agent Maintenance"
$TS_RIM_Templates[2][4] = "4000\4-Low"
$TS_RIM_Templates[2][6] = "NO"

$TS_RIM_Templates[3][0] = "1000000881"
$TS_RIM_Templates[3][1] = "Agent Maintenance"
$TS_RIM_Templates[3][4] = "No Further Action Required"
$TS_RIM_Templates[3][6] = "NO"

$TS_RIM_Templates[4][0] = "1000000164"
$TS_RIM_Templates[4][1] = "Agent Maintenance"
$TS_RIM_Templates[4][4] = "Low"
$TS_RIM_Templates[4][6] = "NO"

$TS_RIM_Templates[5][0] = "1000000169"
$TS_RIM_Templates[5][1] = "Agent Maintenance"
$TS_RIM_Templates[5][4] = "0"
$TS_RIM_Templates[5][6] = "NO"

; Create array to hold "column filled" data
Global $aColumns[UBound($TS_RIM_Templates, 2)]
; Run through the array and set the "filled" markers for each element 
For $j = 0 To UBound($TS_RIM_Templates) - 1
    For $i = 0 To UBound($TS_RIM_Templates, 2) - 1
        If $TS_RIM_Templates[$j][$i] <> "" Then $aColumns[$i] = 1
    Next
Next
; Now assemble the "filled" string
$sList = ""
For $i = 0 To UBound($aColumns) - 1
    If $aColumns[$i] = "" Then $sList &= $i & ", " ; Add empty elements
Next
$sList = StringTrimRight($sList, 2) ; Remove the final ", "
; And display the result to the ungrateful OP who does not deserve it!
MsgBox(0, "Missing", $sList & @CRLF & @CRLF & "Do it yourself next time!")

After such a display of ingratitude, you are on your own now! ;)

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

melba of course im thankful for your help!

i think both of you are misunderstanding me. let me try to explain again.

im looking for a unique numbering of the first part of the array (so in the example below X)

$array[x][y]

as you can see in my initial array example, the answer to it would be 0,1,2,3,4,5

the answer you are getting melba i was already getting in "what i have so far" =)

in a different way than you are getting it, using arraysearch - i do like your method better though

Share this post


Link to post
Share on other sites

gcue,

melba of course im thankful for your help!

OK, forgiven! ;)

im looking for a unique numbering of the first part of the array (so in the example below X)

$array[x][y]

as you can see in my initial array example, the answer to it would be 0,1,2,3,4,5

How does that differ from the return you get from UBound expanded into a series? ;)

I am now completely baffled as to what you are trying to do - please try to explain again as if to your beloved greatgrandmother who has never seen a computer in her life. :)

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

hahaha good analogy.

ok here's what im trying to do (hope this helps)..

i have a manually built array that i will continuously want to inject values into it, sometimes columns in the middle

original array sample:

$TS_RIM_Templates[0][0] = "7"

$TS_RIM_Templates[0][1] = "Agent Maintenance"

$TS_RIM_Templates[0][2] = "Resolved"

$TS_RIM_Templates[0][3] = "NO"

$TS_RIM_Templates[1][0] = "7121"

$TS_RIM_Templates[1][1] = "Agent Maintenance"

$TS_RIM_Templates[1][2] = "Complete"

$TS_RIM_Templates[1][3] = "YES"

i want to add new columns to the array, so instead of adding them manually, i programmatically arrange where i want the new column placements by renaming the columns around

after:

$TS_RIM_Templates[0][0] = "7"

$TS_RIM_Templates[0][1] = "Agent Maintenance"

$TS_RIM_Templates[0][4] = "Resolved"

$TS_RIM_Templates[0][6] = "NO"

$TS_RIM_Templates[1][0] = "7"

$TS_RIM_Templates[1][1] = "Agent Maintenance"

$TS_RIM_Templates[1][4] = "Resolved"

$TS_RIM_Templates[1][6] = "NO"

now as you can see i have some columns missing.. which i find doing the arraysearch i showed initially.

BUT i dont know where to insert them, so in the above example i would need to insert

$TS_RIM_Templates[0][2] = ""

$TS_RIM_Templates[0][3] = ""

$TS_RIM_Templates[0][5] = ""

$TS_RIM_Templates[1][2] = ""

$TS_RIM_Templates[1][3] = ""

$TS_RIM_Templates[1][5] = ""

so 0 and 1 are the numbers im looking for so i know where to inject the columns missing

hehe i dont think my grandma would understand that.. but hope you guys will! =)

thanks again for your help!!!

Share this post


Link to post
Share on other sites

Still baffled here.

Are you trying to copy the contents of column0, to column1. Overwriting the original values in column1 and emptying columns in column1 that might have had data, but that are empty in column0?

Share this post


Link to post
Share on other sites

gcue:

Is this what you want: ;)

#include <Array.au3>

; Create and fill array to be checked
Global $TS_RIM_Templates[6][7]

$TS_RIM_Templates[0][0] = "7"
$TS_RIM_Templates[0][1] = "Agent Maintenance"
$TS_RIM_Templates[0][4] = "Resolved"
$TS_RIM_Templates[0][6] = "NO"

$TS_RIM_Templates[1][0] = "1000000163"
$TS_RIM_Templates[1][1] = "Agent Maintenance"
$TS_RIM_Templates[1][4] = "4000\4-Minor/Localized"
$TS_RIM_Templates[1][6] = "NO"

$TS_RIM_Templates[2][0] = "1000000162"
$TS_RIM_Templates[2][1] = "Agent Maintenance"
$TS_RIM_Templates[2][4] = "4000\4-Low"
$TS_RIM_Templates[2][6] = "NO"

$TS_RIM_Templates[3][0] = "1000000881"
$TS_RIM_Templates[3][1] = "Agent Maintenance"
$TS_RIM_Templates[3][4] = "No Further Action Required"
$TS_RIM_Templates[3][6] = "NO"

$TS_RIM_Templates[4][0] = "1000000164"
$TS_RIM_Templates[4][1] = "Agent Maintenance"
$TS_RIM_Templates[4][4] = "Low"
$TS_RIM_Templates[4][6] = "NO"

$TS_RIM_Templates[5][0] = "1000000169"
$TS_RIM_Templates[5][1] = "Agent Maintenance"
$TS_RIM_Templates[5][4] = "0"
$TS_RIM_Templates[5][6] = "NO"

; Create array to hold "data missing" data
Global $aElements[UBound($TS_RIM_Templates)]
; Run through the array and set the "filled" markers for each element
For $j = 0 To UBound($TS_RIM_Templates) - 1
    For $i = 0 To UBound($TS_RIM_Templates, 2) - 1
        If $TS_RIM_Templates[$j][$i] = "" Then $aElements[$j] &= $i & ", "
    Next
    $aElements[$j] = StringTrimRight($aElements[$j], 2)
Next

; Assemble the result
$sText = ""
For $i = 1 To UBound($TS_RIM_Templates) - 1
    If $aElements[$i] <> "" Then $sText &= "Element " & $i & " is missing data in columns " & $aElements[$i] & @CRLF
Next

; And display the result
MsgBox(0, "Missing", $sText)

If not, I might retire baffled. :)

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

Just establish a max number of elements per properly configured entry, in this example 4.

Then adjust the if statement to ignore null entries above that threshold.

Please tell me this is getting warmer....

#include <array.au3>

Global $TS_RIM_Templates[6][7]

$TS_RIM_Templates[0][0] = "7"
$TS_RIM_Templates[0][1] = "Agent Maintenance"
$TS_RIM_Templates[0][2] = "Resolved"
$TS_RIM_Templates[0][3] = "NO"

$TS_RIM_Templates[1][0] = "1000000163"
$TS_RIM_Templates[1][1] = "Agent Maintenance"
$TS_RIM_Templates[1][4] = "4000\4-Minor/Localized"
$TS_RIM_Templates[1][6] = "NO"

$TS_RIM_Templates[2][0] = "1000000162"
$TS_RIM_Templates[2][1] = "Agent Maintenance"
$TS_RIM_Templates[2][2] = "4000\4-Low"
$TS_RIM_Templates[2][3] = "NO"

$TS_RIM_Templates[3][0] = "1000000881"
$TS_RIM_Templates[3][1] = "Agent Maintenance"
$TS_RIM_Templates[3][4] = "No Further Action Required"
$TS_RIM_Templates[3][6] = "NO"

$TS_RIM_Templates[4][0] = "1000000164"
$TS_RIM_Templates[4][1] = "Agent Maintenance"
$TS_RIM_Templates[4][2] = "Low"
$TS_RIM_Templates[4][3] = "NO"

$TS_RIM_Templates[5][0] = "1000000169"
$TS_RIM_Templates[5][1] = "Agent Maintenance"
$TS_RIM_Templates[5][4] = "0"
$TS_RIM_Templates[5][6] = "NO"





$sList = ""
For $i = 0 To 6
For $k = 0 To 5
    If $TS_RIM_Templates[$k][$i] = "" And $i < 3 Then $sList &= $k &  ", " ; Add empty elements
Next
Next

$sList = StringTrimRight($sList, 2) ; Remove the final ", "

msgbox (0, '', $sList)

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

melba that's exaccctly what i was looking for!!!!

except i changed this

For $i = 1 To UBound($TS_RIM_Templates) - 1

to

For $i = 0 To UBound($TS_RIM_Templates) - 1

;)

sorry about all the confusion fellas. was a bit hard to explain i guess

many many many thanks!!!!!

Share this post


Link to post
Share on other sites

gcue,

I am delighted it was what you wanted - you need to brush up on your "describing" skills a bit though! ;)

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