Page 1 of 1

Cycle items with textformat

PostPosted: Thu Dec 21, 2017 2:57 pm
by GMKai
Hi there,
I currently try to edit the contents of a cycle-item during runtime of the application.
So I use mui.CreateObject with a fresh new "Object-Tree".
This is to produce the new xml:
Code: Select all
Function p_TeamItemsbyPosition(positiontext)
     DebugPrint("p_TeamItemsbyPosition")
     Local items$="<item>None</item>\n"
     mui.DoMethod("playerlistcleanall", "Sort", 1)
     for Local n = 0 to mui.get("playerlistcleanall","Entries")-1
         column1$, column2$,column3$ = mui.DoMethod("playerlistcleanall", "GetEntry", n)
         If(column2$ = positiontext)
            items$ = items$.."<item>\27b"..column2$.." - "..column3$.."\27n</item>\n"
         Else
            items$ = items$.."<item>"..column2$.." - "..column3$.."</item>\n"
         EndIf()
     Next
     Return(items$)
EndFunction

this leads to an xml like this:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?><vgroup id="grplayers" frametitle="players" frame="group" background="groupback"><hgroup>
      <text id="grplayerst1">1</text>
      <cycle id="cyteamlineup1" horizweight="300"><item>None</item>
<item>CB - Bagaric</item>
<item>CB - Ayar</item>
<item>DM - Ahmed</item>
<item>MA - Alexander-Salota</item>
<item>RA - Able</item>
</cycle>
        </hgroup><hgroup>
      <text id="grplayerst2">2</text>
      <cycle id="cyteamlineup2" horizweight="300"><item>None</item>
<item>CB - Ayar</item>
<item>CB - Bagaric</item>
<item>DM - Ahmed</item>
<item>MA - Alexander-Salota</item>
<item>RA - Able</item>
</cycle>
        </hgroup><hgroup>
      <text id="grplayerst3">3</text>
      <cycle id="cyteamlineup3" horizweight="300"><item>None</item>
<item>CB - Bagaric</item>
<item>CB - Ayar</item>
<item>DM - Ahmed</item>
<item>MA - Alexander-Salota</item>
<item>RA - Able</item>
</cycle>
        </hgroup><hgroup>
      <text id="grplayerst4">4</text>
      <cycle id="cyteamlineup4" horizweight="300"><item>None</item>
<item>CB - Ayar</item>
<item>CB - Bagaric</item>
<item>DM - Ahmed</item>
<item>MA - Alexander-Salota</item>
<item>RA - Able</item>
</cycle>
        </hgroup><hgroup>
      <text id="grplayerst5">5</text>
      <cycle id="cyteamlineup5" horizweight="300"><item>None</item>
<item>CB - Ayar</item>
<item>CB - Bagaric</item>
<item>DM - Ahmed</item>
<item>MA - Alexander-Salota</item>
<item>RA - Able</item>
</cycle>
        </hgroup><hgroup>
      <text id="grplayerst6">6</text>
      <cycle id="cyteamlineup6" horizweight="300"><item>None</item>
<item>CB - Ayar</item>
<item>CB - Bagaric</item>
<item>bDM - Ahmedn</item>
<item>MA - Alexander-Salota</item>
<item>RA - Able</item>
</cycle>
        </hgroup><hgroup>
      <text id="grplayerst7">7</text>
      <cycle id="cyteamlineup7" horizweight="300"><item>None</item>
<item>CB - Ayar</item>
<item>CB - Bagaric</item>
<item>DM - Ahmed</item>
<item>MA - Alexander-Salota</item>
<item>RA - Able</item>
</cycle>
        </hgroup><hgroup>
      <text id="grplayerst8">8</text>
      <cycle id="cyteamlineup8" horizweight="300"><item>None</item>
<item>CB - Bagaric</item>
<item>CB - Ayar</item>
<item>DM - Ahmed</item>
<item>MA - Alexander-Salota</item>
<item>RA - Able</item>
</cycle>
        </hgroup><hgroup>
      <text id="grplayerst9">9</text>
      <cycle id="cyteamlineup9" horizweight="300"><item>None</item>
<item>CB - Bagaric</item>
<item>CB - Ayar</item>
<item>DM - Ahmed</item>
<item>MA - Alexander-Salota</item>
<item>RA - Able</item>
</cycle>
        </hgroup><hgroup>
      <text id="grplayerst10">10</text>
      <cycle id="cyteamlineup10" horizweight="300"><item>None</item>
