Jump to content

Code bit


Recommended Posts

Dim $arr[2]
$in=FileOpen("elevi.txt",0)
$out=FileOpen("elevi.out",2)
while 1
$inst=FileReadLine($in)
if @error=-1 then ExitLoop
$inst=StringRight($inst,2)
$arr=StringSplit($inst,",")
$nume=$arr[1]
$judet=StringStripWS($arr[2],8)
if $ljudet<>$judet then FileWriteLine($out,$judet)
FileWrite($out,$nume)
$ljudet=$judet
wend

What's wrong with this code bit????!!!!!

I keep getting an error on line 10 "Array variable has incorrect number of subscripts or subscript dimension range exceeded."

Pls help.. :)

Quote

Together we might liveDivided we must fall

 

Link to comment
Share on other sites

$arr[2] means you can use:

1: $arr[0]

2: $arr[1]

and your trying to call $arr[2]

btw you also overwrite your array with stringsplit.

you dont have to pre-declare it if it is used in stringsplit.

Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Link to comment
Share on other sites

Ok..make that $arr[100]..it doesn't matter..I added that just because I thought I haven't declared it right..:)..Same thing with Dim $arr[100], $arr[1000] or $arr[514]..

Quote

Together we might liveDivided we must fall

 

Link to comment
Share on other sites

i need to know what is in elivi.txt could you attach it ?

[edit]

i think you mean StringTrimRight instead of TrimRight. now you only got 2 chars.

and i think that is unable to split into more then 1 :)

[/edit]

Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Link to comment
Share on other sites

Yep..got it fixed..here's the final version..(not that it would be of use to anyone here)..Thanks for the StringRight remark, w0uter..I guess I'm not as 31337 in AutoIt as I thought I was :D..(Btw..It seems that FileReadLine reads everything on the line BUT the @CRLF..so there was no need for a StringTrimRight after all..I guess I'm just used to 'sockets' :)))..thanks again :evil:

Dim $arr[100]
Dim $ljudet
$in=FileOpen("elevi.txt",0)
$out=FileOpen("elevi.out",2)
while 1
$inst=FileReadLine($in)
if @error=-1 then ExitLoop
$arr=StringSplit($inst,",")
$nume=$arr[1]
$judet=StringStripWS($arr[2],8)
if $ljudet<>$judet then FileWriteLine($out,$judet)
FileWriteLine($out,$nume)
$ljudet=$judet
wend
Edited by VicTT
Quote

Together we might liveDivided we must fall

 

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