Jump to content

Multi dimensional array to MsgBox


shornw
 Share

Recommended Posts

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]

Link to comment
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

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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
Link to comment
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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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]

Link to comment
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
 Share

  • Recently Browsing   0 members

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