![]() |
Telelogic Rhapsody (steve huntington) | ![]() |
Topic Title: ReporterPlus Templates that work on a selection or the entire project Topic Summary: My lessons learned Created On: 18-Nov-2008 16:35 Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
One of the tasks I was given in my current job was to create a ReporterPlus template that could be applied to various parts of our model to export it for a review package. After more trial and error than I'd like to admit, I ran into a few basic tricks that make the task easier.
Problem: The first level of iteration always has to be "Class" rather than Association. Operating on a selection, it will mostly only fetch the items under that selection. There are a few odd exceptions that I found. For example, searching over all Packages would yield all packages under the selection, as all as a single package that was down at the project level. I had a similar result trying to iterate over all controlled files. Also, this does not create proper indentation for nested items. Solution: Begin your iteration by iterating over all Projects (there should only be one for the selection. Don't display any heading or text for either node of this iteration) and then associated containedPackages. This will iterate through all packages at the selection and below it. If you have a package selected and not the project, this makes the first node that you iterate over be the selected package. If the project is selected, this iterates through all of the packages from the project level. If there are multiple projects loaded, it will only process the Active Project. Problem: The title page needs to be different based on whether we're doing a selection, or doing the entire model. Solution: Expressions are your friend. I generate my title page dynamically using the following expression for the name: if (size [project] ->[containedPackages] = 1) then $name of [project]->[containedPackages] else $name of [project]; "Untitled". What this does is output the name of the selected package, if just a package was selected for export, or the name of the project if that's what is selected. Other tips: * If you have some tricky formatting that you want to add in, like specifying fonts or adding in auto-numbering captions, using Insert File will allow you to import Word Files. One catch is that this can add extra carriage returns after the file. This is usually a predictable number for your file, so I added a unique value like "@@Replace" at the end of my file and after export, I do a search and replace for "@@Replace^p^p" to remove the value and the extra paragraph marks after it. * I don't believe you can put commands, such as inserting files, into expressions. However, there are some tricks you can use to provide conditional commands and text. ** If you can isolate the text to the end of a node, you can place a conditional expression before it that evaluates to nothing if the condition is false and then select Skip Following text. Any commands or text after it, including things like inserting files, will not be displayed. To perform multiple operations, or something conditional in the middle, just use multiple nodes, without a CR at the end if want items concatenated. ** If the text is conditional upon whether an iteration has items, one easy trick is to do a dummy iteration. For example, our documents require a caption and classification information prior to a table. I could use the above trick and check whether the collection that will be the rows has a size greater than 0, but we didn't know about that initially, so instead we had two iterations over the parameters of an operation in which the first only had the classification and caption within the root and then the second had the actual table info. I think this actually consumes more time and resources than the technique above, because it actually forces evaluation of the iteration twice, but it is an option if the above technique doesn't work, for cases where your condition is whether an iteration has any items. Problem: There are some sections of text which are repeated multiple times. For example, I iterate over attributes six different times in my template, all of which do the same thing. How do I ripple a change through all six instances? Solution (sort of): Honestly, I don't. The closest I get generally is saving a node to disk, and then inserting it again at subsequent places and deleting the old value. I have heard of a few people, such as Simon Morrish here on the forums, who have had success with the VBA integration and it is possible to do finds and replaces on the template file, which is plaintext, but so far, that's not been something I've had a chance to try. Eh, this was just one of those days where I had some spare time and I figured I would share this with people on the forum on the off chance it answers any questions. Goodness knows, I've learned a lot from the people here. |
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.