Shinies Posted October 3, 2005 Share Posted October 3, 2005 Hey, i have been trying to get the text inside a .txt file, and storing it into a $var. I was using this code to test if it would work $fileread = FileOpen("123.txt", 0) If $fileread = -1 Then Exit EndIf While 1 $txt = FileRead($fileread, 1) If @error = -1 Then ExitLoop Wend FileClose($fileread) Run("Notepad.exe") WinWaitActive("Untitled - Notepad") Send($txt) But all it writes to the notepad is "¼" ..? is there another function i can use to accomplish this? or is there another way to do this? plz help thanks -Smirk Link to comment Share on other sites More sharing options...
sykes Posted October 3, 2005 Share Posted October 3, 2005 Try The Following: $file = FileOpen("test.txt", 0) $cnt = FileGetSize("Test.txt") If $file = -1 Then Exit EndIf $txt = FileRead($file, $cnt) ClipPut($txt) FileClose($file) Run("Notepad.exe") WinWaitActive("Untitled - Notepad") ;Send($txt);Uncomment this line to send the text one character at a time ;Send("^v");Uncomment this line to paste the text into notepad all at once We have enough youth. How about a fountain of SMART? Link to comment Share on other sites More sharing options...
w0uter Posted October 3, 2005 Share Posted October 3, 2005 why not just use $txt = FileRead('test.txt', FileGetSize('test.txt')) If @error then Exit clipput($txt) 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...
jefhal Posted October 3, 2005 Share Posted October 3, 2005 why not just use$txt = FileRead('test.txt', FileGetSize('test.txt'))If @error then Exitclipput($txt)and... if you'd like to read just one line at a time, check out: FileReadLine ( filehandle or "filename" [, line] ) ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
Shinies Posted October 4, 2005 Author Share Posted October 4, 2005 The first one worked perfectly, i spose where i went wrong was not getting the file size? anyways, thank you so much for your help -Smirk 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