problems with "substitute" function

  • Follow


FMP7 on Mac OS X

I am trying to do a scripted find.  The 'find' text may have " 
characters in it, so these have to be escaped to avoid them being 
interpreted as special sharacters.  This applies even if the 'find' text 
begins with "==".  So the correct thing seemed to be to use a 
'substitute' function to prepend a backslash character to the double 
pips.  But I can't get the 'substitute' to work  - it just does nothing. 
  This is what I have used:

Substitute ( Saved Comments ; "\"" ; "\\\"" )

The search field is a double pip, escaped.

The replace field is an excaped backslah, followed by an escaped double pip.

Any suggestions what I am doing wrong?

thanks

0
Reply Luke 1/23/2005 12:47:30 PM

The calc that you provide:
	Substitute ( Saved Comments ; "\"" ; "\\\"" )
works for me with no problem.

So your script should go into find mode, set the search field to 
Substitute ( Saved Comments ; "\"" ; "\\\"" ), and then perform the find.

On the other hand, I'm not sure why you need to go to such "trouble".

I have text in a field that reads:  [what did the "dog" do?]
I perform a find on that field using: [the "dog" do]
The brackets above are only used for clarity in reading this posting; 
they were not used in my actual test.

Found it with no problem, no escape characters, no substitute functions, 
no nuttin.





Luke Siemaszko wrote:
> FMP7 on Mac OS X
> 
> I am trying to do a scripted find.  The 'find' text may have " 
> characters in it, so these have to be escaped to avoid them being 
> interpreted as special sharacters.  This applies even if the 'find' text 
> begins with "==".  So the correct thing seemed to be to use a 
> 'substitute' function to prepend a backslash character to the double 
> pips.  But I can't get the 'substitute' to work  - it just does nothing. 
>  This is what I have used:
> 
> Substitute ( Saved Comments ; "\"" ; "\\\"" )
> 
> The search field is a double pip, escaped.
> 
> The replace field is an excaped backslah, followed by an escaped double 
> pip.
> 
> Any suggestions what I am doing wrong?
> 
> thanks
> 

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg              (818) 883-2846
FM Pro Solutions       Los Angeles, California

FileMaker 7 Certified Developer
Associate Member, FileMaker Solutions Alliance
0
Reply Howard 1/23/2005 6:53:49 PM



Howard Schlossberg wrote:
> The calc that you provide:
>     Substitute ( Saved Comments ; "\"" ; "\\\"" )
> works for me with no problem.
> 
> So your script should go into find mode, set the search field to 
> Substitute ( Saved Comments ; "\"" ; "\\\"" ), and then perform the find.
> 
> On the other hand, I'm not sure why you need to go to such "trouble".
> 
> I have text in a field that reads:  [what did the "dog" do?]
> I perform a find on that field using: [the "dog" do]
> The brackets above are only used for clarity in reading this posting; 
> they were not used in my actual test.
> 
> Found it with no problem, no escape characters, no substitute functions, 
> no nuttin.
> 

errrrrr.....
I am doing a scripted find.  Initially it was falling over some records 
- "no records found" when I knew perfectly well it should have found 
some.  Investigation showed that it was going wrong when the field 
contained characters such as =,",? etc.  So I fixed it by prefixing the 
search string with ==.  This almost works, but still falls over when the 
field contains ".  So the solution must be to use the 'substitute' 
function to replace " with \".  But it just doesn't work.  I can 
demonstrate that 'substitute' works with alpha characters, but when I 
try to get to seach for " and replace it with ANYTHING it just fails.

nb this is using 'substitute' in a calculated field, I wonder if it 
behaves diffferently in a script.

nb 2 - are you on the same platform as me?

cheers










> 
> 
> 
> 
> Luke Siemaszko wrote:
> 
>> FMP7 on Mac OS X
>>
>> I am trying to do a scripted find.  The 'find' text may have " 
>> characters in it, so these have to be escaped to avoid them being 
>> interpreted as special sharacters.  This applies even if the 'find' 
>> text begins with "==".  So the correct thing seemed to be to use a 
>> 'substitute' function to prepend a backslash character to the double 
>> pips.  But I can't get the 'substitute' to work  - it just does 
>> nothing.  This is what I have used:
>>
>> Substitute ( Saved Comments ; "\"" ; "\\\"" )
>>
>> The search field is a double pip, escaped.
>>
>> The replace field is an excaped backslah, followed by an escaped 
>> double pip.
>>
>> Any suggestions what I am doing wrong?
>>
>> thanks
>>
> 

0
Reply Luke 1/23/2005 10:55:52 PM

