Jump to content
Sign in to follow this  
ken82m

Problem Parsing Large String [Solved]

Recommended Posts

ken82m

Okay here's something I've thought about but never done. And now I have a need to do it lol

I have three array's:

1st contains titles

2nd contains urls

3rd contains bitrates associated with the urls

So $array3[2] is the bitrate for the url in $array[2]2

My problem is the string could have contained one title or many titles. And each title has 3 or 4 url's associated with it.

Here's an example:

Array1      Array2       Array3
2              6              6
Title1   testurl.com       500
Title2   testurl.com      1600
           testurl.com    2200
           testurl.com    500
           testurl.com    1600
           testurl.com    2200

Question:

The problem is I don't know how to associate the titles with the urls in this format.

I do know how to get seperate arrays for each title.

But if I was in say a DO loop how would I generate and manage array names on the fly.

If there were 2 titles I would need the commands to use $array1/$array2/$array3 the first time,

and then $array4/$array5/$array6 the first time, etc.

Thanks,

Kenny

Edited by ken82m

My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Share this post


Link to post
Share on other sites
ken82m

Okay new question above lol


My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Share this post


Link to post
Share on other sites
BrettF

Maybe its better to show how you are getting the titles/urls?

It may then be easier to create a 2D array like so:

$arrary[0][0] = Number of Titles/URLS etc.

$arrary[1][0] = Title

$arrary[1][1] = Bit Rate

$arrary[1][2] = Number of URLS

$arrary[1][3] = URL 1

$arrary[1][x] = URL x

$arrary[n][0] = Title

$arrary[n][1] = Bit Rate

$arrary[n][2] = Number of URLS

$arrary[n][3] = URL 1

$arrary[n][x] = URL x

.....

Share this post


Link to post
Share on other sites
ken82m

Thanks Brett, I just didn't want to scare anyone with that lol

So I setup the code below to give you the exact same data and tables I'm working with.

EDIT:

Finally got it lol

I've got a new table $Count it stores the number of URL's associated with each Title.

I've gotten all the data on a 9x3 table.

I've setup the code below to give you the exact same data and tables I'm working with.

I hadn't bothered using the FOR command before this script,

really getting the hang of it and liking it :mellow:

Thanks,

Kenny

#include <array.au3>

Global $Title[3], $Bitrates[9], $Urls[9], $Count[3], $CompleteTable[9][3]

;Populate Tables
SetValues()

$CompleteTable[0][0] = $URLs[0]
$CompleteTable[0][1] = $URLs[0]
$CompleteTable[0][2] = $URLs[0]

;Write URL's to Completed Table
For $i = 1 To $CompleteTable[0][1]
$CompleteTable[$i][2] = $URLs[$i]
Next

;Write Bitrates to Completed Table
For $i = 1 To $CompleteTable[0][2]
$CompleteTable[$i][1] = $Bitrates[$i]
Next

;Write Titles to Completed Table
For $L = 1 to $Count[0]
$a = 0
If $L > 1 Then $a = _ArraySearch($CompleteTable, "", 0, 0, 0) - 1
For $i = $a + 1 To $Count[$L] + $a
  $CompleteTable[$i][0] = $Title[$L]
Next
Next

;Display all tables
;_ArrayDisplay($Title, "$Title")
;_ArrayDisplay($Bitrates, "$Bitrates")
;_ArrayDisplay($URLs, "$URLs")
;_ArrayDisplay($Count, "$Count")
_ArrayDisplay($CompleteTable, "$CompleteTable")


Func SetValues()
;Count of URL's per title
$Count[0] = 2
$Count[1] = 4
$Count[2] = 4
;Title Names
$Title[0] = 2
$Title[1] = "Title1"
$Title[2] = "Title2"
;Bitrates for Each URL
$Bitrates[0] = 8
$Bitrates[1] = "500"
$Bitrates[2] = "800"
$Bitrates[3] = "1200"
$Bitrates[4] = "1600"
$Bitrates[5] = "500"
$Bitrates[6] = "800"
$Bitrates[7] = "1200"
$Bitrates[8] = "1600"
;URL's
$Urls[0] = 8
$Urls[1] = "TestURL1.com"
$Urls[2] = "TestURL2.com"
$Urls[3] = "TestURL3.com"
$Urls[4] = "TestURL4.com"
$Urls[5] = "TestURL5.com"
$Urls[6] = "TestURL6.com"
$Urls[7] = "TestURL7.com"
$Urls[8] = "TestURL8.com"
EndFunc
Edited by ken82m

My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

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  

×