I would assume that the layouts are based on different tables. So use the layout table to determine the left side of the string.
No problem, I am already doing this. But the thing is that I get multiple lines per module, which is unwanted.
Would there be anything wrong with using an array?
$$currentTabObjectName = STU--tab_address
$$currentTabObjectName = UNI--tab_document
$$currentTabObjectName = CON--tab_address
Then you just replace the appropriate repetition with the new value.
"Module" isn't a well-defined term here, but let's assume you're talking about layouts.
I handle this with a coded repeitition:
$$tab.Name [ Code ( Get ( LayoutName ) ) ]
How about something like the calculation below?
( Swap in values for varList, varSearchString, and varReplaceString. )
HTH & Best,
varList = "";
varSearchString = "";
varReplaceString = "";
DELIMITER = Char( 13 );
ADD_TO_LIST_IF_NO_MATCH = True;
varListLength = Length( varList );
varReplaceString = Case( IsEmpty( varSearchString ); ""; varReplaceString );
varReplaceExists = not IsEmpty( varReplaceString );
varFirstPosition = Position( varList; varSearchString; 0; 1 );
varDelimiterCount = PatternCount( Left( varList; varFirstPosition ); DELIMITER );
varIndex01 = Position( varList; DELIMITER; 0; varDelimiterCount );
varIndex02 = Position( varList; DELIMITER; varIndex01 + 1; 1 );
varLeftChars = Case( varFirstPosition; varIndex01 - ( varDelimiterCount > 0 ); varListLength );
varRightChars = Case( varFirstPosition and varIndex02; varListLength - varIndex02; 0 );
varDelimiter01 = Case( varLeftChars and varReplaceExists; DELIMITER );
varDelimiter02 = Case( varRightChars and varReplaceExists; DELIMITER; not varReplaceExists and varLeftChars and varRightChars; DELIMITER )
Left( varList; varLeftChars ) & Case( varFirstPosition or ADD_TO_LIST_IF_NO_MATCH; varDelimiter01 & varReplaceString ) & varDelimiter02 & Right( varList; varRightChars )
Thank you for the suggestion. An array with the repetition numbers you mention would suggest a field. It is too static for my purpose. I do not want to maintain the number of repetitions when a new module gets added. But it could work, surely.
Sorry about the undefined module term. Module, in my book, is 1 or more layouts, typically a form/detail and a list + possibly various printouts. So it is a logical part of the system. Often, it corresponds roughly to a TOG. It is what I use to communicate to the users which parts the systems consists of. In this case, I even use my internal 3-letter TOG name in the documentation, which I co-write with a power user.
I am not sure about what you mean by coded repetition?
Steve, thank you very much. I don't quite get the results I expected, though.
In the meantime, I got a PM with a great solution:
1: Create a new Custom Function, call it something like "ReplacePrefixedString"
2: Add a parameter called "prefix" (important!)
3: Add a parameter called "value" (important!)
4: Add a parameter called "listOfValues" (important!)
5: Copy and paste the following calculation to the custom functions calculation part
exist = PatternCount ( "¶" & listOfValues ; "¶" & prefix ) > 0;
start = Position ( "¶" & listOfValues ; "¶" & prefix ; 0 ; 1 ) + 1;
stop = Position ( "¶" & listOfValues & "¶" ; "¶" ; start ; 1 );
newList = Replace ( "¶" & listOfValues & "¶" ; start ; stop - start ; prefix & value );
newList = Left( newList; Length(newList) - 1 );
newList = Right( newList; Length(newList) - 1 )
If( exist; newList; listOfValues & If( Length(listOfValues) > 0; "¶"; "" ) & prefix & value )
What this does is that it finds the first value in listOfValues that has the given prefix and replaces that value withvalue. If no prefix is found the value will simply be added at the end of the list.
It is important that listOfValues does NOT begin or end with a linebreak! Always use this calculation for this specific task and you should be fine!
ReplacePrefixedString( "STU--"; "tab_document"; "STU--tab_address¶UNI--tab_document¶INT--tab_equipment¶CON--tab_address" )
This will replace STU--tab_address with STU--tab_document. Note that the prefix is added automaticly to the added value!
It does exactly what I was looking for.
I think this discussion could be used for stating 'best practice methods' of restoring tab selection? I have played with saving a found set too, both with and without use of FileMaker Snapshot Link. But that discussion is a little off topic, I guess.
This does not directly answer your question about your calculation, but you may find this useful for the same end result:
Works in v11 and v12.
Well, no, you can do the same thing with a variable. Doesn't have to be part of the schema; I don't know if that makes it dynamic enough for you.
Variables have repetitions. They're not as robust as true arrays but it's what FileMaker's got.
Mike's example is to us repetitions like:
My suggestion is similar, but instead of assigning a number to a module, you can use the Code() function to convert a text string (e.g. a layout name) into a number.
So a variable encoding would be $$variable[ Code ( Get ( LayoutName ) ) ] and the actual variable may look like this: $$variable
It's the most flexible way to handle this. The only "hardcoded" piece is the name of the variable, like $$tab.name. Everything else is dynamic and can be applied to any solution.
I'm glad that you have found a solution that works well for you.
Thank you all.