Cycle items with textformat

Discuss GUI programming with the MUI Royale plugin here

Cycle items with textformat

Postby GMKai » Thu Dec 21, 2017 2:57 pm

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"
GMKai
 
Posts: 60
Joined: Mon Feb 15, 2010 11:58 am

Re: Cycle items with textformat

Postby airsoftsoftwair » Sat Dec 23, 2017 2:53 pm

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.
User avatar
airsoftsoftwair
 
Posts: 2415
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany

Re: Cycle items with textformat

Postby GMKai » Mon Dec 25, 2017 9:08 am

I see.
I missed to double the \\.

Can you maybe put that into the documentation?
GMKai
 
Posts: 60
Joined: Mon Feb 15, 2010 11:58 am

Re: Cycle items with textformat

Postby airsoftsoftwair » Tue Dec 26, 2017 9:24 pm

You also missed that 27 needs to be 33. I'll see if I can add this information to the MUI Royale documentation.
User avatar
airsoftsoftwair
 
Posts: 2415
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany

Re: Cycle items with textformat

Postby GMKai » Wed Dec 27, 2017 10:35 pm

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
GMKai
 
Posts: 60
Joined: Mon Feb 15, 2010 11:58 am

Re: Cycle items with textformat

Postby airsoftsoftwair » Thu Dec 28, 2017 12:54 pm

Code: Select all
- Change [Doc]: Added note about properly escaping the backslash when passing XML from the
  Hollywood script to MUI Royale
User avatar
airsoftsoftwair
 
Posts: 2415
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany


Return to MUI Royale

Who is online

Users browsing this forum: No registered users and 1 guest