Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

FileWrite Loop Issues

$
0
0

I have an issue where I'm trying to write a configuration for our routers. I am grabbing all the data needed from our website and declaring all the variables from the parsed html data.

 

I have a gui that a person will enter the number of projects that they have for each router.  This number of projects will dictate how many times the loop runs to grab all of the data.

 

The issue comes up when writing the file.

 

What I would like to happen is something similar to this:

 

===============================

 

Lines to only be written 1 time to file:

 

Lines to be written depend on number of projects:

 

Back to Only Write Lines below 1 time to file:

 

 

Lines to be written depend on number of projects:

 

=================================

 

 

I can get the number of lines being written the correct number of lines in the correct spot in the file, the issue is that the variable that is being written is the same variable everytime, since I believe its within the same do loop.

 

Any help would be greatly appreciated.

 

Below is a sample code written:

AutoIt         
Do $oIE = _IECreate("https://internalsite/?title=" & GUICtrlRead($ProjectNameInputBox) & "&action=edit", 0, 0, 1, 1)     _IELinkClickByText($oIE, "Continue to this website (not recommended).") $string = _IEBodyReadHTML($oIE) $data = $oIE     _IEQuit($oIE) $asideinterface = _StringBetween($string, '|AInterface=', @CRLF) $zsideinterface = _StringBetween($string, '|ZInterface=', @CRLF) Local $aprojincr = StringRegExp(GUICtrlRead($ProjectNameInputBox), "(?<=-\d{2})([A-Z])(?=-Q)", 3)         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)) if IsArray($asideinterface) = 1 Then ReDim $asideinterface[1] if IsArray($zsideinterface) = 1 Then ReDim $zsideinterface[1] EndIf EndIf ConsoleWrite("First Line Test"& @CRLF) If Not GUICtrlRead($NumberofProjects) = 0 Then Call ("_Test") EndIf ConsoleWrite("Last Line Test"& @CRLF) $i += 1 Until $i = (GUICtrlRead($NumberofProjects)) If $i = $C Then Exit     EndSwitch WEnd Func _Test() ConsoleWrite($asideinterface[0]& @CRLF) ConsoleWrite($zsideinterface[0]& @CRLF) EndFunc

The code above is spitting this out in the Console:

--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop First Line Test et-0/0/11 xe-3/0/0 Last Line Test --> IE.au3 V2.4-0 Warning from function _IELinkClickByText, $_IEStatus_NoMatch First Line Test et-0/0/13 xe-3/1/0 Last Line Test --> IE.au3 V2.4-0 Warning from function _IELinkClickByText, $_IEStatus_NoMatch First Line Test et-1/0/11 xe-3/0/2 Last Line Test --> IE.au3 V2.4-0 Warning from function _IELinkClickByText, $_IEStatus_NoMatch First Line Test et-1/0/13 xe-3/1/2 Last Line Test

In the above text I only need "first line test" and last line test" to be written one time, and not looping like it currently is.

 

Below is the output file that is being created on the actual code:  Where the interface is the same, that is supposed to be the next interface that was in the loop.

 


AutoIt         
THIS ONLY NEEDS TO BE WRITTEN ONE TIME Pre-Snap Shot: show interface description | no-more show rsvp interface | no-more show mpls interface| no-more show ospf neighbor| no-more show pim neighbors| no-more show bgp summary| no-more show ldp interface| no-more show ldp session | no-more show ldp neighbor | no-more show mpls lsp | match wn show igmp interface | no-more show bfd session summary show log messages | last 300 THIS NEEDS TO BE WRITTEN THE NUMBER OF TIMES THAT WE ARE LOOPING.  As you can see the interface "et-0/0/11" is the same all the lines.  I want this to be the next interface that is expected in the loop. show interface extensive et-0/0/11 | no-more show interface diagnostics optics et-0/0/11 | match "Laser output power|Receiver signal average optical power" show interface extensive et-0/0/11 | no-more show interface diagnostics optics et-0/0/11 | match "Laser output power|Receiver signal average optical power" show interface extensive et-0/0/11 | no-more show interface diagnostics optics et-0/0/11 | match "Laser output power|Receiver signal average optical power" show interface extensive et-0/0/11 | no-more show interface diagnostics optics et-0/0/11 | match "Laser output power|Receiver signal average optical power"

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>