Sign in to follow this  
Followers 0
atnextc

Array Not Pulling Any Information

24 posts in this topic

I"m trying to create "1" array or more if needed to be able to pull very specific data from HTML page, while running in a loop to generate configuration commands for our team.  The problem that I am running into is....There are some portions of the configuration that will only need to be written 1 time no matter how many times the array is being looped for, while at other times I'll need all "6" instances of a particular variable written to a file one right after another.  

I believe that this is the correct way to create my array and gather the information but console write isn't displaying anything.  I"ve been reading all about _StringBetween and Arrays for about 3 weeks, and i've honestly gotten so much partial stuff working I've decided to start over.  The code below is the heart and soul of everything that I need to work off of though so if this doesn't work correctly everytime then there is no point in trying to work out the other stuff as well.

 

**Example of what i'm looking for at the end**

 

show bfd session summary
show log messages | last 300 

 

show interface extensive $asideinterface | no-more 
show interface diagnostics optics $asideinterface | match "Laser output power|Receiver signal average optical power"
 

show interface extensive $asideinterface | no-more 

show interface diagnostics optics $asideinterface | match "Laser output power|Receiver signal average optical power"

 

 

show interface extensive $asideinterface | no-more 

show interface diagnostics optics $asideinterface | match "Laser output power|Receiver signal average optical power"
 

 

****************************************************************************************************************************************************************

Below is my code.

As always any help is greatly appreciated

#include <IE.au3>
#include <string.au3>
#include <Array.au3>

$i = 0

Local $oIE = _IECreate("https://internal/mediawiki/index.php?title=C-ASHB/MRFD-01A-Q2-20135&action=edit", 0, 0, 1, 1)
_IELinkClickByText($oIE, "Continue to this website (not recommended).")
Local $imax = 26
Local $data = $oIE
Local $string = _IEBodyReadHTML($oIE)
_IEQuit($oIE)

Local $projectnextstep = _StringBetween($string, '|NextStep=', @CRLF)
Local $circuitID = _StringBetween($string, '|CircuitID=', @CRLF)
Local $asideengineer = _StringBetween($string, '|ASideAssignedEngineer=', @CRLF)
Local $zsideengineer = _StringBetween($string, '|ZSideAssignedEngineer=', @CRLF)
Local $asidenextstep = _StringBetween($string, '|ASideNextStep=', @CRLF)
Local $zsidenextstep = _StringBetween($string, '|ZSideNextStep=', @CRLF)
Local $asiderouter = _StringBetween($string, '|ALocation=', @CRLF)
Local $zsiderouter = _StringBetween($string, '|ZLocation=', @CRLF)
Local $asideinterface = _StringBetween($string, '|AInterface=', @CRLF)
Local $zsideinterface = _StringBetween($string, '|ZInterface=', @CRLF)
Local $asidetransport = _StringBetween($string, '|ATransportLocation=', @CRLF)
Local $zsidetransport = _StringBetween($string, '|ZTransportLocation=', @CRLF)
Local $asidefpc = _StringBetween($string, '|AFPC=', @CRLF)
Local $zsidefpc = _StringBetween($string, '|ZFPC=', @CRLF)
Local $asidepic = _StringBetween($string, '|APIC=', @CRLF)
Local $zsidepic = _StringBetween($string, '|ZPIC=', @CRLF)
Local $asideoptics = _StringBetween($string, '|AOptics=', @CRLF)
Local $zsideoptics = _StringBetween($string, '|ZOptics=', @CRLF)
Local $asidetam = _StringBetween($string, '|ATAM=', @CRLF)
Local $zsidetam = _StringBetween($string, '|ZTAM=', @CRLF)
Local $asidetom = _StringBetween($string, '|ATOM=', @CRLF)
Local $zsidetom = _StringBetween($string, '|ZTOM=', @CRLF)
Local $asidetestip = _StringBetween($string, '|ATestingIP=', @CRLF)
Local $zsidetestip = _StringBetween($string, '|ZTestingIP=', @CRLF)
Local $bypassname = _StringBetween($string, '|BypassName=', @CRLF)

 If IsArray($projectnextstep) Then
     For $i = 1 to $projectnextstep[0]
         ConsoleWrite($projectnextstep[$i] & @LF)
         Next
    For $i = 1 to $circuitID[0]
         ConsoleWrite($circuitID[$i] & @LF)
         Next
    For $i = 1 to $asideinterface[0]
         ConsoleWrite($asideinterface[$i] & @LF)
         Next
        For $i = 1 to $zsideinterface[0]
         ConsoleWrite($zsideinterface[$i] & @LF)
     Next
     $i=$i +1
 EndIf

