Sign in to follow this  
Followers 0
shornw

Multi dimensional array to MsgBox

8 posts in this topic

I have searched the forum, but I can't find anything regarding what I want to achieve. I have an AD query which outputs to a multidimensional array and I want to present the results in a MsgBox, without the identifiers.

_ArrayToClip() and _ArrayToString() will only work with a 1 dimensional array, and I don't really want to write the output to file.

I'm probably missing something really simple (apologies if it's something silly). Any ideas gratefully received.


[font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]

Share this post


Link to post
Share on other sites



You can use _arraydisplay() to view the array or you can use a For loop to pull just the index that you want to display via msgbox


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Czardas - it's a 2 dimensional array

nitekram - _ArrayDisplay displays all the array identifiers, which I don't want and a loop will only list the items one at a time.

The output of a _AD_GetProperties() query, for example, can output over 40 rows and two columns, which I want to present in a clean and easy-on-the eye display.

Thanks for the replies

Edited by shornw

[font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

When going through the loop of the array elements, then you would use something like

$oldval = $oldval & $newval

you would be combining all the array elements into a single variable you could then use in a msgbox

MsgBox(0,"",$oldval)

*edit*

spelling

Edited by kaotkbliss

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You can concatenate the elements in each row and use whatever delimiter you like. For example TAB.

Dim $array[3][3] = [[10,54,73],[87,23,1],[5,64,71]]

Dim $ret
For $i = 0 To 2
    For $j = 0 To 2
        $ret &= $array[$i][$j] & @TAB
    Next
    $ret &= @LF
Next

MsgBox(0, "2D display", $ret)

I would personally not use a message box. Instead I would use a list view control, but that's just about the same as using _ArrayDisplay

Edited by czardas

Share this post


Link to post
Share on other sites

The output of a _AD_GetProperties() query, for example, can output over 40 rows and two columns, which I want to present in a clean and easy-on-the eye display.

If by "clean and easy-on-the eyes" you mean to remove some of the lines you could pass the properties you want to get returned to _AD_GetObjectproperties.

Example:

_AD_GetObjectProperties(@UserName, "samaccountname")
only returns one of the 40 properties.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks for all suggestions.

In the end, as I needed something quick, I went with concatenating the two dimensions and writing the result to a single dimension array, copying that to clip and writing into MsgBox(). It's not as pretty as I would have liked, but it will do for now.

I intend to create a much better alternative, where users can select the results they require.

This is the function that did the work. Feel free to pick holes/suggest improvements etc.

Func ADquery()
Dim $test
Dim $out[1]
_ArrayAdd($out, GUICtrlRead($name))
GUIDelete("AD Query")
For $i = 1 to UBound($aProperties) -1
$test &= $aProperties[$i][0] & " = " & $aProperties[$i][1]
_ArrayAdd($out, $test)
$test = ""
Next
_ArrayToClip($out, 2)
MsgBox(0, " Properties of " & $out[1], ClipGet())
_AD_Close()
Exit

EndFunc

[font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]

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