Jump to content
Sign in to follow this  
erezlevi

Array help please....

Recommended Posts

erezlevi

hi,

can some one tell me why can't I put the values after striping them from the original string in the Array at the $e+10 position in the Array?

the erez.txt file holds the following:

erez1=king

erez2=Quein

erez3=prince

erez4=servent

#include <File.au3>
#include <Array.au3>
global $r, $u1

Dim $myArray[20]


$i = "erez"
$s = "1"
$erez="c:\erez.txt"
_FileReadToArray ($erez,$myArray)
_ArrayDisplay ($myArray)
For $o = 1 To 10
$e=_ArraySearch ($myArray,$i&$s,0,0,1,True)
if $e > -1 Then
    $u1 = FileReadLine($erez, $e)
    $infou1 = StringSplit($u1, "=")
    $u1 = $infou1[2]
    call ("levi",$u1)
Else 
    call ("levi",$u1="")
EndIf
$s=$s+1

Next
func levi ($m1)
    _ArrayInsert ($myArray,$e+10,$m1)
EndFunc
_ArrayDisplay ($myArray)

Share this post


Link to post
Share on other sites
erezlevi

hi,

can some one tell me why can't I put the values after striping them from the original string in the Array at the $e+10 position in the Array?

the erez.txt file holds the following:

erez1=king

erez2=Quein

erez3=prince

erez4=servent

#include <File.au3>
#include <Array.au3>
global $r, $u1

Dim $myArray[20]


$i = "erez"
$s = "1"
$erez="c:\erez.txt"
_FileReadToArray ($erez,$myArray)
_ArrayDisplay ($myArray)
For $o = 1 To 10
$e=_ArraySearch ($myArray,$i&$s,0,0,1,True)
if $e > -1 Then
    $u1 = FileReadLine($erez, $e)
    $infou1 = StringSplit($u1, "=")
    $u1 = $infou1[2]
    call ("levi",$u1)
Else 
    call ("levi",$u1="")
EndIf
$s=$s+1

Next
func levi ($m1)
    _ArrayInsert ($myArray,$e+10,$m1)
EndFunc
_ArrayDisplay ($myArray)
sorry guys, found the problem + I have decided to use a second Array instead here is the code:

#include <string.au3>
#include <File.au3>
#include <Array.au3>
local $r, $u1
global $e
Dim $myArray[20]
Dim $yuArray[20]

$i = "erez"
$s = "1"
$erez="c:\erez.txt"
_FileReadToArray ($erez,$myArray)
_ArrayDisplay ($myArray)

for $o=1 to 5
    $e=_ArraySearch ($myArray,$i&$s,0,0,1,True)
if $e > -1 Then
    $u1 = FileReadLine($erez, $e)
    $infou1 = StringSplit($u1, "=")
    $u1 = $infou1[2]
    call ("levi",$u1,$e)
Else 
    call ("levi",$u1="")
EndIf
$s=$s+1
Next

func levi ($m1,$y)
    _ArrayInsert ($yuArray,$y,$m1)
EndFunc
_ArrayDisplay ($yuArray)

Share this post


Link to post
Share on other sites
FreeFry

Are you sure you want to use a text file? If it's just entries with a value, then you should maybe try using the Ini functions(IniWrite, IniRead, etc.). :}

Share this post


Link to post
Share on other sites
erezlevi

Are you sure you want to use a text file? If it's just entries with a value, then you should maybe try using the Ini functions(IniWrite, IniRead, etc.). :}

It isn't what I meant, the Text file is the outcome of another application. I need to get the values from the text for each line holds the:

erez1="lskdjflsdkjf"

lskjfdlskdjflkj

sdlfkjdslkjf

ashdglashg

erez2="blablablalba"

without the "erez1" or "erez2" initials, so the stringsplit helps with that and the arrays helps with getting the lines where "erez1" and "erez2" are. so if I change their value using _filewritetoline I know what line to change for erez1 and for erez2.

Share this post


Link to post
Share on other sites
FreeFry

Oh, okidok. :D

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  

×