Jump to content

Search in a file


Recommended Posts

Hi
I want fetch everything behind , and , in the text file.
I have tried to find what I am doing wrong but I cant see it.
Can I get help with two extra eyes who can see what I have done wrong?

My script looks like this

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <String.au3>

$FilePath = 'Testing9.txt'

$Source = BinaryToString(IniReadSection($FilePath, ""))
$FirstChunks = _StringBetween($Source, ',', ',')


For $a In $FirstChunks
    ConsoleWrite($a & @CRLF)
    Sleep(1000)
Next

Inside Testing9.txt

dfsgasdfadsfads, Test1! ,dsafsdagasfgf
asdgasdfasd, Test2! ,sadfasdgasdfg74698
asdfasdfasd, Test3! ,dsagfgerargar
reggasdgadfsdg, Test4! ,gewgregegsreg
rgsfgdfsgff, Test5! ,regegfrdgfdsg6546
dfsbsdbfvsf, Test6! ,4563489465464
hetgbsdffsd, Test7! ,regbrregszgsf
sfgdf84gds65, Test8! ,fsdg8df4g6s5df4
rgewarg6456, Test9! ,fsg564654fsg

 

error I get is 

"C:\autoit\Script\Testing9.au3" (11) : ==> Variable must be of type "Object".:
For $a In $FirstChunks
For $a In $FirstChunks^ ERROR

Link to comment
Share on other sites

I know the message is misleading, but it also says (in other words) that your variable is not an 1D array.

Try this instead :

#include <Constants.au3>
#include <Array.au3>

$FilePath = 'Testing9.txt'

$Source = FileRead($FilePath)
Local $FirstChunks[0][3]
_ArrayAdd($FirstChunks, $Source, 0, ",", @CRLF)

For $i = 0 to UBound($FirstChunks, 1) - 1
  For $j = 0 to UBound($FirstChunks, 2) - 1
    ConsoleWrite($FirstChunks[$i][$j] & @CRLF)
  Next
Next

 

Edited by Nine
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...