Question on variables

Please post all questions and comments regarding Help & Manual 7 here.

Moderators: Alexander Halser, Tim Green

Post Reply
John Johann
Posts: 305
Joined: Mon Aug 21, 2017 7:35 pm

Question on variables

Unread post by John Johann »

I have a project with a large number of topics.
These topics will in future be linked to various other projects as snippets. The title of the topic appears a number of times on the page (e.g. the topic is about a dialogue or command "ABC", the title of the "toggle ABC" for chm is the same, the conditional text for pdf "figure ABC" is the same and so on.

In an earlier test, I had entered the variable <%TOPICTITLE%> for all occurences of this same text. When I then inserted the topic somewhere else as a snippet, it inherited the title from the new page.

What is the best solution in this scenario bearing in mind that the linked projects may contain multiple different snippets?
User avatar
Tim Green
Site Admin
Posts: 23153
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Question on variables

Unread post by Tim Green »

Hi John,

Like styles, variables will always take their values from the project in which they are published. A variable is just that, a variable. It doesn't contain any value of its own, by definition. When you insert a snippet only the content of the snippet is inserted in the topic where it is inserted. When the project is published the snippet is normal topic content. At that point there is literally no difference between the content of a snippet and the rest of the topic. So when a variable is encountered Help+Manual must look in its own list of variables and find the value there. And a strongly context-related variable like TOPICTITLE will always reflect the current topic where the variable is located.

This means that any variables you use in snippets must be defined in the project in which the snippets are used. It's thus not a good idea to use standard project and topic variables like TOPICTITLE, because those will always reflect the current project and topic. If you want something to be the same across multiple projects you need to define it as a user-defined variable, in every project where it is going to be used.
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
John Johann
Posts: 305
Joined: Mon Aug 21, 2017 7:35 pm

Re: Question on variables

Unread post by John Johann »

Hi Tim,
Thanks.
Does that also apply to <%TOPICMETA:MYMETATAG%> information?

I'm not keen on creating 2,000 +variables in all projects just on the off-chance that a topic might get used somewhere.
User avatar
Tim Green
Site Admin
Posts: 23153
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Question on variables

Unread post by Tim Green »

Does that also apply to <%TOPICMETA:MYMETATAG%> information?
If the MYMETATAG exists in the topic file where the snippet is inserted, then the value of that tag will be used. The basic rule for all variables is that they take their values from where they are, not from where they were. :)
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
John Johann
Posts: 305
Joined: Mon Aug 21, 2017 7:35 pm

Re: Question on variables

Unread post by John Johann »

Hi Tim,
Thanks -- that wuld be a no then :cry: .
Ga Bowen
Posts: 324
Joined: Mon Jun 27, 2016 5:05 pm

Re: Question on variables

Unread post by Ga Bowen »

Just thinking out aloud. Could you...

Duplicate the source project file.

Change each snippet to be linked from Snippet is linked to Copy & Paste into text (maybe someone on here might be able to create a batch macro?)

Insert snippets in new document.

:?:
User avatar
Tim Green
Site Admin
Posts: 23153
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Question on variables

Unread post by Tim Green »

Hi Ga,
Ga Bowen wrote:Change each snippet to be linked from Snippet is linked to Copy & Paste into text (maybe someone on here might be able to create a batch macro?)
That wouldn't make any difference to the variables problem. The variables would still take their values from their location in the target topic. They wouldn't "bring" any values with them from the source,wherever that was. Copy/Paste mode and Linked mode for snippet insertion is only different in terms of when the insertion is made. In Link mode Help+Manual also performs a copy/paste operation, but it performs it just before publishing the topic instead of when you are editing. The published result is exactly the same in both cases: The snippet becomes a normal part of the topic, just the same as if you had typed it in. :?
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
Post Reply