Jump to content
Sign in to follow this  
tempman

Save arraydisplay to txt

Recommended Posts

tempman

;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?

Share this post


Link to post
Share on other sites
Palestinian

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

Share this post


Link to post
Share on other sites
tempman

Did you even try the code you wrote?!? :ermm:

Share this post


Link to post
Share on other sites
Palestinian

Did you even try the code you wrote?!? :ermm:

 

I did, and this is what I got inside the ip.txt file after running it:

10.27.52.5
10.27.52.6

 

If that's not what you are looking for then please try to explain your question better.

Share this post


Link to post
Share on other sites
Malkey

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 -----------------

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.