Jump to content
Sign in to follow this  
Hyflex

Complicated script help...

Recommended Posts

Hyflex

I need the script to add make some text inside a txt file

so i have the file:

Word.txt

I want it to make the following but upto 10,000

DDS|1

DDS|2

DDS|3

DDS|4

DDS|5

DDS|6

DDS|7

DDS|8

DDS|9

and so on...

Any ideas?

Share this post


Link to post
Share on other sites
Siao

Nothing complicated. :)

$str = ""
For $i = 1 to 10000
    $str &= "DDS|" & $i & @CRLF
Next
FileWrite("Word.txt", $str)
Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites
gamepin126

$str = ""
For $i = 1 to 10000
    $str &= "DDS|" & $i
    FileWrite("Word.txt", $str)
Next

fixed it :)

The @CRLF isn't necessary cuz it'll make a new line for every invokation of filewriteline.

Edited by gamepin126

Share this post


Link to post
Share on other sites
therks

fixed it :)

The @CRLF isn't necessary cuz it'll make a new line for every invokation of filewriteline.

$str = ""
For $i = 1 to 10000
    $str &= "DDS|" & $i
    FileWriteLine("Word.txt", $str)
Next

I fixed it better. You forgot the "Line" in FileWriteLine. :)

Share this post


Link to post
Share on other sites
Siao

Anyone care to explain why it needed fixing in first place? HDD IO is slower than memory. Why open, write to file and close it 10000 times, when you can write 1?

Not to mention your fixes are buggy, because $str holds all previous lines too.

So excuse me while I rotfl :)

Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites
therks

Haha, yes you are right, of course. I wasn't even looking at that, I just saw he didn't use FileWriteLine when he specifically said he did.

Share this post


Link to post
Share on other sites
gamepin126

$str = ""
For $i = 1 to 10000
    $str &= "DDS|" & $i
    FileWriteLine("Word.txt", $str)
NextoÝ÷ ØâÅçbµ·­µêØ¢çè®
-¶ªºKwªºbX¥yjâµæËw¿lÿêº^¨Z¶«­«,xV¬µø±n[¬«­¢+ØÀÌØíÍÑÈôÅÕ½ÐìÅÕ½Ðì)½ÈÀÌØí¤ôÄѼÄÀÀÀÀ(ÀÌØíÍÑÈôÅÕ½ÐíMðÅÕ½ÐìµÀìÀÌØí¤(¥±]É¥Ñ1¥¹ ÅÕ½Ðí]½É¹ÑáÐÅÕ½Ðì°ÀÌØíÍÑȤ(%Q½½±Ñ¥À ÀÌØí¤°ÄÀ°ÄÀ¤)9áÐ

I added the tooltip just cuz I like to see stuff working. Just remove it if you want.

The reason it was holding all the previous values was because it had str &= instead of just =. I didn't even know you could do that. :)

It works fine for me.

Edited by gamepin126

Share this post


Link to post
Share on other sites
therks

Of course Siao's is still better, because as he said, it's faster to write all the data to the variable, and do ONE filewrite, than to do multiple filewrites. :)

Share this post


Link to post
Share on other sites
Hyflex

Nothing complicated. :)

$str = ""
For $i = 1 to 10000
    $str &= "DDS|" & $i & @CRLF
Next
FileWrite("Word.txt", $str)
that worked good for me, now i need another one with what i have just made i need to on the end of each line in word.txt to add the text: PnD

Share this post


Link to post
Share on other sites
Jos

that worked good for me, now i need another one with what i have just made i need to on the end of each line in word.txt to add the text: PnD

What have you tried yourself ?


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Hyflex

What have you tried yourself ?

I was looking though the ini writes.. but thats only ini.... :)

Share this post


Link to post
Share on other sites
Jos

I was looking though the ini writes.. but thats only ini.... :)

INI functions ?

Thought you wanted to add something at the end of the record written to word.txt ?

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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  

×