Sign in to follow this  
Followers 0
erezlevi

Help me please.

6 posts in this topic

hi,

well this is a problem that I can't find out why is happening, and don't know where to look for (maybe a bug in AU3) not sure, because if using the same file in VB it works fine.

the problem is that this file (attached) "erez.txt" is having problem getting it into Array using _FileReadTo Array. if anyone of you can solve it than you are GODS.

here is my code:

#include <File.au3>
#include <Array.au3>
Local $E[500]
Local $U[500]

FileOpen("c:\erez.txt", 1)
$c = FileOpen("c:\erez-Array.txt", 1)
_FileReadToArray("c:\erez.txt", $E)                          ; only need this part solved the rest is working fine when the file is entered into the Array manually.
$k = $E[0]
MsgBox(0, "$k", $k)
_ArrayDisplay($E)
For $o = 1 To $k
    Do                                                                ; this part erases all the JUNK in the file like: "[1;1H" 
        $z = $E[$o]
        $p1 = StringInStr($z, Chr(27), 1)
        $p2 = StringInStr($z, "H", 1)
        $p3 = ($p2 - $p1) + 1
        $n = StringMid($z, $p1, $p3)
        $t = StringReplace($z, $n, "")
    ;MsgBox(0, "this is $t:", $t)
        $E[$o] = $t
        If $t <> "" Then $U[$o] = $t
    ;_ArrayDisplay($U)
    Until $p1 = 0
    
Next
_FileWriteFromArray ($c,$U)

Share this post


Link to post
Share on other sites



what is the purpose of this line ?

FileOpen("c:\erez.txt", 1)

:)

well tried it without it and it still don't fill the $E array only partially look:

Share this post


Link to post
Share on other sites

oh, and another thing,

When opening the file and saving it as UNICODE file, the above script works.

but, when using AutoIT :

$File="c:\erez.txt"
$hfile="c:\erez1.txt"
$hFile1 = FileOpen($hfile, 2 + 32)
FileWrite($hFile1, FileRead($File))
FileClose($hFile1)

don't help either only when I manually change the file it does. what is wrong here?

Share this post


Link to post
Share on other sites

Hi,

This is the same problem as before;

You have null chars after your filereead, so replace them before saving the file; thus

$FileOrig=@ScriptDir&"\erez.txt"
$sfileread= FileRead($FileOrig)
consolewrite("stringlen($sfileread&@LF)="&stringlen($sfileread)&@LF)
consolewrite("$sfileread="&$sfileread&@LF)
$sfileread=StringReplace($sfileread,chr(0),"") ;**************************************************
consolewrite("No Nulls?; stringlen($sfileread&@LF)="&stringlen($sfileread)&@LF)
consolewrite("$sfileread="&$sfileread&@LF)
;=======================================================
$FileResult=@ScriptDir&"\erez1.txt"
$hFile = FileOpen($FileResult, 2 ) ;for writing+ 32+4*32
FileWrite($hFile,$sfileread)
FileClose($hFile)

run("notepad "&$FileResult)
Best, Randall

Share this post


Link to post
Share on other sites

Hi,

This is the same problem as before;

You have null chars after your filereead, so replace them before saving the file; thus

$FileOrig=@ScriptDir&"\erez.txt"
$sfileread= FileRead($FileOrig)
consolewrite("stringlen($sfileread&@LF)="&stringlen($sfileread)&@LF)
consolewrite("$sfileread="&$sfileread&@LF)
$sfileread=StringReplace($sfileread,chr(0),"") ;**************************************************
consolewrite("No Nulls?; stringlen($sfileread&@LF)="&stringlen($sfileread)&@LF)
consolewrite("$sfileread="&$sfileread&@LF)
;=======================================================
$FileResult=@ScriptDir&"\erez1.txt"
$hFile = FileOpen($FileResult, 2 ) ;for writing+ 32+4*32
FileWrite($hFile,$sfileread)
FileClose($hFile)

run("notepad "&$FileResult)
Best, Randall
well all I can say to You mr 'randallc' that you are a GOD! and I am bowing down man to your feet!

how did you know that this is a null problem ? you have to teach me.

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