Okay, I didn't understand that you had other symbols and that you needed 
to use the == .

You are trying this in a calc field, which worked for me using your 
calc.  Ar eyou saying the result of the calc field is incorrect (if you 
place the field on the layout and look at it in browse mode)?  Are you 
sure the result is set to be text and it is unstored?

Regardless, here's my script, which works on Win FM7v3:

# Set field contents from the current record to a global
Set Field [ test::global; test::Description ]
Enter Find Mode [ ]
# Now that we're in find mode, take the global,
# perform the calc on it to escape the quotes, and add the "=="
Set Field [ test::Description; "==" & Substitute(test::global; "\""; 
"\\\"") ]
Perform Find [ ]



Luke Siemaszko wrote:
> 
> 
> Howard Schlossberg wrote:
> 
>> The calc that you provide:
>>     Substitute ( Saved Comments ; "\"" ; "\\\"" )
>> works for me with no problem.
>>
>> So your script should go into find mode, set the search field to 
>> Substitute ( Saved Comments ; "\"" ; "\\\"" ), and then perform the find.
>>
>> On the other hand, I'm not sure why you need to go to such "trouble".
>>
>> I have text in a field that reads:  [what did the "dog" do?]
>> I perform a find on that field using: [the "dog" do]
>> The brackets above are only used for clarity in reading this posting; 
>> they were not used in my actual test.
>>
>> Found it with no problem, no escape characters, no substitute 
>> functions, no nuttin.
>>
> 
> errrrrr.....
> I am doing a scripted find.  Initially it was falling over some records 
> - "no records found" when I knew perfectly well it should have found 
> some.  Investigation showed that it was going wrong when the field 
> contained characters such as =,",? etc.  So I fixed it by prefixing the 
> search string with ==.  This almost works, but still falls over when the 
> field contains ".  So the solution must be to use the 'substitute' 
> function to replace " with \".  But it just doesn't work.  I can 
> demonstrate that 'substitute' works with alpha characters, but when I 
> try to get to seach for " and replace it with ANYTHING it just fails.
> 
> nb this is using 'substitute' in a calculated field, I wonder if it 
> behaves diffferently in a script.
> 
> nb 2 - are you on the same platform as me?
> 
> cheers
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>>
>>
>>
>>
>> Luke Siemaszko wrote:
>>
>>> FMP7 on Mac OS X
>>>
>>> I am trying to do a scripted find.  The 'find' text may have " 
>>> characters in it, so these have to be escaped to avoid them being 
>>> interpreted as special sharacters.  This applies even if the 'find' 
>>> text begins with "==".  So the correct thing seemed to be to use a 
>>> 'substitute' function to prepend a backslash character to the double 
>>> pips.  But I can't get the 'substitute' to work  - it just does 
>>> nothing.  This is what I have used:
>>>
>>> Substitute ( Saved Comments ; "\"" ; "\\\"" )
>>>
>>> The search field is a double pip, escaped.
>>>
>>> The replace field is an excaped backslah, followed by an escaped 
>>> double pip.
>>>
>>> Any suggestions what I am doing wrong?
>>>
>>> thanks
>>>
>>
> 

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg              (818) 883-2846
FM Pro Solutions       Los Angeles, California

FileMaker 7 Certified Developer
Associate Member, FileMaker Solutions Alliance
0
Reply Howard 1/24/2005 2:08:43 AM


Howard Schlossberg wrote:

> Okay, I didn't understand that you had other symbols and that you needed 
> to use the == .
> 
> You are trying this in a calc field, which worked for me using your 
> calc.  Ar eyou saying the result of the calc field is incorrect (if you 
> place the field on the layout and look at it in browse mode)?  Are you 
> sure the result is set to be text and it is unstored?
> 
The field is calculated and is a global, yes it definitley set to be 
text.  'Substitute' with alphanumeric characters works just as you'd 
expect it to. But if I ask it to substitute \" it just does nothing.

> Regardless, here's my script, which works on Win FM7v3:
> 
> # Set field contents from the current record to a global
> Set Field [ test::global; test::Description ]
> Enter Find Mode [ ]
> # Now that we're in find mode, take the global,
> # perform the calc on it to escape the quotes, and add the "=="
> Set Field [ test::Description; "==" & Substitute(test::global; "\""; 
> "\\\"") ]
> Perform Find [ ]
> 

I will certainly try it in a script rather than calculated field and see 
if that makes any difference.  Also I have fielmaker support at the 
moment (I think) so I may as well call them!  I'll let you know how I 
get on.  May not be for a couple of days.

0
Reply Luke 1/24/2005 11:40:40 PM

GOT IT