<item>CB - Ayar</item>
<item>CB - Bagaric</item>
<item>DM - Ahmed</item>
<item>MA - Alexander-Salota</item>
<item>RA - Able</item>
</cycle>
        </hgroup><hgroup>
      <text id="grplayerst11">11</text>
      <cycle id="cyteamlineup11" horizweight="300"><item>None</item>
<item>CB - Ayar</item>
<item>CB - Bagaric</item>
<item>DM - Ahmed</item>
<item>MA - Alexander-Salota</item>
<item>bRA - Ablen</item>
</cycle>
        </hgroup><hgroup>
      <text id="grplayerst12">12</text>
      <cycle id="cyteamlineup12" horizweight="300"><item>None</item>
<item>CB - Ayar</item>
<item>CB - Bagaric</item>
<item>DM - Ahmed</item>
<item>MA - Alexander-Salota</item>
<item>RA - Able</item>
</cycle>
        </hgroup><hgroup>
      <text id="grplayerst13">13</text>
      <cycle id="cyteamlineup13" horizweight="300"><item>None</item>
<item>CB - Ayar</item>
<item>CB - Bagaric</item>
<item>DM - Ahmed</item>
<item>MA - Alexander-Salota</item>
<item>RA - Able</item>
</cycle>
        </hgroup><hgroup>
      <text id="grplayerst14">14</text>
      <cycle id="cyteamlineup14" horizweight="300"><item>None</item>
<item>CB - Ayar</item>
<item>CB - Bagaric</item>
<item>DM - Ahmed</item>
<item>MA - Alexander-Salota</item>
<item>RA - Able</item>
</cycle>
        </hgroup><hgroup>
      <text id="grplayerst15">15</text>
      <cycle id="cyteamlineup15" horizweight="300"><item>None</item>
<item>CB - Ayar</item>
<item>CB - Bagaric</item>
<item>DM - Ahmed</item>
<item>MA - Alexander-Salota</item>
<item>RA - Able</item>
</cycle>
        </hgroup><hgroup>
      <text id="grplayerst16">16</text>
      <cycle id="cyteamlineup16" horizweight="300"><item>None</item>
<item>CB - Ayar</item>
<item>CB - Bagaric</item>
<item>DM - Ahmed</item>
<item>MA - Alexander-Salota</item>
<item>RA - Able</item>
</cycle>
        </hgroup>     <vgroup>
      <text>Strength:</text>
      <text id="txteamselectedplayerstrength"/>
      <button id="btteamselectedplayerset" notify="pressed" frame="button">\33A[27]Set Players</button>
        <button id="btteamtacticview" notify="pressed" frame="button">\33A[42]View Tactics</button>
      <rectangle/>
    </vgroup>
     </vgroup>


Which is not well-formed.
How do i have to set the text of an Item to be partially bold?
Code: Select all
  items$ = items$.."<item>\27b"..column2$.." - "..column3$.."\27n</item>\n"

Re: Cycle items with textformat

PostPosted: Sat Dec 23, 2017 2:53 pm
by airsoftsoftwair
XML uses octal notation for escape codes, see here for details. So you have to do the following:

Code: Select all
items$ = items$.."<item>\\33b"..column2$.." - "..column3$.."\\33n</item>\n"


Then it should work. Also note the two backslashes. These are necessary because we want to have the sequence "\33b" in the XML. To get this we first have to escape the backslash by duplicating it.

Re: Cycle items with textformat

PostPosted: Mon Dec 25, 2017 9:08 am
by GMKai
I see.
I missed to double the \\.

Can you maybe put that into the documentation?

Re: Cycle items with textformat

PostPosted: Tue Dec 26, 2017 9:24 pm
by airsoftsoftwair
You also missed that 27 needs to be 33. I'll see if I can add this information to the MUI Royale documentation.

Re: Cycle items with textformat

PostPosted: Wed Dec 27, 2017 10:35 pm
by GMKai
It was not missed to have to set \27 but it didn't work in first place.
So I changed to \33
but as we know by now that was not the real problem.

When updating documentation, please give some examples to point others to the need of good escaping.

From current documentation it did not come to my mind to check for double \.


Thank you

Re: Cycle items with textformat

PostPosted: Thu Dec 28, 2017 12:54 pm
by airsoftsoftwair
Code: Select all
- Change [Doc]: Added note about properly escaping the backslash when passing XML from the
  Hollywood script to MUI Royale