Heathbo Posted January 8, 2005 Posted January 8, 2005 I have this script that checks to see if a certain value is in a text field(test field). It will run 1 of 4 scripts based on whats in the test field. Essentially the script just goes to a container and copies the contents and paste it into another container. There are 15 test fields titled MovTest1 - MovTest15, and 15 container fields for the scripts to paste in, with names that corispond to the test fields ie. Mov1 - Mov15. Here is what I have. If[Data Files::MovTest1 = "OLD" Perform Script ["OLD"] Paste[select; Data Files::Mov1] end if If[Data Files::MovTest1 = "NEW" Perform Script["NEW"] Paste[select; Data Files::Mov1] end if If[Data Files::MovTest1 = "Action" Perform Script["Action"] Paste[select; Data Files::Mov1] end if If[Data Files::MovTest1 = "Drama" Perform Script["Drama"] Paste[select; Data Files::Mov1] end if This script has to be performed on all 15 fields. Because the script is field specific, does it have to be rewritten for each field. Is there a way to write the script once and have it loop through all the fields? Also, is there an easier way to do this, or a way to simplify this? Thanks for your time Heath
Søren Dyhr Posted January 8, 2005 Posted January 8, 2005 I would like to question this: Because the script is field specific, does it have to be rewritten for each field. ...have you thought of scriptparameters, as well as GetField( : Further more is it naugty to use copy and paste since it says - To heck with what the user might have hidden in the clipboard. Programmer/developers don't do that! One more thing can a movie be several categories?? If not then don't use "End If" but instead "else if" it's waste to test for something that isn't likely when match already is made. --sd
Heathbo Posted January 8, 2005 Author Posted January 8, 2005 What are scriptparameters? How does GetField work? What the scripts titled "OLD", "NEW", etc. do is go to a container with an image in it and copy it. Then the this script paste it in the appropriate container. Can I use the set field command on a container with images? I never thought about copy and pasting like that before, thanks, I'm a newbe at this so I'm not familiar with whats proper scripting and whats not.
Søren Dyhr Posted January 8, 2005 Posted January 8, 2005 How does GetField work? Well take a look here: http://www.fmforums.com/threads/showflat.php/Cat/0/Number/75768/Main/53693 Meanwhile do I seek a similar well written explanation regarding "ScriptParameters" ...But try this for starters: http://www.coresolutions.ca/filemaker/issue/26/parameters.php --sd
Heathbo Posted January 9, 2005 Author Posted January 9, 2005 I'm starting to understand the Get Field function but I have a few questions I rewrote the script to look like this Set Field [Data Files::MovTemp; MT0] If[(GetField (Data Files::MovTemp) & "Test1" = "OLD" Set Field [Data Files::(GetField (Data Files::MovTemp) & "Symbol"; Data Files::Red Circle] end if If[(GetField (Data Files::MovTemp) & "Test1" = "NEW" Set Field [Data Files::(GetField (Data Files::MovTemp) & "Symbol"; Data Files::Blue Circle] end if If[(GetField (Data Files::MovTemp) & "Test1" = "Action" Set Field [Data Files::(GetField (Data Files::MovTemp) & "Symbol"; Data Files::Green Circle] end if If[(GetField (Data Files::MovTemp) & "Test1" = "Drama" Set Field [Data Files::(GetField (Data Files::MovTemp) & "Symbol"; Data Files::Yellow Circle] end if Everything is working except I can't get the computer to recognize the & "Test1" part. It sees the MovTemp with no problem. Basically in the if statement directly above I want the the computer to check the "MT0 Test1" field. The script will continue to re set the MovTemp field with the name of the next field to check. Am I going about this all wrong. How else do I format this, rather than having end ifs all through the script. You mentioned else. Where would I put that? Thanks for being patient with me on this.
Søren Dyhr Posted January 9, 2005 Posted January 9, 2005 except I can't get the computer to recognize the & "Test1" part. In my humble opinion is it a syntactical error - Don't mean e.g. If(GetField(Data Files::MovTemp) and Data Files::Test1 = "Action") What you tried was a concatation which always would end on ....Test1 and this will never meet the string "Action". Then have the "end if" been continued... couldn't you at least put an "Exit Script" into each condition, so daft testings are avoided?? --sd
Heathbo Posted January 9, 2005 Author Posted January 9, 2005 In my humble opinion is it a syntactical error - Don't mean e.g. If(GetField(Data Files::MovTemp) and Data Files::Test1 = "Action") What you tried was a concatation which always would end on ....Test1 and this will never meet the string "Action". --sd How do I script it so it will look at the MT0 Test1 field and then when it runs again I can set MovTemp to MT1 so it will then look at the MT1 Test1 field and so on and so. The only thing that changes in the Test1 fields is the number after MT. Thanks again.
Søren Dyhr Posted January 10, 2005 Posted January 10, 2005 If[(GetField (Data Files::MovTemp) & "Test1" = "OLD" Ah!!! thats what you're getting at: .....If[GetField ( Data files::MovTemp & " Test1") = "OLD"] It's pretty important to notice the <space> just after the ampersand inside the quotes!!! But the task in it self puzzels me though, why script this?? Since no one seaches in containerfields when it doesn't make sence - directly in a quicktime, doesn't it matter if it just shows up in an unstored calcfield unindexed, instead of the commotion to copy it perhaps to 3 or 4 destination. I would do it by making the calc's include the 15 conditions and if met would the calcfield pull the movie from the field where it's stored initially. The calc does obviously need to have to be container as resulttype!!! --sd
Heathbo Posted January 10, 2005 Author Posted January 10, 2005 I would do it by making the calc's include the 15 conditions and if met would the calcfield pull the movie from the field where it's stored initially. The calc does obviously need to have to be container as resulttype!!! --sd How would I script this in a calc field? Would the calc field be the container field with were the image was being pasted into or set into. Since there isn't a set command in the calc window, how do you do this?
Søren Dyhr Posted January 10, 2005 Posted January 10, 2005 No not scripting at all... Well we might not be speaking of the same but I've made a template for you that kind of makes "Conjunction - conjunction whats your function" ...which migh be what you're after or not. At least comment it so I can get a grip of what you want. movemovie.zip
Heathbo Posted January 10, 2005 Author Posted January 10, 2005 Thank you soo much for the attachment! I can not believe how much harder I was making it. What you did in your attachment is exactly what I need, and its much simpler than what I was doing. Plus it requires less fields. Thank you so much.
Recommended Posts
This topic is 7259 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