Sign in to follow this  
Followers 0
fi3ldy

Clear all text in TXT file

26 posts in this topic

How do i clear all of the text inside of a text file?? ive not been coding long, so im still a bit new, but struggling along successfully!

Any help appriciated, thanks!!! :P

Share this post


Link to post
Share on other sites



Hi,

just write "" to it in not append mode or delete it and create it again. :P

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

thx for reply.

how do i create it again, without fileinstall again?? thx alot :P

if cant create again using autoit, ill just have to do filedelete and file install again :D

which wownt work? will it... after its compiled and on a different system, will it beable to fileinstall again?!?!

Edited by fi3ldy

Share this post


Link to post
Share on other sites

filedelete("Your textfile.txt")
filewrite("Your textfile.txt","")

Think that should do it


My Scripts:Radioblog Club Music DownloaderOther stuff:Fun movieIm serious read the help file it helps :PFight 'Till you drop. Never stop, You Cant give up. Til you reach the top Fight! you’re the best in town Fight!

Share this post


Link to post
Share on other sites

thx alot buddy! :P

Share this post


Link to post
Share on other sites

Np im glad that i could help,


My Scripts:Radioblog Club Music DownloaderOther stuff:Fun movieIm serious read the help file it helps :PFight 'Till you drop. Never stop, You Cant give up. Til you reach the top Fight! you’re the best in town Fight!

Share this post


Link to post
Share on other sites

FileClose(FileOpen("c:\temp\test.txt", 2))


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
:P dangit plato beat me to it

Share this post


Link to post
Share on other sites

:P dangit plato beat me to it

I got roller blades for my walker for Christmas :-)

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

thx for all the help, rambo's way worked just fine for me :P

Share this post


Link to post
Share on other sites

Hi,

beware in both cases there will be created an empty file even if there wasn't a file before. Maybe you don't want that.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

HA! rambo beat you both :P

Edited by dandymcgee

- Dan [Website]

Share this post


Link to post
Share on other sites

Umm I meant for the method that plato used which is a Better then deleting then writing nothing to it.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Hi,

beware in both cases there will be created an empty file even if there wasn't a file before. Maybe you don't want that.

So long,

Mega

$path = "c:\temp\test.txt"
If FileExists($path) And FileRead($path) <> "" Then FileClose(FileOpen($path, 2))
I could make it one line, but then it would not post well... so two lines it is - even if one line might wrap in your display. :-) Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Umm I meant for the method that plato used which is a Better then deleting then writing nothing to it.

I'm glad that you figured that out... I pondered dandymcgee post a bit - but after all, he is "Valik's #1 Fan" :-)

@OP,

We know you have your solution - we are just playing - and showing you other (better?) ways to do what you asked for.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

uhhh.... EDIT!

Edited by dandymcgee

- Dan [Website]

Share this post


Link to post
Share on other sites

calm down boys, the file WILL be there anyway as its installed at the begiining of the script, also as soon as i used FileWrite i used FileWriteLine to write the title inside, basically refreshing the text doc, its for logging... :P

Share this post


Link to post
Share on other sites

the other way tends to be alot more, "simple" for my inexperienced brain to cope with atm :P

Share this post


Link to post
Share on other sites

What exactly are you implying by this? I was simply noting that Rambo had posted the first working solution,..

Nothin'.

It was the first time that I had noticed that custom title of yours. I just thought that I would mention it. I probably did not do so in the best manner.

It did take me a while to figure out your post, but I just wrote that off to my not feeling all that well that day (and not that much better today). Once Thatsgreat2345 posted, your post made sense to me.

As to what code is better... I was not willing to make any claims on that. That is why I put (better?) like I did. When the results are not critical and you can live without error checking, then a single line of code like that is "better" for my tastes... but like you said, it is really up to the OP to pick a solution from among those offered. I don't care if the one that I posted is not picked. The thread has a good title, so others may read it at some point in the future... it is nice to have a few coding options posted.

Thanks for all that you contribute to the forum - keep up the good work. Again, sorry if my post struck you wrong - it was not intended to do so.


[size="1"][font="Arial"].[u].[/u][/font][/size]

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  
Followers 0