The issues is, exactly *which* double pips am I looking for?  What 
happens is, when I type a double-pip character into a filemaker field in 
browse mode I will get a certain character - I don't know exactly which one.
When I type a double-pip character (using the same key on the keyboard) 
into a formula in Filemaker script editor I GET A DIFFERENT CHARACTER. 
You wouldn't notice to look at it - nothing visually striking.  But if I 
do a "substitute" using a double pip typed in, it doesn't do anything 
when it sees a double pip in the data.  But if I cut and paste the 
double-pip character from the data into the formula, IT WORKS.

I think I get a medal for finding that.

Can I be bothered to tell filemaker?

Byeeeee.........

0
Reply Luke 1/25/2005 10:33:40 PM

In article <8PzJd.446$a24.294@newsfe3-gui.ntli.net>, Luke Siemaszko
<no.spam.for.me@please.com> wrote:

> GOT IT
> 
> The issues is, exactly *which* double pips am I looking for?  What 
> happens is, when I type a double-pip character into a filemaker field in 
> browse mode I will get a certain character - I don't know exactly which one.
> When I type a double-pip character (using the same key on the keyboard) 
> into a formula in Filemaker script editor I GET A DIFFERENT CHARACTER. 
> You wouldn't notice to look at it - nothing visually striking.  But if I 
> do a "substitute" using a double pip typed in, it doesn't do anything 
> when it sees a double pip in the data.  But if I cut and paste the 
> double-pip character from the data into the formula, IT WORKS.
> 
> I think I get a medal for finding that.
> 
> Can I be bothered to tell filemaker?
> 
> Byeeeee.........

Where did the data come from originally? If it's been imported from
then it's possible that it uses the wrong character that only looks
like a ".



Helpful Harry                   
Hopefully helping harassed humans happily handle handiwork hardships  ;o)
0
Reply Helpful 1/25/2005 11:57:05 PM

Sorry, medals for this can only be self-awarded.  The quotes you have in 
your data are apparent "smart" (curly) quotes, which are entriely 
different characters then the regular double-quote.  You can substitute 
for these by copying the quote from your data field and pasting it into 
the calculation window to use as your substitute character.  Note that 
the opening smart quotes are different from the closing smart quotes, 
which are different from the regular double-quotes.

Luke Siemaszko wrote:
> GOT IT
> 
> The issues is, exactly *which* double pips am I looking for?  What 
> happens is, when I type a double-pip character into a filemaker field in 
> browse mode I will get a certain character - I don't know exactly which 
> one.
> When I type a double-pip character (using the same key on the keyboard) 
> into a formula in Filemaker script editor I GET A DIFFERENT CHARACTER. 
> You wouldn't notice to look at it - nothing visually striking.  But if I 
> do a "substitute" using a double pip typed in, it doesn't do anything 
> when it sees a double pip in the data.  But if I cut and paste the 
> double-pip character from the data into the formula, IT WORKS.
> 
> I think I get a medal for finding that.
> 
> Can I be bothered to tell filemaker?
> 
> Byeeeee.........
> 

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg              (818) 883-2846
FM Pro Solutions       Los Angeles, California

FileMaker 7 Certified Developer
Associate Member, FileMaker Solutions Alliance
0
Reply Howard 1/26/2005 12:53:00 AM


Helpful Harry wrote:

> In article <8PzJd.446$a24.294@newsfe3-gui.ntli.net>, Luke Siemaszko
> <no.spam.for.me@please.com> wrote:
> 
> 
>>GOT IT
>>
>>The issues is, exactly *which* double pips am I looking for?  What 
>>happens is, when I type a double-pip character into a filemaker field in 
>>browse mode I will get a certain character - I don't know exactly which one.
>>When I type a double-pip character (using the same key on the keyboard) 
>>into a formula in Filemaker script editor I GET A DIFFERENT CHARACTER. 
>>You wouldn't notice to look at it - nothing visually striking.  But if I 
>>do a "substitute" using a double pip typed in, it doesn't do anything 
>>when it sees a double pip in the data.  But if I cut and paste the 
>>double-pip character from the data into the formula, IT WORKS.
>>
>>I think I get a medal for finding that.
>>
>>Can I be bothered to tell filemaker?
>>
>>Byeeeee.........
> 
> 
> Where did the data come from originally? If it's been imported from
> then it's possible that it uses the wrong character that only looks
> like a ".
> 

Absolutely definitely it was manually typed in to Filemaker.


0
Reply Luke 1/26/2005 7:22:25 AM

8 Replies
203 Views

(page loaded in 0.122 seconds)

Similiar Articles:













7/25/2012 5:37:11 AM


Reply: