Skip to main content
Solved

global variables declaration inside a template

  • September 3, 2018
  • 12 replies
  • 24 views

Forum|alt.badge.img

Hallo! I want to set a global variable in an subtemplate which i can get from another subtemplate, is there any function possible ? Its like a gett- and sett-function.

Thanks for answers.

Best answer by rolandpilsinger

yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

12 replies

takashi
Celebrity
  • 7842 replies
  • September 3, 2018
What are the "subtemplates"? Do you mean different two workspaces?

 

 


Forum|alt.badge.img
  • Author
  • 20 replies
  • Best Answer
  • September 3, 2018

yes two different subtemplates (workspaces). Also how to define a variable in one workspace.


takashi
Celebrity
  • 7842 replies
  • September 3, 2018

yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

You can define a global variable with the VariableSetter.

 

However, the scope of a global variable is within the workspace which contains the variable definition, and its value exists only while the workspace is running.

 

I don't think there is a way to directly refer a variable defined in a workspace from another workspace.

 

 


Forum|alt.badge.img

yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

Yeah but how can i set a variable into a template ? And how could i set the variable higher into a loop or something. (everything inside a template)

 

 


Forum|alt.badge.img

yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

If i define a variable before i input that into my template, how can i access to that variable ?

 

 

i tried it with " b="$aVariable" ", but he show allways an error.

 


takashi
Celebrity
  • 7842 replies
  • September 4, 2018

yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

You can retrieve the value of a global variable defined by a VariableSetter only through the VariableRetriever. See the help to learn more.

 

 


Forum|alt.badge.img

yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

But in an subtemplate (number 1) i can not set an variable where i can access on that value from an other subtemplate (number 2) ?

 

 

in subtemplate 1 i want to set the value in which road i be with an Value (1,2,3,...) and in subtemplate 2 i want to check if I'm in road 1 or 2 and so on to get the right nodes from my lanes.

 


takashi
Celebrity
  • 7842 replies
  • September 4, 2018

yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

As I mentioned before, the scope of a global variable is only within the workspace which contains the variable definition. There is no way to access a global variable in the first workspace from the second workspace.

 

You probably would have to consider other approach rather than global variables, in order to achieve your goal. We could think of a solution if you would explain the conditions and the requirements specifically.

 


takashi
Celebrity
  • 7842 replies
  • September 4, 2018

yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

Additionally, I would recommend you to use standard FME terms. "template" is not equal to "worksapce". "subtemplate" is not clear.

 

See also here: FME Terminology

 

 


Forum|alt.badge.img

yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

The template is structured in "Root Template" and "Sub Template" and also "Geometry Template". And i want to set a variable in my sub template "ROAD" and get it in my sub template "GEOMETRY". (shown in the picture)

 

 


takashi
Celebrity
  • 7842 replies
  • September 4, 2018

yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

That was another story. "templates" - XML template expressions written in the XMLTemplater transformer won't be called "workspaces".A variable defined in an XML template expression cannot be accessed from any other XML template expression, even though the two expressions are sub templates belonging to an identical XMLTemplater transformer.

 


Forum|alt.badge.img

yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

Okay if that is impossible to get one variable from one subtemplate to an other i have to go an other way to create an .xml structure. Which other possible way's could i go to create an xml file with a defined structure ?