Filemaker: различия между версиями
Hoe83yarn (обсуждение | вклад) |
Hoe83yarn (обсуждение | вклад) |
||
| Строка 1: | Строка 1: | ||
| − | + | Haystack - This parameter holds the whole string to research: the proverbial Haystack in which to discover and change the Needle, if you will. | |
| + | Perform Human body: | ||
| + | Situation( PatternCount( Haystack Needle ) > | ||
| − | + | Swap( Haystack Posture( Haystack Needle 1 1 ) Size( Needle ) Substitute ) | |
| − | + | Haystack) | |
| − | + | Utilizing the developed-in Circumstance operate (given that there are only two cases, the If function could be utilised in this article as well), we take a look at for the existence of Needle within Haystack with the created-in PatternCount function: | |
| − | + | PatternCount ( Haystack Needle )>0 For the correct scenario, we print the final results of the constructed-in Change(textstartnumberOfCharactersreplacementText) purpose. | |
| − | + | Substitute ( Haystack Posture ( Haystack Needle one one ) Length ( Needle ) Substitution ) The replacement inside of Haystack begins at the posture of the initially instance of Needle and extends the amount of characters of Needle and is changed by Replacement. | |
| − | + | For the bogus or default circumstance, we simply print Haystack because there is no Needle to replace. | |
| − | + | World-wide Research and Exchange Purpose | |
| − | + | Purpose Title: String Change | |
| + | Parameters: | ||
| − | + | Needle - This parameter represents the substring for which we wish to research. | |
| − | + | Substitute - This retains the string that will exchange the substring in Needle. | |
| − | |||
| − | + | Haystack - This parameter retains the complete string to search: the proverbial Haystack in which to locate and replace the Needle, if you will. | |
| − | + | Functionality Human body: | |
| + | |||
| + | If( PatternCount( Haystack Needle ) > | ||
| + | |||
| + | Permit( pos = Posture( Haystack Needle one one ) + Duration( Needle ) | ||
| + | |||
| + | Let( | ||
| + | |||
| + | [ HaystackBegin = Scenario( pos > Remaining( Haystack pos - 1 ) "" ) | ||
| + | |||
| + | HaystackEnd = Middle ( Haystack pos Duration( Haystack ) - pos + 1 ) | ||
| + | |||
| + | ] | ||
| + | |||
| + | String Substitute( Needle Alternative HaystackBegin ) & String Change All( Needle Alternative HaystackEnd ) | ||
| + | |||
| + | ) | ||
| + | |||
| + | ) | ||
| + | |||
| + | Haystack) Our base problem in this article is a Haystack with cases of Needle. Below we just output the Haystack. | ||
| + | |||
| + | For a defining affliction, when Haystack has additional than situations of Needle (it can never ever have a unfavorable quantity of situations, of training course), we substitute the initially instance and contact this operate recursively with the remaining Haystack. With every single get in touch with, there will be one much less Needle in the Haystack, right up until the base problem is attained exactly where Needles exist in the Haystack. | ||
| + | |||
| + | Working with the designed-in If functionality, we do a exam for a non-base issue which is a Haystack with one or far more instance of Needle. | ||
| + | |||
| + | PatternCount( Haystack Needle ) > The explanation we do not exam specifically for the base affliction (i.e.PatternCount ( Haystack Needle ) = ), is that in some situations, these kinds of as when Haystack is empty, the PatternCount function may well return an undefined benefit, which is neither nor higher than , but really should final result in a base situation return. | ||
| + | |||
| + | If the issue is true, there are Needles in the Haystack, so we established these variables: | ||
| + | |||
| + | |||
| + | pos = Placement( Haystack Needle 1 1 ) + Size( Needle ) - The character position in Haystack promptly pursuing the 1st instance of Needle. | ||
| + | HaystackBegin = Circumstance( pos > Left( Haystack pos - one ) "" ) - The content material of the Haystack string up to position pos. This string will incorporate exactly a single instance of Needle | ||
| + | HaystackEnd = Middle( Haystack pos Size(Haystack) - pos + one ) - The remaining content of Haystack that contains 1 significantly less occasion of Needle. | ||
| + | Then, we print the final result of HaystackBegin with its solitary instance of Needle replaced and concatenated(&) with the recursive get in touch with to String Substitute All with the remaining Haystack. | ||
| + | |||
| + | [http://www.iccup.com/dota/content/blogs/hosting_03.html hosting], [http://media.katgraham.net/read_blog// filemaker], [http://karahanyuze.com/read_blog/53986/filemaker filemaker] | ||
Версия 19:03, 13 апреля 2013
Haystack - This parameter holds the whole string to research: the proverbial Haystack in which to discover and change the Needle, if you will.
Perform Human body:
Situation( PatternCount( Haystack Needle ) >
Swap( Haystack Posture( Haystack Needle 1 1 ) Size( Needle ) Substitute )
Haystack)
Utilizing the developed-in Circumstance operate (given that there are only two cases, the If function could be utilised in this article as well), we take a look at for the existence of Needle within Haystack with the created-in PatternCount function:
PatternCount ( Haystack Needle )>0 For the correct scenario, we print the final results of the constructed-in Change(textstartnumberOfCharactersreplacementText) purpose.
Substitute ( Haystack Posture ( Haystack Needle one one ) Length ( Needle ) Substitution ) The replacement inside of Haystack begins at the posture of the initially instance of Needle and extends the amount of characters of Needle and is changed by Replacement.
For the bogus or default circumstance, we simply print Haystack because there is no Needle to replace.
World-wide Research and Exchange Purpose
Purpose Title: String Change
Parameters:
Needle - This parameter represents the substring for which we wish to research.
Substitute - This retains the string that will exchange the substring in Needle.
Haystack - This parameter retains the complete string to search: the proverbial Haystack in which to locate and replace the Needle, if you will.
Functionality Human body:
If( PatternCount( Haystack Needle ) >
Permit( pos = Posture( Haystack Needle one one ) + Duration( Needle )
Let(
[ HaystackBegin = Scenario( pos > Remaining( Haystack pos - 1 ) "" )
HaystackEnd = Middle ( Haystack pos Duration( Haystack ) - pos + 1 )
]
String Substitute( Needle Alternative HaystackBegin ) & String Change All( Needle Alternative HaystackEnd )
)
)
Haystack) Our base problem in this article is a Haystack with cases of Needle. Below we just output the Haystack.
For a defining affliction, when Haystack has additional than situations of Needle (it can never ever have a unfavorable quantity of situations, of training course), we substitute the initially instance and contact this operate recursively with the remaining Haystack. With every single get in touch with, there will be one much less Needle in the Haystack, right up until the base problem is attained exactly where Needles exist in the Haystack.
Working with the designed-in If functionality, we do a exam for a non-base issue which is a Haystack with one or far more instance of Needle.
PatternCount( Haystack Needle ) > The explanation we do not exam specifically for the base affliction (i.e.PatternCount ( Haystack Needle ) = ), is that in some situations, these kinds of as when Haystack is empty, the PatternCount function may well return an undefined benefit, which is neither nor higher than , but really should final result in a base situation return.
If the issue is true, there are Needles in the Haystack, so we established these variables:
pos = Placement( Haystack Needle 1 1 ) + Size( Needle ) - The character position in Haystack promptly pursuing the 1st instance of Needle. HaystackBegin = Circumstance( pos > Left( Haystack pos - one ) "" ) - The content material of the Haystack string up to position pos. This string will incorporate exactly a single instance of Needle HaystackEnd = Middle( Haystack pos Size(Haystack) - pos + one ) - The remaining content of Haystack that contains 1 significantly less occasion of Needle. Then, we print the final result of HaystackBegin with its solitary instance of Needle replaced and concatenated(&) with the recursive get in touch with to String Substitute All with the remaining Haystack.