tryout1 Posted July 10, 2006 Share Posted July 10, 2006 hi, How add a space after each character exemple : my txt is : MOTHER and i want write in txt : M O T H E R TX Link to comment Share on other sites More sharing options...
Zedna Posted July 10, 2006 Share Posted July 10, 2006 (edited) $file = FileOpen("test.txt", 0) $file2 = FileOpen("test2.txt", 2) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf If $file2 = -1 Then MsgBox(0, "Error", "Unable to open file2.") Exit EndIf While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop ;~ MsgBox(0, "Line original:", $line) $line = StringSplit($line,'') $line2 = '' For $i = 1 To $line[0] $line2 &= $line[$i] & ' ' Next ;~ MsgBox(0, "Line with spaces:", $line2) FileWriteLine($file2, $line2) Wend FileClose($file) FileClose($file2) EDIT: As start was used example from AutoIt Helpfile for function FileReadLine. Edited July 10, 2006 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Developers Jos Posted July 10, 2006 Developers Share Posted July 10, 2006 $text = "mother" $Ntext = "" For $x = 1 To StringLen($text) -1 $Ntext &= StringMid($text,$x,1) & " " Next $NText &= StringMid($text,$x) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Bart Posted July 12, 2006 Share Posted July 12, 2006 [autoit]$file = FileOpen("test.txt", 0) $file2 = FileOpen("test2.txt", 2) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf If $file2 = -1 Then MsgBox(0, "Error", "Unable to open file2.") Exit EndIf ....... Am I right to assume that Exit closes all open files? Or do I need to close all files explicitly? Bart Link to comment Share on other sites More sharing options...
Iznogoud Posted July 12, 2006 Share Posted July 12, 2006 Exit is for quiting the script. If you want to make the code complete/nice you add at the last closing the files. Link to comment Share on other sites More sharing options...
MHz Posted July 12, 2006 Share Posted July 12, 2006 Am I right to assume that Exit closes all open files?Or do I need to close all files explicitly?BartCheck the helpfile... RemarksIf filehandle is invalid, an AutoIt runtime error will be thrown, and the script will terminate!Upon termination, AutoIt automatically closes any files it opened--but calling FileClose is still a good idea.This function is also used to close search handles as returned by FileFindFirstFile(). Link to comment Share on other sites More sharing options...
Bart Posted July 12, 2006 Share Posted July 12, 2006 Ah! Thanks! I checked the Help, but looked at Exit and not at FileClose. Bart Link to comment Share on other sites More sharing options...
w0uter Posted July 12, 2006 Share Posted July 12, 2006 since i like small i made the space adding routine into one line $Ntext = StringTrimRight(StringRegExpReplace($text, '(.*?)*(.)', '\1 '), 1) My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Bart Posted July 12, 2006 Share Posted July 12, 2006 Check the helpfile... Ok, so I should explicitly close any open files, but how can I check if a file is open? When error handling it's not always certain the error occured after the file was opened!And there is a runtime error when I try to close a file that is not open.Bart Link to comment Share on other sites More sharing options...
Zedna Posted July 12, 2006 Share Posted July 12, 2006 since i like small i made the space adding routine into one line $Ntext = StringTrimRight(StringRegExpReplace($text, '(.*?)*(.)', '\1 '), 1)Wouter it's nice, but I think not ideal for Newbies Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now