Share this post


Link to post
Share on other sites



Yes but I'm trying to figure out why this isn't working. When I used @error it didn't provide any information

Share this post


Link to post
Share on other sites

So i've been working on this some more.  I was able to get the "array" to retrieve the data successfully.

The issue that I appear to be having is its looping until the array is "empty" and its throwing:

C:\Users\tcovert\Desktop\Autoit Forum Examples\Array-Ubound Testing.au3 (124) : ==> Subscript used with non-Array variable.:
ConsoleWrite($projectnextstep[0] & @LF)
ConsoleWrite($projectnextstep^ ERROR

Below is my code...  Any help is appreciated.

I guess my question is, am I using the array correctly or am I simply just using a "do/until" loop instead of using the array in the correct syntax?


Do

    If $I = 1 Then

        Local $aprojincr = StringRegExp(GUICtrlRead($ProjectNameInputBox), "(?<=-\d{2})([A-Z])(?=-Q)", 3)
        Local $Incr_char = Chr(Asc($aprojincr[0]) + 1)
        GUICtrlSetData($ProjectNameInputBox, StringRegExpReplace(GUICtrlRead($ProjectNameInputBox), _
                "(?<=-\d{2})([A-Z])(?=-Q)", $Incr_char))
    Else
        ;$I = $C Then
    EndIf
    Local $oIE = _IECreate("https://bbops.cox.net/mediawiki/index.php?title=" & GUICtrlRead($ProjectNameInputBox) & "&action=edit", 0, 0, 1, 0)
    _IELinkClickByText($oIE, "Continue to this website (not recommended).")
    Local $Imax = 26
    Local $data = $oIE
    Local $string = _IEBodyReadHTML($oIE)
    _IEQuit($oIE)

    Local $projectnextstep = _StringBetween($string, '|NextStep=', @CRLF);;;;;; WORKS AND IS IN A LOOP
    Local $circuitID = _StringBetween($string, '|CircuitID=', @CRLF);;;;;;;;;;;;;;;;;;;;;;;;;;;WORKS AND IS IN A LOO
    Local $asideengineer = _StringBetween($string, '|ASideAssignedEngineer=', @CRLF)
    Local $zsideengineer = _StringBetween($string, '|ZSideAssignedEngineer=', @CRLF)
    Local $asidenextstep = _StringBetween($string, '|ASideNextStep=', @CRLF)
    Local $zsidenextstep = _StringBetween($string, '|ZSideNextStep=', @CRLF)
    Local $asiderouter = _StringBetween($string, '|ALocation=', @CRLF)
    Local $zsiderouter = _StringBetween($string, '|ZLocation=', @CRLF)
    Local $asideinterface = _StringBetween($string, '|AInterface=', @CRLF)
    Local $zsideinterface = _StringBetween($string, '|ZInterface=', @CRLF)
    Local $asidetransport = _StringBetween($string, '|ATransportLocation=', @CRLF)
    Local $zsidetransport = _StringBetween($string, '|ZTransportLocation=', @CRLF)
    Local $asidefpc = _StringBetween($string, '|AFPC=', @CRLF)
    Local $zsidefpc = _StringBetween($string, '|ZFPC=', @CRLF)
    Local $asidepic = _StringBetween($string, '|APIC=', @CRLF)
    Local $zsidepic = _StringBetween($string, '|ZPIC=', @CRLF)
    Local $asideoptics = _StringBetween($string, '|AOptics=', @CRLF)
    Local $zsideoptics = _StringBetween($string, '|ZOptics=', @CRLF)
    Local $asidetam = _StringBetween($string, '|ATAM=', @CRLF)
    Local $zsidetam = _StringBetween($string, '|ZTAM=', @CRLF)
    Local $asidetom = _StringBetween($string, '|ATOM=', @CRLF)
    Local $zsidetom = _StringBetween($string, '|ZTOM=', @CRLF)
    Local $asidetestip = _StringBetween($string, '|ATestingIP=', @CRLF)
    Local $zsidetestip = _StringBetween($string, '|ZTestingIP=', @CRLF)
    Local $bypassname = _StringBetween($string, '|BypassName=', @CRLF)




    ConsoleWrite($projectnextstep[0] & @LF)


    ConsoleWrite($circuitID[0] & @LF)


    ConsoleWrite($asideinterface[0] & @LF)


    ConsoleWrite($zsideinterface[0] & @LF)

    If $I = 0 Then


    Else
        Local $aprojincr = StringRegExp(GUICtrlRead($ProjectNameInputBox), "(?<=-\d{2})([A-Z])(?=-Q)", 3)
        Local $Incr_char = Chr(Asc($aprojincr[0]) + 1)
        GUICtrlSetData($ProjectNameInputBox, StringRegExpReplace(GUICtrlRead($ProjectNameInputBox), _
                "(?<=-\d{2})([A-Z])(?=-Q)", $Incr_char))
    EndIf
    $I = $I + 1
    MsgBox(0, "test", $I)
Until @error

EndSwitch
WEnd

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

_StringBetween returns a zero based array, so the first element array[0] does not contain the number of elements contained in the array. Instead you must use Ubound to get the number of elements in the array. The normal syntax would be something like the following.

For $i = 0 To Ubound($array) -1

Of course you still need to check that the function actually returned an array to begin with.

Edited by czardas

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

czardas....all of this data is being pulled from one HTML page.  I need these to be looped each time all the data is "parsed" from one page then move on to the next. so there will always onl be 1 element in any of the arrays.

I guess i'm confused if I need to declare each of the variables as its each own array then use UBOUND for each instance that I need the variables printed in my email form or is there a better "less code" way of writing this or can I declare all of these variables as global instead of having to declare all of the "_StringBetween" under each function that I will be using in this script which will basically be 7 different varations of text using all of the same variables

Edited by atnextc

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Let's suppose you get an array with 1 element and that has a numeric value of 1. You then loop from 0 to $array[0]. That's looping through two elements of an array which only contains one element. This is the first thing wrong with your original code - which will nearly always throw an error. There are some other issues, but this is the main problem you have to solve before you can fix anything else.

You wrote:

For $i = 1 to $projectnextstep[0]

This is the main issue. $projectnextstep[0] should be a string, and not necessarilly numeric. Read the help file about _StringBetween again. It states:

$array[0] contains the first found string.

 

I'm not quite sure what the rest of your code is about, but instead of using so many arrays you could create a single 2D array to hold all the data. You still need to understand the difference between a 0 based array and an array which contains the number of entries in $array[0].

The other issue I see in your first post is a logical error.

If IsArray($projectnextstep) Then
     For $i = 1 to $projectnextstep[0]
         ConsoleWrite($projectnextstep[$i] & @LF)
         Next
    For $i = 1 to $circuitID[0] ; =====>> This might not be an array. ??????????
         ConsoleWrite($circuitID[$i] & @LF)
         Next
 EndIf
Edited by czardas

Share this post


Link to post
Share on other sites

so basically all i'm doing is grabbing the interface names and router name from a web page, then moving to the next webpage and grabbing the same date,....router and interfaces, then using those variables to fill in a script written

Share this post


Link to post
Share on other sites

so yea i guess the easiest thing would be to create a 2d array, which i attempted several times and failed in another post I created, an help on how I could get that started would be appreciated.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

You should read all you can about working with arrays. Here's some information http://www.autoitscript.com/wiki/Arrays

I think you are having difficulty because you are trying to solve the problem with your project, instead of understanding the tools and learning how to use them. First make a simple 2D array and play around with it. Then you need to figure out how to use the same methods to solve a more complicated problem (your original problem). If you start learning about 2D arrays with your complicated example, you will just confuse yourself. The first and most important thing is to understand the points I made in my previous, post before messing about with 2D arrays.

Here's something to get you started:

#include <Array.au3>

Local $aMyArray[3][2]
$aMyArray[0][0] = 6

_ArrayDisplay($aMyArray)
Edited by czardas

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

thank you..i've read that several times....I will create a simple 2d array and play around with it.  In regards to " my complicated example":

The elements in the array would be this right?  Since all i'm really trying to do is gather all of this information from a certain webpage, an undetermined number of times"

Local $projectnextstep = _StringBetween($string, '|NextStep=', @CRLF);;;;;; WORKS AND IS IN A LOOP
Local $circuitID = _StringBetween($string, '|CircuitID=', @CRLF);;;;;;;;;;;;;;;;;;;;;;;;;;;WORKS AND IS IN A LOO
Local $asideengineer = _StringBetween($string, '|ASideAssignedEngineer=', @CRLF)
Local $zsideengineer = _StringBetween($string, '|ZSideAssignedEngineer=', @CRLF)
Local $asidenextstep = _StringBetween($string, '|ASideNextStep=', @CRLF)
Local $zsidenextstep = _StringBetween($string, '|ZSideNextStep=', @CRLF)
Local $asiderouter = _StringBetween($string, '|ALocation=', @CRLF)
Local $zsiderouter = _StringBetween($string, '|ZLocation=', @CRLF)
Local $asideinterface = _StringBetween($string, '|AInterface=', @CRLF)
Local $zsideinterface = _StringBetween($string, '|ZInterface=', @CRLF)
Local $asidetransport = _StringBetween($string, '|ATransportLocation=', @CRLF)
Local $zsidetransport = _StringBetween($string, '|ZTransportLocation=', @CRLF)
Local $asidefpc = _StringBetween($string, '|AFPC=', @CRLF)
Local $zsidefpc = _StringBetween($string, '|ZFPC=', @CRLF)
Local $asidepic = _StringBetween($string, '|APIC=', @CRLF)
Local $zsidepic = _StringBetween($string, '|ZPIC=', @CRLF)
Local $asideoptics = _StringBetween($string, '|AOptics=', @CRLF)
Local $zsideoptics = _StringBetween($string, '|ZOptics=', @CRLF)
Local $asidetam = _StringBetween($string, '|ATAM=', @CRLF)
Local $zsidetam = _StringBetween($string, '|ZTAM=', @CRLF)
Local $asidetom = _StringBetween($string, '|ATOM=', @CRLF)
Local $zsidetom = _StringBetween($string, '|ZTOM=', @CRLF)
Local $asidetestip = _StringBetween($string, '|ATestingIP=', @CRLF)
Local $zsidetestip = _StringBetween($string, '|ZTestingIP=', @CRLF)
Local $bypassname = _StringBetween($string, '|BypassName=', @CRLF)

As I see it, the elements in the array would be the "variables" posted above and the data in the array would always be "0" as there is always something filled in on these pages.

Please advise if I am on the right track with my thinking.  And if so, the wiki doesn't really have a good example of how to set the elements in an array by using string split several times on the same string, which in this case is the html from one webpage.

Edited by atnextc

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Think - how would you lay the information out in a table? In your example, each row should represent one type of return data and have a number of entries. The table has to be large enough to hold all the rows and columns needed. To create this table you will have to loop through each row, and then in each row you have to loop through each column to fill the array with the correct contents. So this involves a loop nested inside another loop.

#include <Array.au3>

Local $aMyArray[3][2]
$aMyArray[0][0] = 2
$aMyArray[0][1] = 2

For $i = 1 To 2
    For $j = 0 To 1
        $aMyArray[$i][$j] = "Data"
    Next
Next
_ArrayDisplay($aMyArray)

These will just be meaningless words to you if you don't try out some simple examples to check you understand correctly what is happening. You may also need to use Redim - if you need to add more columns.

Edited by czardas

Share this post


Link to post
Share on other sites

thank you for this information czardas......i'm not sure i'm accurately conveying what exactly i'm hoping to achieve....as I don't believe that I will need more than 1 column, and the number of rows would be the number of the variables that i'm trying to get from the HTML page above.

 

Here is an example that I wrote that, the "console write" is one of the many things that this script that i'm trying to write will do.  In this example below this works perfectly.  I just couldn't get it to work properly in my code posted in #1, I"m not a coder or programmer, and I fell based on the results that I have achieved that I'm almost there but as you said not fully understanding the arrays is very hindering, the problem is I have about 5 days to get this whole script working...which hinges on me getting the data pulled from the HTMl pages accurately and looping correctly the array  or variable is empty...indicating that the wiki page doesn't exist yet.

 

I really appreciate your help tonight....I'm honestly not looking for a post consisting of "here ya go" but a start using the actual data that i've provided I think would greatly help my understanding as its what i'm working with, versus using an example that i'm trying to make up as I go along, because i will always default back to " let me try it with a real world example".  Again, no disrespect to any of your ideas or suggestions.....its just frustrating when I can get "accurate results" some times, and feel like I have a handle on it, then when I go to "expand/continue" the script to include other scenarios it all breaks........:(

; Working "Do Until In Loop" But the items in the array are predefined. Still need to see how to get it to work on the actual script.

#include <Array.au3>

Global $arr[5]
$arr[0]="xe-1/2/3"
$arr[1]="xe-1/2/4"
$arr[2]="xe-1/2/5"
$arr[3]="xe-1/2/6"
$arr[4]="LANGBBRJ01"
Global $arr2[5]
$arr2[0]="xe-2/2/3"
$arr2[1]="xe-2/2/4"
$arr2[2]="xe-2/2/5"
$arr2[3]="xe-2/2/6"
$arr2[4]="SANJBBRJ01"
$ASideAEinterface = ("ae9")
$ZSideAEinterface = ("ae15")
;$ZSideRouter = ("LANGBBRJ01")
;$ASideRouter = ("SANJBBR01")

Global $L= 0
Global $K= 0


ConsoleWrite("show interface description | no-more" & @CRLF)
ConsoleWrite("show rsvp interface | no-more" & @CRLF)
ConsoleWrite("show mpls interface | no-more" & @CRLF)
ConsoleWrite("show ospf neighbor | no-more" & @CRLF)
ConsoleWrite("show pim neighbors | no-more" & @CRLF)
ConsoleWrite("show bgp summary | no-more" & @CRLF)
ConsoleWrite("show ldp interface | no-more" & @CRLF)
ConsoleWrite("show ldp session | no-more" & @CRLF)
ConsoleWrite("show ldp neighbor | no-more" & @CRLF)
ConsoleWrite("show mpls lsp | match down" & @CRLF)
ConsoleWrite("show igmp interface | no-more " & @CRLF)
ConsoleWrite("show bfd session summary" & @CRLF)
Do
ConsoleWrite("show interface extensive " & $arr[$L] & " | no-more " & @CRLF)
$L =$L +1
Until $L = 4
$L= 0
ConsoleWrite("show interface extensive " & $ASideAEinterface & " | no-more" & @CRLF)
ConsoleWrite("show log messages | last 300 " & @CRLF)
ConsoleWrite(@CRLF)

Do
ConsoleWrite("delete interfaces " & $arr[$L] & @CRLF)
ConsoleWrite("set interfaces " & $arr[$L]& " unit 0 family inet address 192.168.10" &$L&".1/31"& @CRLF)
ConsoleWrite("set interfaces " & $arr[$L]& " description ""Testing Script for " & $arr[$L]&""""&@CRLF)
ConsoleWrite(@CRLF)
$L =$L +1
Until $L = 4
$L= 0
ConsoleWrite("========================================================================================================================" & @CRLF)
ConsoleWrite( @CRLF)
ConsoleWrite("Configuration Commands:" & @CRLF)
ConsoleWrite( @CRLF)
ConsoleWrite( @CRLF)
ConsoleWrite("edit exclusive" & @CRLF)
ConsoleWrite( @CRLF)
Do
ConsoleWrite("delete interfaces " & $arr2[$K] & @CRLF)
$K =$K +1
Until $K = 4
$K= 0
ConsoleWrite( @CRLF)
Do

ConsoleWrite("set interfaces " & $arr2[$K] & " description ""Cox;;C4 "& $arr[4] &";"& $arr[$L]& ";MR;10GE To "& $arr[4]& ";""" & @CRLF)
ConsoleWrite("set interfaces gigether-options 802.3ad " & $ASideAEinterface & @CRLF)
ConsoleWrite("set interfaces disable " & $arr2[$K] & @CRLF)
ConsoleWrite( @CRLF)
$L =$L +1
$K =$K +1
Until $L And $K = 4
$L= 0
$K= 0

ConsoleWrite( @CRLF)
ConsoleWrite( @CRLF)
ConsoleWrite("show | compare " & @CRLF)
ConsoleWrite("commit check " & @CRLF)
ConsoleWrite("commit sync and quit " & @CRLF)

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

It's not only because it's more useful to you to be able to solve problems, that I focus on the basics - it's also because it's complicated to pull data from html. There is no single solution as far as I know. If _StringBetween is working in this case, then you can use that method. The function returns an array. The syntax you used in the first post was not accessing the array correctly. which I tried to explain in >post #5 . Part of your code should really look something like this:

If IsArray($projectnextstep) Then
     For $i = 0 to UBound($projectnextstep) -1
         ConsoleWrite($projectnextstep[$i] & @LF)
     Next
 EndIf

This first checks if $projectnextstep is an array before trying to access however many elements it contains. Another tip: Instead of writing $L =$L +1, you could also write $L += 1. Perhaps you will understand it better after a good night's sleep - if you're tired right now.

Edited by czardas

Share this post


Link to post
Share on other sites

czardas....the reason that I'm using stringbetween is this:

Below is a direct copy of data i'm working with...this is a mediawiki page in "edit" mode this is what i'm pulling with the top portion of the script.

From there, i'm interested in whats between = and @CRLF on each line. 

There is a gui on my script that a user would enter a project name which would pull the "HTML" from our wiki server and parse out said information to basically place in a "find and replace" template so that we don't have to type our configurations.  The issue is that there are times where we're doing more than 1 project at a time, which would involve the loop within another loop.

Please let me know if this is helpful in what i'm trying to accomplish.

[[Category:C4OpenProjectTest]]
{{C4NextGen
|NextStep=Hardware/Testing
|TargetCompletionDate=June 2013
|CircuitID=
|ProjectOverview=MRFDBBRJ02 add 4 more SFPP / OCG Upgrade Needed/TAM moves required
|ProjectNotes=Z side Hardware/Testing completed on May 21, 2013
|ProjectType=C4 Hardware
||Priority=79%
|ProjectOpenDate= 2013-Q2
|FailureResponse=N/A
|Fatesharing=
|ProjectType=C4 Hardware
|LinktoCaridenPlan=
|ASideAssignedEngineer=
|ZSideAssignedEngineer=
|ASideNextStep=
|ZSideNextStep=Traffic Add
|ALocation=Router1
|ZLocation=Router1
|ARouter=ASHBBBRJ02
|ZRouter=MRFDBBRJ02
|AInterface=et-0/0/11
|ZInterface=xe-3/0/0
|AOSPFMetric=
|ZOSPFMetric=
|AIPAddress=10.10.10.10
|ZIPAddress=10.10.10.11
|ATransportLocation=ASH-4-A-5-1-1
|ZTransportLocation=MRFD-5-A-5-1-1
|APOC=
|ZPOC= 
|AChassisType=PTX
|ZChassisType=T1600
|AFPC=
|AFPCSerialNumber=
|ZFPC=T1600 FPC
|ZFPCSerialNumber=BBAJ4084
|ZFPC=T1600 FPC
|APIC=
|APICSerialNumber=
|ZPIC=10 x 10GE (LAN/WAN) SFPP
|ZPICSerialNumber=EN4605
|AOptics=
|AOpticsSerialNumber=
|ZOptics=SFPP-10G-LR
|ZOpticsSerialNumber=SAP31C73
|AConnector=
|ZConnector=LC
|AFiber=
|ZFiber=
|Ahardware=
|Zhardware=
|ATAM=MOVE
|ZTAM=MOVE
|ATOM=NONE
|ZTOM=NONE
|ABudgetCode=
|ZBudgetCode=
|ATransportSerialNumbers=
|ZTransportSerialNumbers=
|ATestingIP=192.168.55.2/30
|ZTestingIP=192.168.55.1/30
|ATransportNotes=BBOPS-TR: OCG Upgrade Needed/Move TAM/TOMs from PLAL 1-A-5-5
|ZTransportNotes=BBOPS-TR: OCG Upgrade Needed/Move TAM/TOMs from PLAL 3-A-6-3
|BypassName=
|BypassIP=
|BypassAConnector=
|BypassZConnector=
|DPIName=
|DPIIP=
|DPIAConnector=
|DPIZConnector=
|AInstallECM=
|AInstallDate=
|ZInstallECM=ECR000000070736
|ZInstallDate=May 21, 2013
|ATrafficDate=
|ZTrafficDate=
|ATrafficECM=
|ZTrafficECM=
|AShipmentOneTracking=
|ZShipmentOneTracking=
|AShipmentTwoTracking=
|ZShipmentTwoTracking=
|AShipmentThreeTracking=
|ZShipmentThreeTracking=
|APeeringMaintenanceTicket=
|ZPeeringMaintenanceTicket=
|AInboundShipmentTicket=
|ZInboundShipmentTicket=
|}}

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

The above information doesn't mean a great deal to me - I understand it's some kind of sales related information. Perhaps someone else knows more about what you are doing. In any case I imagine you will want to use nested loops. Perhaps your method could be FOR each project, FOR each relevant item, replace some information NEXT NEXT. How you organise the data depends on how you want to access it. Just loop through and write the results to a file, or store all the information from all the projects in some kind of table for future reference. It all depends on the intended purpose.

I notice all the categories are unique. What I don't know is whether they always occur in the same order and what exactly you intend to replace. So finding the best solution isn't particularly easy for anyone.

Edited by czardas

Share this post


Link to post
Share on other sites

they will always occur in the same order. I just need to loop through and write the results to a file. Thats it.

Share this post


Link to post
Share on other sites

This code "works" in that the correct value for the variable is written to the console. It's not stopping when the array "read any of them" are empty, it just keeps looping through and i'm not sure why.

Case $Submit
Do

    If $I >= 1 Then

        Local $aprojincr = StringRegExp(GUICtrlRead($ProjectNameInputBox), "(?<=-\d{2})([A-Z])(?=-Q)", 3)
        Local $Incr_char = Chr(Asc($aprojincr[0]) + 1)
        GUICtrlSetData($ProjectNameInputBox, StringRegExpReplace(GUICtrlRead($ProjectNameInputBox), _
                "(?<=-\d{2})([A-Z])(?=-Q)", $Incr_char))
    Else

    EndIf
    Local $oIE = _IECreate("https://bbops.cox.net/mediawiki/index.php?title=" & GUICtrlRead($ProjectNameInputBox) & "&action=edit", 0, 0, 1, 0)
    _IELinkClickByText($oIE, "Continue to this website (not recommended).")
    Local $Imax = 5
    Local $data = $oIE
    Local $string = _IEBodyReadHTML($oIE)
    _IEQuit($oIE)

    Local $projectnextstep = _StringBetween($string, '|NextStep=', @CRLF);;;;;; WORKS AND IS IN A LOOP
    Local $circuitID = _StringBetween($string, '|CircuitID=', @CRLF);;;;;;;;;;;;;;;;;;;;;;;;;;;WORKS AND IS IN A LOO
    Local $asideengineer = _StringBetween($string, '|ASideAssignedEngineer=', @CRLF)
    Local $zsideengineer = _StringBetween($string, '|ZSideAssignedEngineer=', @CRLF)
    Local $asidenextstep = _StringBetween($string, '|ASideNextStep=', @CRLF)
    Local $zsidenextstep = _StringBetween($string, '|ZSideNextStep=', @CRLF)
    Local $asiderouter = _StringBetween($string, '|ALocation=', @CRLF)
    Local $zsiderouter = _StringBetween($string, '|ZLocation=', @CRLF)
    Local $asideinterface = _StringBetween($string, '|AInterface=', @CRLF)
    Local $zsideinterface = _StringBetween($string, '|ZInterface=', @CRLF)
    Local $asidetransport = _StringBetween($string, '|ATransportLocation=', @CRLF)
    Local $zsidetransport = _StringBetween($string, '|ZTransportLocation=', @CRLF)
    Local $asidefpc = _StringBetween($string, '|AFPC=', @CRLF)
    Local $zsidefpc = _StringBetween($string, '|ZFPC=', @CRLF)
    Local $asidepic = _StringBetween($string, '|APIC=', @CRLF)
    Local $zsidepic = _StringBetween($string, '|ZPIC=', @CRLF)
    Local $asideoptics = _StringBetween($string, '|AOptics=', @CRLF)
    Local $zsideoptics = _StringBetween($string, '|ZOptics=', @CRLF)
    Local $asidetam = _StringBetween($string, '|ATAM=', @CRLF)
    Local $zsidetam = _StringBetween($string, '|ZTAM=', @CRLF)
    Local $asidetom = _StringBetween($string, '|ATOM=', @CRLF)
    Local $zsidetom = _StringBetween($string, '|ZTOM=', @CRLF)
    Local $asidetestip = _StringBetween($string, '|ATestingIP=', @CRLF)
    Local $zsidetestip = _StringBetween($string, '|ZTestingIP=', @CRLF)
    Local $bypassname = _StringBetween($string, '|BypassName=', @CRLF)


if IsArray($asideinterface) Then

    $Imax = UBound($asideinterface)
     ;ConsoleWrite("Items in the array: " & $iMax & @LF)
         For $i = 0 to UBound($asideinterface) -1
         ConsoleWrite($asideinterface[$i] & @LF)
        ; ConsoleWrite("Ubound($asideinterface):=" & UBound($asideinterface)& @LF)
     Next
 EndIf

if IsArray($zsideinterface) Then

    $Imax = UBound($zsideinterface)
     ;ConsoleWrite("Items in the array: " & $iMax & @LF)
         For $i = 0 to UBound($zsideinterface) -1
         ConsoleWrite($zsideinterface[$i] & @LF)

Next
endif
$I =$I + 1
msgbox (0,"test",$I)
Until $I = 5

     _ArrayDisplay($asideinterface)
     _ArrayDisplay($zsideinterface)


EndSwitch
WEnd

Share this post


Link to post
Share on other sites

It keeps looping because you use $i and $I. They are the same variable. The value for $i keeps getting reset in the For loop, so you never can exit the Do loop.  Variables are not case sensitive. You have to choose another name for one of those two variables.

Share this post


Link to post
Share on other sites

czardas...thanks was able to get that portion resolved rather easily.

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