Jump to content

Save arraydisplay to txt


Go to solution Solved by Malkey,

Recommended Posts

;map.txt
;| IP         | Status      |
;----------------------------
;| 10.27.52.5 | disabled    |
;| 10.27.52.6 | disabled    |


#include <array.au3>
#include <File.au3>

$dump = "map.txt"

Local $String
_FileReadToArray($dump, $String)
_arraydisplay($String)

For $i = 1 To UBound($String) - 1
$answer = StringRegExp($String[$i],'((?:\d{1,3}\.){3}\d{1,3})',3)
_arraydisplay($answer)
Next

How to save $answer to ip.txt?

Link to comment
Share on other sites

Try this one.

#include <array.au3>
#include <File.au3>

$dump = "d:\map.txt"
$oIP = "d:\ip.txt"

Local $String
_FileReadToArray($dump, $String)
_ArrayDisplay($String)

For $i = 1 To UBound($String) - 1
    $answer = StringRegExp($String[$i], '((?:\d{1,3}\.){3}\d{1,3})', 3)
    _ArrayDisplay($answer)

    $oString = _ArrayToString($answer)
    FileWrite($oIP, $oString & @CRLF)
Next
Edited by Palestinian
Link to comment
Share on other sites

  • Solution

An example.

#include <array.au3>
#include <File.au3>

Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

;----- Create map.txt file -----------------
Local $dump = "map.txt"
If FileExists($dump) = 0 Then FileWrite($dump, "| IP         | Status      |" & @CRLF & _
        "----------------------------" & @CRLF & _
        "| 10.27.52.5 | disabled    |" & @CRLF & _
        "| 10.27.52.6 | disabled    |")
;ConsoleWrite(FileRead($dump) & @LF)
;-----> End of create "map.txt" file -----------------

Local $answer = StringRegExp(FileRead($dump), '((?:\d{1,3}\.){3}\d{1,3})', 3)
_ArrayDisplay($answer)

Local $SaveTo = "ip.txt"
_FileWriteFromArray($SaveTo, $answer)

; ----- View "ip.txt" file and optional clean up files from disk ------------
Local $iPID = ShellExecute($SaveTo)
Local $hWin = WinWaitActive($SaveTo, "")
Local $Sel = MsgBox(1, "Clean Up", 'Press "Ok" to delete "' & $dump & '" and  "' & $SaveTo & '" files.', 0, $hWin)

If $Sel = 1 Then
    FileDelete($dump)
    FileDelete($SaveTo)
EndIf
If WinExists($SaveTo) Then ProcessClose($iPID)
;-----> End view "ip.txt" file -----------------
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...