Hi
I’m using VB to write a client that calls a HTML scoreboard.
The person thats written the scoreboard relies on an Invoke command to make changes, so I’ve got a button which does this:-
InvokeControl(TeamHome('" + HomeTeamInitialsTXT.Text + "')")
The InvokeControl being a Sub:-
Sub InvokeControl(ByVal Value As String)
If Me.CasparDevice.IsConnected = True Then
CasparDevice.Channels(0).CG.Invoke(1, 1, Value)
End If
End Sub
This sends a string to Caspar:-
CG 1-1 INVOKE 1 setTeamHome(‘MANUTD’)
This works until I try and send the text MAN UTD, then the update fails and nothing is shown.
If I manually type into Caspar, this commands works:-
CG 1-1 INVOKE 1 “setTeamHome(‘MAN UTD’)”
but I cant get past VB.NET IDE thinking there are too many quotations when I try and add them anywhere in code.
I think its something basic and my brain is failing me.
Does this make sense to anyone?
Space in data is a problem for server 2.1, 2.2 and 2.3 but works with server 2.07. Your code will work in server 2.07.
So you will need to encode space while sending data and decode in html template.
1 Like
Hi Vimlesn1975
Thanks for that info, makes sense. I’ll speak to my HTML guy about that but have you any suggestions on how you’d encode the white space? Would it be as simple as replacing white space as a character before sending and removing in the HTML?
Kind Regards
Steve
In vb.net I have a function like this
Function replacestring(str As String) As String
str = Replace(str, vbCrLf, "<br />")
str = Replace(str, " ", "xxx")
str = Replace(str, "'", "yyy")
str = Replace(str, """", "zzz")
Return str
End Function
In html template I have a function like this
function restorestring(str)
{
str = str.replace(/xxx/g, " ");
str = str.replace(/yyy/g, "'");
str = str.replace(/zzz/g, '"');
return str
}
And for updating a variable str1 with value str2 I have a function in html template like this
function updatestring(str1, str2)
{
document.getElementById(restorestring(str1)).innerHTML = restorestring(str2);
}
Thank you very much for sharing, you’re very kind.
Kind Regards
Stephen
1 Like
As an update, I’ve made a slight alteration to your code which means you dont need to do any work on the HTML templates:-
Function replacestring(str As String) As String
str = Replace(str, vbCrLf, "<br />")
str = Replace(str, " ", " ")
str = Replace(str, "'", "&apos")
str = Replace(str, """", """)
str = Replace(str, "<", "<")
str = Replace(str, ">", ">")
Return str
End Function
Feel free to use if you would like.
1 Like
That is good extension of code. But WebUtility.HtmlEncode in vb.net will also be required for more extensible use.
backslash \
is also a problem which needs to be taken care.
For Backshlash
str - Replace(str, “\”)
and forward slash
str - Replace(str, “/”)
I haven’t tested, but the codes are from the same place so should work. : -
https://www.rapidtables.com/web/html/html-codes.html