Can a variable definition include another variable?

This forum is for all Flare issues not related to any of the other categories.
Post Reply
HelenF
Propeller Head
Posts: 56
Joined: Tue May 18, 2010 2:24 am

Can a variable definition include another variable?

Post by HelenF »

Hi, will Flare let me use a variable within a variable?

I'm trying to set up this scenario:
VariableA = 'Company'
VariableB = 'Installing applications made by VariableA'

I've tried using the [%=VariableSet.variablename%] syntax within Variable B but it is treated as literal text.

Any other ideas?

Much appreciated
Helen
nickatwork
Sr. Propeller Head
Posts: 457
Joined: Thu Sep 16, 2010 6:31 am
Location: London

Re: Can a variable definition include another variable?

Post by nickatwork »

You could use a snippet for your variable B instead.
HelenF
Propeller Head
Posts: 56
Joined: Tue May 18, 2010 2:24 am

Re: Can a variable definition include another variable?

Post by HelenF »

VariableB is text that appears in the footer of a PDF document. Each PDF has different footer text - so I specify the footer text in each PDF's target file.

I don't think snippets work this way.
nickatwork
Sr. Propeller Head
Posts: 457
Joined: Thu Sep 16, 2010 6:31 am
Location: London

Re: Can a variable definition include another variable?

Post by nickatwork »

Do the variables need to be nested? If the text is just 'Installing applications made by VariableA' then you could just put the variables side-by-side?
variable A = Installing applications made by
variable B = CompanyName

Or do you need to put company name within that text at times?

I guess if you need to put the text in the middle sometimes then you could use 3 variables and if using the example above then variable C would be empty but it's there for use if you need it with other variables?

Also, you should send a feature request to MadCap for variables within variables.

Nick.
HelenF
Propeller Head
Posts: 56
Joined: Tue May 18, 2010 2:24 am

Re: Can a variable definition include another variable?

Post by HelenF »

Feature request submitted - thanks.
Rona Kwestel
Sr. Propeller Head
Posts: 212
Joined: Wed Apr 04, 2007 11:50 am

Re: Can a variable definition include another variable?

Post by Rona Kwestel »

Request submitted as well:
It would be cool if you could define a variable that contains another variable. For example, for a copyright notice variable, I would like to embed the General.Year variable so I don't have to remember to update the copyright variable when the year ticks over. Perhaps the relatively limited set of use cases for this feature doesn't warrant the complexity of implementation, but per the forum (<link to this topic>), I'm not the only one asking, even if it is only once every 5 years. ; - )
Rona Kwestel
Sr. Propeller Head
Posts: 212
Joined: Wed Apr 04, 2007 11:50 am

Re: Can a variable definition include another variable?

Post by Rona Kwestel »

Okay, I guess there's another way to do this using a set of variables and a snippet:

So, instead of one variable that contains "Copyright © 2017. MyCompany All Rights Reserved.", you can make several variables:

Code: Select all

Company.Copyright: "Copyright ©"
General.Year: "yyyy"
Company.CompanyName: "MyCompany"
Company.RightsReserved: "All Rights Reserved."
And then just run them together in a snippet:

Code: Select all

<MadCap:variable name="Company.Copyright" /> <MadCap:variable name="General.Year" />. <MadCap:variable name="Company.CompanyName" /> <MadCap:variable name="Company.RightsReserved" />
I'm guessing that implementing the nested variables would be more complicated than it's worth given this relatively easy workaround.
Last edited by Rona Kwestel on Fri Jun 23, 2017 8:32 am, edited 1 time in total.
whunter
Sr. Propeller Head
Posts: 429
Joined: Thu Mar 12, 2009 4:49 pm
Location: Portland, OR

Re: Can a variable definition include another variable?

Post by whunter »

You can use a variable within another variable's definition. I'm not sure when the functionality was added. I think I stumbled on it 2 releases ago (2016 R2 or whatever that was).

When your cursor is in the definition field, there's an Insert Variable icon that you can use to select another variable to insert into the definition.
Rona Kwestel
Sr. Propeller Head
Posts: 212
Joined: Wed Apr 04, 2007 11:50 am

Re: Can a variable definition include another variable?

Post by Rona Kwestel »

Thanks, whunter.

Okay, I admit I didn't read the doc entirely (http://help.madcapsoftware.com/flare201 ... iables.htm), but in my defense, there should be a topic for each dialog that lists all the buttons along with a brief explanation for each and a link to the relevant topics that describe their use. Otherwise, you have to have noticed this sentence, which, given the context of "creating (inserting?) variables into the list", can easily be misconstrued:
If you want to insert a variable, you can click <button image here> . The variable will appear as syntax in the field, but in the output the variable definition will be shown.
I would say:
If you want to insert a variable within the variable definition, ... The embedded variable will appear as syntax in the Definition field, but in the output, the evaluated definition will be shown.
Rona Kwestel
Sr. Propeller Head
Posts: 212
Joined: Wed Apr 04, 2007 11:50 am

Re: Can a variable definition include another variable?

Post by Rona Kwestel »

One more point on this. When you edit a variable in the Target Editor to provide a target-specific value, I don't see an option to insert a variable in the definition, so you have to fake it with some typed-in text value to add an entry in the target file, then edit the target with the Internal Text Editor to change the text value to a variable using the [%=variable_set.variable_name%] syntax.

The use case here is when you have similar products with a lot of common content, and you want to simply replace the product name in the common snippets/topics at build time with the appropriate product variable. So, you define your product name variables and a generic product variable:

ProductA = "Product A"
ProductB = "Product B"
Product = "product"

Then, set the Product variable to the ProductA variable in ProductA_Target, and to the ProductB variable in ProductB_Target.

It looks like this in the target file:

Code: Select all

<Variables>
  <Variable
    Name="OurCompany/Product">[%=OurCompany.ProductA%]</Variable>
</Variables>
Rona Kwestel
Sr. Propeller Head
Posts: 212
Joined: Wed Apr 04, 2007 11:50 am

Re: Can a variable definition include another variable?

Post by Rona Kwestel »

But here's where my solution potentially falls down. If it turns out that you want to produce a single target that builds the doc for all the sub-products into a single output/tree, then you can't set the product-specific snippet variable values at the target level, but instead must do so on the snippet instances themselves within the topics. However, not only is this more tedious, but the syntax in the topic (HTML) files is necessarily different from that of the target (XML) files, so there doesn't appear to be a way to embed a variable in the specified value for the variable in the snippet:

Code: Select all

<MadCap:snippetBlock src="../Resources/Snippets/MyVariableSnippet.flsnp" MadCap:snippetVariables="MyVariables.ProductName:BestProductEver," />
And though I knew this apples-and-oranges idea wouldn't work, I couldn't help myself, and tried stuffing the [%=variable_set.variable_name%] syntax used in the target file into the above construct in place of BestProductEver, and sure enough, attempting to preview it crashed Flare. :?

It almost seems like the right solution would be a modular one, where you build target A with the target-level variables set for product A, build target B with the target-level variables set for Product B, and then build target C that would nest target A and target B beneath it. Sort of like cascading target "sheets". :D
Post Reply