El_Pablo Posted October 18, 2006 Posted October 18, 2006 Hi, I'm trying to set a values to calculated field names and these fields are not in the Layout, so I can't navigated through them. SetVariable[$fieldPrefix; "img"] SetVariable[$linkPrefix; "txt"] SetVariable[$firstFieldName; Get(ActiveFieldName)] SetVariable[$fieldName; $firstFieldName] Loop if (PatternCount($fieldName; $fieldPrefix) > 0) SetField[Abase:$linkPrefix & $fieldName; $XYZvalue] // This is what I'm trying to figure out end if Go to Next Field SetVariable[$fieldName; Get (ActiveFieldName)] Exit Loop If ($fieldName = $firstFieldName) End Loop The purpose is that each container is paired with a text field which contains a URL to a web image. So is there a way to programmatically set the value of a calculated field name? or a workaround? Exactly I want something like: [color:red]Set Field[TableName::$fieldName; $value] Thank you
Fitch Posted October 18, 2006 Posted October 18, 2006 FileMaker can't set fields by variables, but you can work around it using named objects. Look at the Main page of these forums, there's an article there entitled "Set Fields by Indirection!"
El_Pablo Posted October 18, 2006 Author Posted October 18, 2006 Yes, I know I checked the page, the problem is that I use FMP 8 Advanced and the function is for 8.5...
BobWeaver Posted October 19, 2006 Posted October 19, 2006 You can do it with versions back as far as 5 (or possibly earlier) if you use the kludgy method of putting a go to next field inside a loop and checking the active field name after each iteration. As for them not being on the current layout, you just have to create a utility layout with the fields on it, and have your script go to that layout first. However, I had recent thought about doing this a different way which I think is a lot cleaner, although it requires setting up the autoenter option of any fields that you want to set indirectly. See attached file. SetFieldIndirect.fp7.zip
El_Pablo Posted October 19, 2006 Author Posted October 19, 2006 I worked around displaying the fields on the layout and making them invisible. But concerning your solution and since I'm new to FM, how the Let function works? I've tried to understand, but couldn't figured how it works. And why do I see sometimes a kind of a bold "P" characters, what is the use of this one? Thank you
BobWeaver Posted October 19, 2006 Posted October 19, 2006 The Let() function allows you to define temporary variables within a calculation. It is useful if you need to use an intermediate result in several places. I used it in the example so that when you paste the formula into a new field auto-enter calculation, you only have to change a single field name. The ¶ symbol is interpreted by Filemaker as a line break. Line breaks are used to separate items in a value list. The script simply sets a global field to a two element value list. The first element is the name of the field to be set, and the second element is the data. The auto-enter formula uses LeftValues(gIndirectSetField;1) to get the field name, and RightValues(gIndirectSetField;1) to get the data. If the field name matches it's own, then its old data is replaced with the new data.
El_Pablo Posted October 20, 2006 Author Posted October 20, 2006 Thanks very much! I now have a new way to work around indirection! Nick
Recommended Posts
This topic is 6611 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