New topic: 

Editing Files

<http://forums.realsoftware.com/viewtopic.php?t=45219>

         Page 1 of 1
   [ 3 posts ]                 Previous topic | Next topic          Author  
Message        Menachemt          Post subject: Editing FilesPosted: Sun Sep 
02, 2012 4:14 pm                         
Joined: Sun Sep 02, 2012 1:23 pm
Posts: 3                Hello. I have made a FolderItem that already has the 
value of a file I am targeting. Now the problem is, I want to make it so that 
if a certain checkbox is checked, then edit the file. What I mean is, I have:
If Checkbox1.value Then
  //I have no idea what to put here
End If

In the If statement, I want it to take the FolderItem, and find and replace 
words in it. Is that possible? If it is impossible, is there an alternative? 
Thanks!    
                             Top                DaveS          Post subject: 
Re: Editing FilesPosted: Sun Sep 02, 2012 4:28 pm                               
  
Joined: Sun Aug 05, 2007 10:46 am
Posts: 4067
Location: San Diego, CA                Are you trying to write a word-processor?
or just load the contents of the file and replace some text in it?

dim inp_txt as textinputstream
dim out_txt as textoutputstream
//
inp_txt=textinputstream.open(f) ' where f is your folderitem
s=inp.txt.readall
inp.txt.close
s=replaceall(s,"old word","new word")
out_txt=textoutputstream.create(f)
out_txt.write s
out_txt.close


Illustration purposes only.  There is no error checking etc...      
_________________
Dave Sisemore
MacPro, OSX 10.7.3 RB2011r3
Note : I am not  interested in any solutions that involve custom Plug-ins of 
any kind  
                             Top                Menachemt          Post 
subject: Re: Editing FilesPosted: Sun Sep 02, 2012 4:48 pm                      
   
Joined: Sun Sep 02, 2012 1:23 pm
Posts: 3                I am just trying to load the file and replace some text 
in it. Is that what the code you gave me does? It looks like it. I'm gonna give 
it a go. Thanks!

EDIT: Yes, I did fix when you put inp.txt.close and inp.txt.readall() but when 
I run it, it gives me an error on this line:
s=inp_txt.readall()
and it tells me Expected Textinputstream, got string.
How would I fix this? Also, what do you mean "Illustration purposes only. No 
error checking"? Thanks!   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 3 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to