Jump to content

some help needed


 Share

Recommended Posts

i just want to go through a list, and replace the spaces with a colon.

$file = FileOpen("ACCOUNTS.txt", 0)

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

StringReplace($line," ",":")

Wend

FileClose($file)

exit

its not doing anything..... heh

i have messed with it for about 45 minutes, and im stuck

a little help? thanks

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

Is the file opening? Also you may want a Do...Until.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

its not even changing the FIRST line.. yeah. its opening.

other than that, i thought it was supposed to run till the end of the file.. hence the @error = -1

i got this from the help file

; Read in lines of text until the EOF is reached

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

MsgBox(0, "Line read:", $line)

Wend

FileClose($file)

i just changed it a bit to do what i wanted. but yeah.. like i said, i have been at this about 45 min. i tried a few things. any sugggestions?

EDIT: this shouldnt need a do.. until

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

you're opening the file readonly, is that a problem? There's no point where you're writing the info back to the file, or to another one.

i just want to go through a list, and replace the spaces with a colon.

$file = FileOpen("ACCOUNTS.txt", 0)

While 1

    $line = FileReadLine($file)

If @error = -1 Then ExitLoop

StringReplace($line," ",":")

Wend

FileClose($file)

exit

its not doing anything..... heh

i have messed with it for about 45 minutes, and im stuck

a little help? thanks

<{POST_SNAPBACK}>

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

I'm working on it.. so far I copied your code and created a file and I cant even get it to open :-/

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

well, i just run the script from the helpfile

$file = FileOpen("ACCOUNTS.txt", 0)

; Check if file opened for reading OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

; Read in lines of text until the EOF is reached

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

MsgBox(0, "Line read:", $line)

Wend

FileClose($file)

and when i run that, it works. i mean.. i get a message box, with the first line in the .txt file.

it then gives me the second line.. third line... so on so on.

can the stringreplace function see the space i put in the quotes? everything seems to be working fine except for the stringreplace line.

but when i run this script.. it just ends. it does nothitng that i can see.

$file = FileOpen("ACCOUNTS.txt",0)

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

StringReplace($line," ",":")

Wend

FileClose($file)

exit

so.. yeah. im stuck lol

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

I'm working on it.. so far I copied your code and created a file and I cant even get it to open :-/

JS

<{POST_SNAPBACK}>

My code? That's your code... :) I didn't change it at all.

Edit: Excuse me, my mistake.

Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

Okay I figured it out. (Kinda)

You arent writing what you got back to the file...or to another file.

$g_szVersion = "Test 1.0"
If WinExists($g_szVersion) Then Exit; It's already running
AutoItWinSetTitle($g_szVersion)


$file = FileOpen("ACCOUNTS.txt", 0)

While 1
$line = FileReadLine($file)
If @error = -1 Then ExitLoop
$linewrite = StringReplace($line," ",":")
FileWriteLine("ACCOUNTS.txt", $linewrite)
Wend
FileClose($file)
exit

Play with that for a bit let me know how it works out for you.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

LOL you guys beat me to it, but there are some bugs... I just added the filewriteline() and it kept adding lines :-P Lots of them so maybe try writing it to a new file...

$g_szVersion = "Test 1.0"
If WinExists($g_szVersion) Then Exit; It's already running
AutoItWinSetTitle($g_szVersion)


$file = FileOpen("ACCOUNTS.txt", 0)

While 1
$line = FileReadLine($file)
If @error = -1 Then ExitLoop
$linewrite = StringReplace($line," ",":")
FileWriteLine("ACCOUNTS1.txt", $linewrite)
Wend
FileClose($file)
exit

It works...

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

yeah, i ran that first one, and it copied my list to itself, in the new edited version.. with the colon.. over and over. the file was HUGE lol

SECOND version works great

TY!

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

YW :) I got same on the first :-P second just makes a new file for you :)

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

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