dbTalk Databases Forums  

Right Words

comp.databases.filemaker comp.databases.filemaker


Discuss Right Words in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
This Being Milt
 
Posts: n/a

Default Right Words - 12-08-2005 , 05:01 PM






I'm having some trouble replacing some text in a text field. Here's
the situation. Say I have the following in a text field.

filename.1234.xxx

I want to change this to

filename.abcd.xxx

I can use the Replace command without a problem. The issue is that
with Replace it counts from the left, and oftentimes the filenames I
want to change will be different lengths. What I need to do is start
counting from the right. However, when I use RightWords I am able to
replace the text as desired, but it returns ONLY the changed text.

Here's the script I am using.

Replace ( Right ( "1234" ; 7 ) ; 1 ; 4 ; "abcd" )

Obviously there is some boneheaded thing I am doing. Any advice?


--
"Giving money and power to government is like
giving whiskey and car keys to teenage boys."
-- P. J. O'Rourke


Reply With Quote
  #2  
Old   
Matt Wills
 
Posts: n/a

Default Re: Right Words - 12-08-2005 , 05:30 PM






This Being Milt wrote:

Quote:
I'm having some trouble replacing some text in a text field. Here's
the situation. Say I have the following in a text field.

filename.1234.xxx

I want to change this to

filename.abcd.xxx

I can use the Replace command without a problem. The issue is that
with Replace it counts from the left, and oftentimes the filenames I
want to change will be different lengths. What I need to do is start
counting from the right. However, when I use RightWords I am able to
replace the text as desired, but it returns ONLY the changed text.

Here's the script I am using.

Replace ( Right ( "1234" ; 7 ) ; 1 ; 4 ; "abcd" )

Obviously there is some boneheaded thing I am doing. Any advice?
From your description, I am seeing the "filename." and ".xxx" parts as
unchanging. If those parts are unchanging, you don't need to count
anyting. Just replace your existing value with

"filename." & NewName & ".xxx"

Where NewName = "abcd"

Does that work for you, or am I misunderstanding the problem?

Matt

--



Reply With Quote
  #3  
Old   
This Being Milt
 
Posts: n/a

Default Re: Right Words - 12-08-2005 , 06:19 PM



On 2005-12-08 15:30:21 -0800, "Matt Wills" <Im (AT) Witz (DOT) End> said:

Quote:
From your description, I am seeing the "filename." and ".xxx" parts as
unchanging. If those parts are unchanging, you don't need to count
anyting. Just replace your existing value with

"filename." & NewName & ".xxx"

Where NewName = "abcd"

Does that work for you, or am I misunderstanding the problem?
Hi Matt. Here's what I mean. In my field I have the name of various
files on our server. The files will always have totally different
names. Cosider the following examples.

ThisIsAFileName.1234.xxx
AnotherFileName.1234.xxx
INeedAFrostyBeer.1234.xxx
MyHeadHurts.1234.xxx

The parts of the file name that never change are the last seven
characters. So I need to be able to replace the 1234 in these file
names with abcd and leave the entire rest of the filename intact. Is
there any way to run the Replace function and have it count from the
right?

Thanks!


--
"Giving money and power to government is like
giving whiskey and car keys to teenage boys."
-- P. J. O'Rourke



Reply With Quote
  #4  
Old   
Dan Fretwell
 
Posts: n/a

Default Re: Right Words - 12-08-2005 , 06:55 PM



Will the following calculation do the trick, Text being the initial
contents of your field.

Left(Text;Length(text) - 8) & "abcd," & Right(text;3)


Reply With Quote
  #5  
Old   
Matt Wills
 
Posts: n/a

Default Re: Right Words - 12-08-2005 , 07:29 PM



This Being Milt wrote:

Quote:
On 2005-12-08 15:30:21 -0800, "Matt Wills" <Im (AT) Witz (DOT) End> said:

From your description, I am seeing the "filename." and ".xxx" parts
as unchanging. If those parts are unchanging, you don't need to
count anyting. Just replace your existing value with

"filename." & NewName & ".xxx"

Where NewName = "abcd"

Does that work for you, or am I misunderstanding the problem?

Hi Matt. Here's what I mean. In my field I have the name of various
files on our server. The files will always have totally different
names. Cosider the following examples.

ThisIsAFileName.1234.xxx
AnotherFileName.1234.xxx
INeedAFrostyBeer.1234.xxx
MyHeadHurts.1234.xxx

The parts of the file name that never change are the last seven
characters. So I need to be able to replace the 1234 in these file
names with abcd and leave the entire rest of the filename intact. Is
there any way to run the Replace function and have it count from the
right?

Thanks!
Actually,"1234.xxx" looks more like 8 characters.

Try this:

Left ( Filename ; Length ( Filename ) - 8) & "abcd.xxx"

Mat



Reply With Quote
  #6  
Old   
This Being Milt
 
Posts: n/a

Default Re: Right Words - 12-08-2005 , 09:03 PM



Worked like a charm, thanks!

On 2005-12-08 16:55:48 -0800, "Dan Fretwell" <dan (AT) owlsnet (DOT) co.uk> said:

Quote:
Will the following calculation do the trick, Text being the initial
contents of your field.

Left(Text;Length(text) - 8) & "abcd," & Right(text;3)

--
"Giving money and power to government is like
giving whiskey and car keys to teenage boys."
-- P. J. O'Rourke



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.