• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

[Solved with 120% embarassment] Composing strings

Heretic

Resource contributor
Messages
6,830
Country
germany
Can I compose strings, ideally from macros?

Let's say I have:

Code:
<Macro Name="SetPrefix">A_</Macro>
<Macro Name="SetName">Name</Macro>
<Macro Name="SetSuffix">_B.txt</Macro>

And then do:
Code:
<Macro Name="Compose">'@Setprefix@SetName@SetSuffix'</Macro>

The expected result, when I call "Compose" somewhere* is:
Code:
A_Name_B.txt

But I usually get:
Code:
@SetprefixName_B.txt

Am I doing something wrong or is this an XML limitation?

Strings with a single macro in them usually work.



*I'm using the resulting string for load/save operations in Logger.




- Edit:

Notice the lowercase "p" in "@Setprefix"?

Yep, that's the culprit. The string composes just fine now.

*Head -> desk*
 
Last edited:
A followup issue: I want to generate the "Name" in the "SetName" macro from the "ATC_type" and "ATC_model" lines in the aircraft.cfg.

This code...
Code:
<Macro Name="SetPrefix">A_</Macro>
<Macro Name="SetName">(A:ATC TYPE, string)_(A:ATC MODEL, string)</Macro>
<Macro Name="SetSuffix">_B.txt</Macro>

<Macro Name="Compose">'@SetPrefix@SetName@SetSuffix'</Macro>
...does not produce a valid string though.

Neither does this one:
Code:
<Macro Name="SetPrefix">A_</Macro>
<Macro Name="SetName">%((A:ATC TYPE, string))%!s!_%((A:ATC MODEL, string))%!s!</Macro>
<Macro Name="SetSuffix">_B.txt</Macro>

<Macro Name="Compose">'@SetPrefix@SetName@SetSuffix'</Macro>

I suspect it has something to do with the single quotation marks (') used to generate strings and the final macro not liking the results.

Any ideas?

I'm also experimenting with XMLVars, so if it's possible there, I'm open to it.
 
Last edited:
I think you could try:

Code:
<Macro Name="SetPrefix">'A_'</Macro>
<Macro Name="SetName">(A:ATC TYPE, string) '_' scat (A:ATC MODEL, string) scat</Macro>
<Macro Name="SetSuffix">'_B.txt'</Macro>

<Macro Name="Compose">@SetPrefix @SetName scat @SetSuffix scat</Macro>

(A:ATC TYPE, string) and (A:ATC MODEL, string) are strings already, so I believe they should not be enclosed in quotes.

Tom
 
Back
Top