I changed now the script, without a sort function.
Right now just try to save the data in array and get back.
Dim data As New System.Collections.Generic.List(Of Object())
For i As Integer = 1 to 16
Dim letter, percent, percentch As xpTextObject
Self.GetObjectByName("hiddenLetter" & i, letter)
Self.GetObjectByName("hiddenPercent" & i, percent)
Self.GetObjectByName("hiddenPercentCh" & i, percentch)
Dim ar As Object() = {letter.Text, CDbl(percent.Text.Replace(".", ",")), CDbl(percentch.Text.Replace(".", ","))}
data.Add(ar)
Next
For i As Integer = 1 to 16
Dim letter, percent, percentch As xpTextObject
Self.GetObjectByName("Bogstav " & i, letter)
Self.GetObjectByName("Procent " & i, percent)
Self.GetObjectByName("ProcentCh " & i, percentch)
letter.Text = data(i - 1)(0)
percent.Text = data(i - 1)(1).ToString("N1") + "%"
percentch.Text = data(i - 1)(1).ToString("N1") + "%"
Next
But nothing happens, am I doing anything wrong here?
------------------------------
Tue Sandbæk
Director / TV-Technician
TV SYD
------------------------------
Original Message:
Sent: 12-06-2022 13:22
From: John Corigliano
Subject: Sort data?
Things get trickier when sorting data with multiple fields. I would put the data in an array of 3 items. Then put those arrays into a List. You will need to create a custom sorter function. Since Xpression doesn't seem to support Linq or lambda expressions, put this in your global script:
Function DoSort(ByVal a As Object(), ByVal b As Object()) As Integer DoSort = b(1).CompareTo(a(1))End Function
This creates a function that sorts on the 2nd item of an array.
Then change the script to something like this:
' Create a list of arraysDim data As New System.Collections.Generic.List(Of Object())' Put the data from the hidden text objects in the list For i As Integer = 1 to 16 Dim letter, percent, percentch As xpTextObject Self.GetObjectByName("hiddenLetter" & i, letter) Self.GetObjectByName("hiddenPercent" & i, percent) Self.GetObjectByName("hiddenPercentCh" & i, percentch) ' Put the data in an array Dim ar As Object() = {letter.Text, CDbl(percent.Text.Replace(".", ",")), CDbl(percentch.Text.Replace(".", ","))} ' Add the array to the list data.Add(ar)Next' Sort the list using the custom functiondata.Sort(AddressOf DoSort)' Put the sorted data into the graphicsFor i As Integer = 1 to 16 Dim letter, percent, percentch As xpTextObject Self.GetObjectByName("Letter" & i, letter) Self.GetObjectByName("Percent" & i, percent) Self.GetObjectByName("PercentCh" & i, percentch) letter.Text = data(i - 1)(0) percent.Text = data(i - 1)(1).ToString("N1") + "%" percentch.Text = data(i - 1)(2).ToString("N1") + "%"Next