vMix Forums
»
General
»
General Discussion
»
Variable instead of integer in scripting
Rank: Member
Groups: Registered
Joined: 11/6/2020(UTC) Posts: 21 Location: Saint-Petersburg Thanks: 6 times Was thanked: 1 time(s) in 1 post(s)
|
I need to get timecode of input, this code works: Code:dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)
dim time_position as string = (x.SelectSingleNode("//input[@number=1]/@position").Value)
but if I need to set number of active input it returns exception: Code:dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)
dim active_input as string = (x.SelectSingleNode("//active").InnerText)
dim time_position as string = (x.SelectSingleNode("//input[@number=active_input]/@position").Value)
tried to change to integer, also doesnt work. when write to console input determinates correctly thank you!
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 6/16/2020(UTC) Posts: 77 Thanks: 8 times Was thanked: 2 time(s) in 2 post(s)
|
At first glance you can see that the xpath has a variable inside in this case active_input, you have to separate that variable from everything and or concatenate it. translated from spanish with google
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 10/20/2021(UTC) Posts: 5 Location: Ontario Thanks: 1 times Was thanked: 1 time(s) in 1 post(s)
|
The reason your command is not working is because it is looking for an input numbered "time_position", rather than the value of time_position. To do what you want try the following commands: Quote: dim xml as string = API.XML() dim x as new system.xml.xmldocument x.loadxml(xml)
dim time_position as string = (x.SelectSingleNode("//input[@number=1]/@position").Value)
dim xml as string = API.XML() dim x as new system.xml.xmldocument x.loadxml(xml)
dim position_query as string = "//input[@number=" + time_position + "]/@position" dim time_position as string = (state.SelectSingleNode(position_query).Value)
dim position_query as string = "//input[@number=" + time_position + "]/@position"creates the query string that contains the value of time_position e.g. "//input[@number=1]/@position". dim time_position as string = (state.SelectSingleNode(position_query).Value) performs the xml query to return the position value.
|
1 user thanked GregS for this useful post.
|
|
|
Rank: Member
Groups: Registered
Joined: 11/6/2020(UTC) Posts: 21 Location: Saint-Petersburg Thanks: 6 times Was thanked: 1 time(s) in 1 post(s)
|
Originally Posted by: GregS The reason your command is not working is because it is looking for an input numbered "time_position", rather than the value of time_position Thank you very much! I still don't quite understand how it works, but it does) Code:dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)
dim active_input as string = (x.SelectSingleNode("//active").InnerText)
dim xml2 as string = API.XML()
dim x2 as new system.xml.xmldocument
x2.loadxml(xml)
dim position_query as string = "//input[@number=" + active_input + "]/@position"
dim time_position as string = (x2.SelectSingleNode(position_query).Value)
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,218 Location: Belgium Thanks: 291 times Was thanked: 955 time(s) in 790 post(s)
|
Code:dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)
dim active_input as string = (x.SelectSingleNode("//active").InnerText)
dim time_position as string = (x.SelectSingleNode("//input[@number=" + active_input + "]/@position").Value)
Console.writeline(time_position )
|
|
|
|
vMix Forums
»
General
»
General Discussion
»
Variable instead of integer in scripting
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The vMix Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close