Jump to content

_FileWrite_Array ()


z0mgItsJohn
 Share

Recommended Posts

Hello Auto It Peoples :)... I Came Up With A Pretty Cool Function That Lets You Write The Same File More Than Once... For Say You Need To Write 5 Files With The Name Test Well My Function Would Check To See If Test(1) Exists And If It Dose Then It Writes Test(2)

~ Enjoy ~

(_File_Array.Au3 ) - _FileWrite_Array ()

Func _FileWrite_Array ($File, $File_Type, $Data, $Max)
For $File_Array = '1' To $Max
If FileExists ($File & '(' & $Max & ')' & $File_Type) Then
MsgBox ('0','Error','Maximum Amount Of Files Reached','0')
ExitLoop
EndIf 
If Not FileExists ($File & '(' & $File_Array & ')' & $File_Type) Then
FileWrite ($File & '(' & $File_Array & ')' & $File_Type, $Data)
ExitLoop
EndIf
Next
EndFunc

Please Post.. Comments.. Bugs.. Ect ;)

Latest Projects :- New & Improved TCP Chat

Link to comment
Share on other sites

I really don't get it, could you explain what it does more?

I don't think it needs Array in the function name, nothing in the function uses arrays!

Whats wrong with this?

_FileWriteFromArray()

It appears to me as though what it does is on the first time the function is called (Using test1.txt as example)

it creates test.txt and writes the data to that file. The next time it runs it discovers that test1.txt already exists so it writes the data to test2.txt and so on until the maximum (in his example 5) is reached. That would be test5.txt and the data really doesn't have anything to do with being an array. Oooooooooooops just looked at it again and the above is wrong. It's goint to take the input data and create $Max number of identical files just adding a different number to each file name.

I could be way off base here but that's how I see it and I don't see when I would ever need to create 5 identical files.

Edit: Grammar

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Heres Another Example... For Say Your Making A Program That Uses User Accounts... And You Where Useing My Function To Write The Account Info To A File... Every New Account Made Would Have A Different File Name..

Script :

#Include <_File_Array.Au3>

$Account_1_Username = ('Example')
$Account_1_Password = ('Example')
$Account_2_Username = ('Example')
$Account_2_Password = ('Example')

_FileWrite_Array ('Account','.txt','Username : ' & $Account_1_Username & @CRLF & 'Password : ' & $Account_1_Password,'5') ; This Would Write A File... Named Account(1).txt
_FileWrite_Array ('Account','.txt','Username : ' & $Account_2_Username & @CRLF & 'Password : ' & $Account_2_Password,'5') ; This Would Write A File... Named Account(2).txt

Hope This Clears It Up :)

Latest Projects :- New & Improved TCP Chat

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