Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 9:05 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: File object Quetion
PostPosted: October 15th, 2010, 6:12 pm 
Offline

Joined: September 11th, 2006, 2:38 pm
Posts: 125
Hi all
please can you help me finding a function that replace a word in mytext.txt ?

I know how to do it in TextObject.ReplaceSelection("What I want to replace")
But how i replace it in the file ?

_________________
Win windows 7
Opus Pro 9.5


Top
 Profile  
 
 Post subject: Re: File object Quetion
PostPosted: October 16th, 2010, 7:47 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
OL,
Maybe I can suggest a few of the 'pieces'.

I think there is not a specific, ready-made OpusScript function that will surgically find and replace a word within a text file. However you can make one.

My understanding of Windows is that even if you are going to replace only one Word in a file, essentially you are going to Read the whole file back, change it, and Write the whole file. So that is what I think you have to construct for your purposes here.

What I suggest is you Read file and Write file. In between, you simply set that read to a variable (string).
Here is what I suggest you use to do the 'find' & 'replace':
viewtopic.php?f=4&t=3745&hilit=join see the Post from Mackavi on August 30th, 2009, 8:43 am

There are other OpusScript functions you could use, such as 'FindText()' or 'FindTextInSelection()', which are essentially string manipulations... that may help you here, but you are still bringing in the whole contents of the file anyway.

Is this what you are after?

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject: Re: File object Quetion
PostPosted: October 16th, 2010, 9:33 pm 
Offline

Joined: November 11th, 2004, 4:05 am
Posts: 636
Location: Christchurch, NZ
The easy part is replacing a word in a string.
The hard part (difficulty depending on the file structure) is loading the words into Opus...
If the file contains just a list of words separated by returns, tabs or commas, you can load each word into an array and replace whatever you like, but if you are talking about replacing words in a paragraph or phrase and keeping the formatting it will be considerably more difficult...

I'd suggest finding a grep like utility you can launch from Opus, there must be one around that will do what you want...
With Opus 7's ability to load DLL's, you could also make (or find) a DLL that would do the job for you.

Paul


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group