Jump to content
Sign in to follow this  
{NL}--Xantios---

Just a litle problem

Recommended Posts

{NL}--Xantios---

Goooood day mate's :(

i am making an simple litle script that reads a file , cuts some piece's of an then write it to an other file

now i have the file in the format

<contact type="1">The TEXT</contact>

i just only want to read The TEXT so , how can i do this ? o btw here is what i have made jet :)

$file = InputBox("XantiTools","Waar Staat de lijst met mail adressen ?")
fileread($file)
$count = 4
while 1 
$regel = FileReadLine($file,$count)
$count = $count + 1
$regel = $regel - "<contact type="
$regel = $regel - """1"""
$regel = $regel - "</contact>"
filewrite("uitvoer.txt",$regel &@crlf)
weND

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

try this

Func _StringBetween1($s_String, $s_Start = 0, $s_End = 0)
    $s_Start = StringInStr($s_String, $s_Start) + StringLen($s_Start)
    Return StringMid($s_String, $s_Start, StringInStr($s_String, $s_End) - $s_Start)
EndFunc  ;==>_StringBetween1

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
{NL}--Xantios---

and how do i user this ? :) :">

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

try this:

#include <file.au3>
#include <Array.au3>
$path1 = "1.txt"; your first file
$path2 = "2.txt"; your second file
Dim $array[1]

Dim $aRecords
If Not _FileReadToArray($path1, $aRecords) Then
    MsgBox(4096, "Error", " Error reading log to Array error:" & @error)
    Exit
EndIf

For $x = 1 To $aRecords[0]
    If StringInStr($aRecords[$x], '<contact type="1">') <> 0 Then
        _ArrayAdd($array, _StringBetween1($aRecords[$x], '<contact type="1">', "</contact>"))
    EndIf
Next

_FileWriteFromArray($path2,$array)

Func _StringBetween1($s_String, $s_Start = 0, $s_End = 0)
    $s_Start = StringInStr($s_String, $s_Start) + StringLen($s_Start)
    Return StringMid($s_String, $s_Start, StringInStr($s_String, $s_End) - $s_Start)
EndFunc  ;==>_StringBetween1

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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  

×