Slobey Posted December 19, 2005 Posted December 19, 2005 I have a script that is looking for a pattern count in a global and if found, will flag that record. It seems to work except for similar records. If the string I am looking for is 1200A and the record contains 1200 it flags it. I don't want it to. My current script is as follows: if [ patterncount(global;record)] Set Field[flag;"Yes"] meaning if the contents of the record field is in the global field, flag it. But I want it to flag it only if the exact match is found. How do I do that? Thanks
Ender Posted December 19, 2005 Posted December 19, 2005 Try swapping those parameters: If [ paterncount( record; global ) ] The first argument is the text to search and the second is the search string.
Slobey Posted December 19, 2005 Author Posted December 19, 2005 Sorry, I just typed it wrong in the box here. That is how it is in the script.
Ender Posted December 19, 2005 Posted December 19, 2005 Then perhaps you can give an example of the data in the record field and an example of the search text, along with what the result of the patterncount returns. The use of patterncount() implies that there is more than just "1200" in that record field, otherwise you could just use an = to compare them.
Slobey Posted December 19, 2005 Author Posted December 19, 2005 It is part of a loop. it goes through the records and if the contents of the record field are in the global it flags it. The 1200 is not a static number, it changes from record to record. Each one is checked against the field so where would I put the = ?
Ender Posted December 20, 2005 Posted December 20, 2005 If [ record = global ] If you want a case-sensitive match, use the exact function: If [ exact(record;global) ] Alternatively, the Flag could be calculated based on this: flag (calculation, text result) = case(record=global;"Yes") Or if the point of setting the Flag was just to mark the records for a subsequent find, it would be better to use a self-join relationship between global and record, and a Go to Related Records[ Show ] script step. This would avoid the whole marking operation all together. There's many different ways to flag records and change found set, it just depends on what the purpose is.
Slobey Posted December 20, 2005 Author Posted December 20, 2005 I really appreciate the help Ender! I don't think the exact function or a self join will work. I have not done a good job explaining my situation so I will try to make more sense. The global field is a list of model numbers. It has alot of numbers in it. They are separated by a carriage return. some of the numbers have a letter extension, hence the 1200A and the 1200. I want to check each individual record against this list. If the record exists, then everything is ok. If it is not in the list, then I want to add it to the list and set the flag field. So the records Model number won't be an exact match to the global field. The model number is not unique to one record, it can be in many records. As I said before the script I have has worked fine except for the letter extensions. If the first record found is 1200A, then when the record with 1200 is checked, it finds it in the list using the patterncount. If the first record is 1200 then the 1200A won't be found. Have I confused you yet?
Ender Posted December 20, 2005 Posted December 20, 2005 Have I confused you yet? A long time ago. I have no idea what you're doing or why, sorry.
Fenton Posted December 20, 2005 Posted December 20, 2005 I would use a self-join. You can match the entire global against the key field with Go To Related Record [show], then Show Omitted (or make the relationship <>). Those are the records that are not in the list. Loop to flag the records, and add each to the original global. [sorry, didn't see that Ender already suggested this, at the end of his earlier post.]
comment Posted December 20, 2005 Posted December 20, 2005 If ultimately you want to add all items to the list, why not simply make a value list using values from the field? In any case, the test you want can be written as: If [ Position ( ¶ & list & ¶ ; ¶ & item & ¶ ; 1 ; 1 ) ]
Søren Dyhr Posted December 20, 2005 Posted December 20, 2005 If some of the fieldvalues carry a postfix a, shouldn't the fieldtype be number but text ...this might be the source for unreliable selections, but tagging a set of records is also in my book a very unhealthy way to esablish af found set Enders method with a selfjoin is much more healthy. What it really is, is that you're going to store redundant data, that even have a syncronization problem attached, what happens if the cleaning lady unplugs your machine while at it with the tagging??? Saving searches for future use, is much better achieved this way if the selfjoining makes your stomach turn: http://www.filemakermagazine.com/modules.php?op=modload&name=News&file=article&sid=544 --sd
Slobey Posted December 20, 2005 Author Posted December 20, 2005 Thank you so much comment, it worked perfectly. I realize my logic behind this is not clear but believe me there is a good reason for my madness, I just can't articulate it very well. Thanks again to all of you for your time and effort, I really do appreciate it!
Fenton Posted December 20, 2005 Posted December 20, 2005 I agree with Søren, that it's better to avoid flagging and synchronization if possible. Another question is why the model numbers are in a global field? If the Models are in another table there is another way with version 8,* which is to create a relationship on the Model# from one table to the other, and use the "Match all records in current found set" option in the Go To Related Records dialog. *In version 7 you can do much the same thing by doing an Import, with Update Matching on the key, importing a dummy global (ie., not really importing).
Recommended Posts
This topic is 6915 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now