Sign in to follow this  
Followers 0
Blueman

Change txt file

9 posts in this topic

Hello,

i have just started with scripting and it looks verry nice but i have a question.

How can i by running the script change a txt file.

example

main txt file

--------------

PC-1 time1 date1

PC-2 time2 date2

new txt file after running the script

----------------------------------------

PC-1 time1 date1

PC-2 time2 date2

PC-3 time3 date3

etc..

Many thanks

Share this post


Link to post
Share on other sites



FileWriteLine("main.txt","PC-3 time3 date3")

There, that is a very simple way of doing it. You could use file handles if you want the process to be more efficient and if you want to add mass amounts of data to the txt file. Look in the help file for examples.

The Kandie Man


"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
Share on other sites

I would look at Ini* functions personally (To easily keep track of the PC#).

But, FileWrite() + @Macros will do what you are asking.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Thanks this works.

I have another question.

How can i locate the computer name ?

so that PC-1 becomes namecomputer1

Again thanks

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

@computername

FileWriteLine("main.txt",@computername & 'time3 -'& @hour & @min & @sec &' date3 -'&@year & @mon & @mday)
Edited by jokke

UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.

Share this post


Link to post
Share on other sites

Again thanks !!

I have the following code now

FileWriteLine("\\tma1-48\Software\Ultiboard\netsupport_logboek\log1.txt",@computername" -- "@MDAY"--"@MON"--"@YEAR" om "@HOUR":"@MIN":"@SEC)

but he give a error:

error in expression

What am i doing wrong here ?

thanks

Share this post


Link to post
Share on other sites

Again thanks !!

I have the following code now

FileWriteLine("\\tma1-48\Software\Ultiboard\netsupport_logboek\log1.txt",@computername" -- "@MDAY"--"@MON"--"@YEAR" om "@HOUR":"@MIN":"@SEC)

but he give a error:

error in expression

What am i doing wrong here ?

thanks

Compare yours with the others, and I bet you figure it out :whistle: .. Hint ... String & String

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

remember to use & between vars.

$x = 1
$times = 10

Do 
    $x = $x +1 
    FileWriteLine("main.txt", 'Computer_' & @computername & '_number' & $x & ' time'&$x&' -'& @hour & @min & @sec &' date'&$x&' -'&@year & @mon & @mday)
Until $x = $times
Edited by jokke

UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.

Share this post


Link to post
Share on other sites

Thanks guys !

you were verry helpfull, i remember this forum

This is a verry good forum ! :whistle:

Thanks again

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