Jump to content

String search


Valnurat
 Share

Recommended Posts

How can I go though a one dimention array that contains "|" as separator?

 

Like this:
Blue | Red | Green

Blue | Yellow

Blue | Black | Orange | Brown

But the separator is not constant. It could be zero or it could 4, 5, 6 maybe 7

I need to add this in excel sheet like a treeview

Blue

     Red

          Green

     Yellow

     Black

          Orange

               Brown

 

Yours sincerely

Kenneth.

Link to comment
Share on other sites

If you add _ArrayDisplay after line 

ReDim $aTreeView[$iIndexTV + 1][3]

in function _AD_GetOUTreeView you will see that in the first column you have a number of trailing spaces before the character "#".

Grab this array and write it to Excel (untested):

Global $aExcelData[$aTreeView[0][0] - 1][99]
For $i = 1 to $aTreeView[0][0]
    $iPos = StringInStr($aTreeView[$i][0], "#")
    $aExcelData[$i - 1][$iPos - 1] = $aTreeView[$i][0]
Next
_Excel_RangeWrite($oWorkbook, Default, $aExcelData)


 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

Is it already an array or just a string with delimeters?

If just a string, then create an array by using StringSplit.

With an array, you can then loop through it's parts.

Global $a, $array, $string, $value

$string = "Blue | Black | Orange | Brown"
$array = StringSplit($string, " | ", 1)
For $a = 1 To $array[0]
    $value = $array[$a]
    MsgBox(0, "Value", $value)
Next
Exit

 

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

TheSaint, ViciousXUSMC,

It's not that easy. He needs a treeview like structure. A posted a solution above.
And - as soon as I find some spare time - will add an Excel export function to the _AD_GetOUTreeView example script.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

TheSaint, ViciousXUSMC,

It's not that easy. He needs a treeview like structure. A posted a solution above.
And - as soon as I find some spare time - will add an Excel export function to the _AD_GetOUTreeView example script.

We all posted so close together, that I never saw your post.

My reply was just to get him started, and get more info and some code.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

There is no space in the line and the scoure I got from using:

$aGroupMember = _AD_RecursiveGetGroupMembers($aGroup[$i])

Sorry, my post was a bit misleading. I mean you could grab array $aTreeView in function _AD_GetOUTreeView.
But if you could wait 1 or 2 days I'm sure I can come up with a function to let you export the treeview returned by _AD_GetOUTreeView to Excel.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

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...