RPN <Loop> not initialising parameters nor templates correctly

Version: 1.5.27.0

Frequency: Consistently

Severity: Blocker

Marketplace package name: sent via PM for Simobject patch not overriding base files - #6 by FlyingRaccoon

Context: Editing and Mounted to Community

Bug description: Loops fail to correctly initialise parameters. This is an FS2024-only problem and affects code that works fine in 2020. The problem is there, whether we use Asobo or Asobo_EX1 style RPN.

Repro steps:


TEST 1 - PARTIAL FAILURE

We created this template in an XML library and called it in our exterior model. The purpose was to create a loop that would output into UPDATE_CODE_X.

<Template Name="Loop_Test">
    <Parameters Type="Default">
        <LOOP_COUNT>5</LOOP_COUNT>
        <LOOP_TEMP/>
    </Parameters>
    <Loop>
        <Setup>
            <Param>COUNT</Param>
            <From>1</From>
            <To>#LOOP_COUNT#</To>
            <Inc>1</Inc>
        </Setup>
        <Do>
            <Parameters Type="Default" Lifetime="Loop">
                <LOOP_TEMP>#LOOP_TEMP# #COUNT#</LOOP_TEMP>
            </Parameters>
        </Do>
        <Then>
            <Parameters Type="Default">
                <UPDATE_CODE_X>#LOOP_TEMP#</UPDATE_CODE_X>
            </Parameters>
        </Then>
    </Loop>
    <UseTemplate Name="ASOBO_Update_Template">
        <UPDATE_FREQUENCY>4</UPDATE_FREQUENCY>
        <UPDATE_CODE>#UPDATE_CODE_X#</UPDATE_CODE>
    </UseTemplate>
</Template>

The Components and Update appear correctly, but UPDATE_CODE_X does not initialise correctly and appears as the parametre name in Behaviors:

We also tried creating a ParametersFn to handle it, with the same exact results.


TEST 2 - PARTIAL FAILURE

We used this code to generate the code. This time we put the tag for <UPDATE_CODE_X> within the section of the loop and directly fed into it. The assumption was that is not working correctly, despite seeing it work properly in Asobo_EX1 templates. The result was the same as test #1.

We tried creating a ParametersFn to handle this just like in test #1, with the same exact results.


<Template Name="Loop_Test">
    <Parameters Type="Default">
        <LOOP_COUNT>5</LOOP_COUNT>
        <LOOP_CODE_TEMP/>
    </Parameters>
    <Loop>
        <Setup>
            <Param>COUNT</Param>
            <From>1</From>
            <To>#LOOP_COUNT#</To>
            <Inc>1</Inc>
        </Setup>
        <Do>
            <Parameters Type="Override">
                <UPDATE_CODE_X>#LOOP_CODE_TEMP# #COUNT#</UPDATE_CODE_X>
            </Parameters>
        </Do>
    </Loop>
    <UseTemplate Name="ASOBO_Update_Template">
        <UPDATE_FREQUENCY>4</UPDATE_FREQUENCY>
        <UPDATE_CODE>#UPDATE_CODE_X#</UPDATE_CODE>
    </UseTemplate>
</Template>

TEST 3 - TOTAL FAILURE

Test #3 was about embedding the within a set of , using to output into UPDATE_CODE_X. Again, we have examples of this working in default Asobo_EX1 and examples of our own working in FS20.

<Template Name="Loop_Test">
        <Parameters Type="Default">
            <LOOP_COUNT>5</LOOP_COUNT>
            <LOOP_TEMP/>
        </Parameters>
        <Parameters Type="Default">
            <Loop>
                <Setup>
                    <Param>COUNT</Param>
                    <From>1</From>
                    <To>#LOOP_COUNT#</To>
                    <Inc>1</Inc>
                </Setup>
                <Do>
                    <Parameters Type="Default" Lifetime="Loop">
                        <LOOP_TEMP>#LOOP_TEMP# #COUNT#</LOOP_TEMP>
                    </Parameters>
                </Do>
                <Then>
                    <UPDATE_CODE_X>#LOOP_TEMP#</UPDATE_CODE_X>
                </Then>
            </Loop>
        </Parameters>
        <UseTemplate Name="ASOBO_Update_Template">
            <UPDATE_FREQUENCY>4</UPDATE_FREQUENCY>
            <UPDATE_CODE>#UPDATE_CODE_X#</UPDATE_CODE>
        </UseTemplate>
    </Template>

The result was that the Update doesn’t even get initialised, as if it never existed.

Hello @SWS-AlexVletsas

When a parameter is invalid (it has never been set), using it will show it’s name instead. That’s why you see it in the debug.

Starting from your TEST 1 example, there are a few things you need to change:

  • You need to move your update in the <Then> scope, otherwise when you exit <Then>, your parameter is no longer defined
  • You need to set the parameter section type in <Do> to “Override”. LOOP_TEMP is already defined in a “Default” parameters section at the top of your template, a second “Default” definition will simply be ignored

Doing this, here’s what using this template will output:

I assume this is what you were trying to achieve?

Regards,
Sylvain

1 Like

That is exactly what I want to achieve. My question is, why does this code syntax work in 2020 but not in 2024?

I.e. in 2020 we use to create temporary parameters and to output the final parameters that will be used in the Update section. I will PM an XML sample & explanation that works in 2020 but not in 2024.

1 Like

@FlyingRaccoon I have sent a sample to PrivateContent. The important question is whether the code that worked in FS20 & FS24SU2 needs to change, or if the XML parser broke it unintentionally. It is important because we have to work a potential fix into FS20 as well.

Again, thanks for the quick reply in this!

@FlyingRaccoon other than bugs introduced with our own hands, I was able to identify a significant inconsistency in the XML parser across FS2020 and FS2024. I managed to bring both FS20 and FS24 products to the same coding standard, but then the FS20 version broke and the RPN started with undefined parameters.

Here is what I saw:

Left code: works in FS2024, but not in FS2020.

Right code: works in FS2020, but not in FS2024.

It seems that the Greater/Lower and other operators don’t treat Value and Number the same in each sim.