Jump to content

Search the Community

Showing results for tags 'array filereadarray loops'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. Hey guys, I have a problem I have run into on a script that was going rather well given the limited amount of scripting / programming knowledge that I have. The issue that I have run into seems to be a catch 22 in that I have 2 files which contain router interface commands for our equipment. I basically need to declare a variable in one for loop, and pass that same variable to either another function or another for loop. What I am getting now is "Subscript used with non-Array variable.:" on $asideinterface for the _bside function I"m basically trying to grab this data from both files. Test.txt would be the A side, and Test2.txt would be the Z side. $asideinterface = _StringBetween ($ainput[$a],"interfaces ", " description") $circuitid = _StringBetween ($ainput[$a],"""Cox;",";C4") $zsiderouter = _StringBetween ($ainput[$a],"C4 ;",";") $zsideinterface = _StringBetween ($ainput[$a],";", ";") <-----I'm trying to grab whats between ; and ; towards the end of the file, but i can't tell it not to use the first instance of what it finds using _StringBetween Sample code posted below. Sample code that can be used for "test.txt" and "test2.txt" listed in code. Test.txt: set interfaces xe-0/0/6 description "Cox;13001.GE10.CHCGILDTJBW.PRVERIXYJAW;C4 CHGOBPRJ02;xe-0/0/0;MR;10GE TO CHGOBPRJ02 #1;" Test2.txt: set interfaces xe-0/0/0 description "Cox;13001.GE10.CHCGILDTJBW.PRVERIXYJAW;C4 PROVBBRJ01;xe-0/0/6;MR;10GE To PROVBBRJ01;" #include <file.au3> #include <String.au3> Local $a,$afile, $bfile, $ainput, $binput,$circuitid, $asiderouter, $zsiderouter, $asideinterfaces,$zsideinterfaces $afile = @ScriptDir & "\test.txt" $bfile = @ScriptDir & "\test2.txt" _FileReadToArray($afile,$ainput) _FileReadToArray($bfile,$binput) For $b = 0 To UBound($binput)-1 $zsideinterfaces = _StringBetween ($binput[$b],"interfaces ", " description") $asideinterfaces = _StringBetween ($binput[$b],";", ";") <-----I'm trying to grab whats between ; and ; towards the end of the file, but i can't tell it not to use the first instance of what it finds using _StringBetween if stringinstr($binput[$b],"description") Then filewrite (@ScriptDir & "\bsideinterfaces.txt",$zsideinterfaces[0]& @CRLF) filewrite (@ScriptDir & "\bsideinterfaces.txt",$asideinterfaces[0]& @CRLF) EndIf Next For $a = 0 To UBound($ainput)-1 $asideinterfaces = _StringBetween ($ainput[$a],"interfaces ", " description") $zsideinterfaces = _StringBetween ($ainput[$a],";", ";;") if stringinstr($ainput[$a],"description") Then filewrite (@ScriptDir & "\asideinterfaces.txt",$asideinterfaces[0]& @CRLF) filewrite (@ScriptDir & "\asideinterfaces.txt",$zsideinterfaces[0]& @CRLF) EndIf Next _bside() func _bside() For $b = 0 to UBound($binput)-1 $zsideinterfaces = _StringBetween ($binput[$b],"interfaces ", " description") $circuitid = _StringBetween ($binput[$b],"""Cox;",";C4") ;$circuitid = _StringBetween($binput[$b],";", @CRLF) local $asiderouter = _StringBetween ($binput[$b],";C4 ",";") local $asideinterfaces = _StringBetween ($binput[$b],";", ";")<-----I'm trying to grab whats between ; and ; towards the end of the file, but i can't tell it not to use the first instance of what it finds using _StringBetween if stringinstr($binput[$b],"description") Then _FileWriteToLine(@ScriptDir & "\test2.txt", $b, "set interfaces " &$zsideinterfaces[0]& " description ""Cox;"&$circuitid[0]&";C4 "&$asiderouter[0]&";"& $asideinterfaces[0] &";MR;10GE To " & $asiderouter[0] &";""", 1) EndIf Next EndFunc _aside() func _aside() For $a = 1 to UBound($ainput) -1 $asideinterfaces = _StringBetween ($ainput[$a],"interfaces ", " description") Local $circuitid = _StringBetween ($ainput[$a],"""Cox;",";C4") local $zsiderouter = _StringBetween ($ainput[$a],";C4 ",";") local $zsideinterfaces = _StringBetween ($ainput[$a],";", ";MR;10GE") if stringinstr($ainput[$a],"description") Then _FileWriteToLine(@ScriptDir & "\test.txt", $a, "set interfaces " &$asideinterfaces[0]& " description ""Cox;"&$circuitid[0]&";C4 "&$zsiderouter[0]&";"& $zsideinterfaces[0] &";MR;10GE To " & $zsiderouter[0] &";""", 1) EndIf Next EndFunc Please let me know if I need to be more clear I know this is kind of all over the place. Thanks for any help in advance.
×
×
  • Create New...