vMix Forums
»
General
»
General Discussion
»
Scripting IF statement based on list value
Rank: Member
Groups: Registered
Joined: 9/17/2020(UTC) Posts: 18 Location: Leeds Thanks: 2 times Was thanked: 3 time(s) in 3 post(s)
|
Hi Everyone
Hope you might be able to help me fix my code -
I am trying to put a toggle input to master AND change an image onto a single button for the AKAI. TO do this I am setting the button to script start. I have so far got it toggle the Input to Master with no issues, but I am struggling to get the list to change image. WHen the input is NOT going to Master I want the image to be just "Green Room" when the Input IS going to Master I want it to show my "On Air" Image. I can do it on 2 seperate buttons using "NextItem" and "PreviousItem" but I want it to be on one button.
I see an If statement as the way forward -
If list = value 1 - show value 2, if list = value 2, show value 1. Essentially.
Here is my code (Only just learning/finding my way around vb.)
API.Function("AudioBus", Input:="Zoom1", Value:="M") If API.Function("Selectindex", Value:="1", Input:="GR Images") else API.Function("Selectindex", Value:="2", Input:="GR Images") End if
I think the issue is the "IF Statement, doesn't have a value to compare to which i'm struggling to work out how to set that.
TIA
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,221 Location: Belgium Thanks: 293 times Was thanked: 955 time(s) in 790 post(s)
|
you need to get the if based on the value not the function for simplicity put the value in a variable for the if statement to check on and perform the function based on that like if value is = 1 or "1" (depending if its a string or number(integer) do function A else do function B endif your issue is more related to get the selection value from in the first place , where wil you get it from ? https://www.tutorialspoi...t_if_else_statements.htm
|
|
|
|
Rank: Member
Groups: Registered
Joined: 9/17/2020(UTC) Posts: 18 Location: Leeds Thanks: 2 times Was thanked: 3 time(s) in 3 post(s)
|
Hi, Thanks very much for that. Yes, I felt exactly as you said that it was the value for the statement to check against to then determine if the conditions were true/false. In answer to your question "where will you get it from" I've no idea, i'm hoping someone on here help me out with that!
So my question is - How do I define the status of a list (i.e which item is selected) to determine a condition to measure against when executing an if statement.
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,221 Location: Belgium Thanks: 293 times Was thanked: 955 time(s) in 790 post(s)
|
Originally Posted by: njfeathe85 So my question is - How do I define the status of a list (i.e which item is selected) to determine a condition to measure against when executing an if statement.
one can check the API xml from within a script Have a look at (with vMix running) http://127.0.0.1:8088/api
|
|
|
|
Rank: Member
Groups: Registered
Joined: 9/17/2020(UTC) Posts: 18 Location: Leeds Thanks: 2 times Was thanked: 3 time(s) in 3 post(s)
|
The API is as follows - with the list selection being defined by "selectedIndex"
<input key="4357451a-56c0-4dd0-86d8-e041cd8f4dbb" number="12" type="VideoList" title="GR Images - Green Room - White Text.png" shortTitle="GR Images" state="Paused" position="0" duration="0" loop="False" muted="True" volume="100" balance="0" solo="False" audiobusses="" meterF1="0" meterF2="0" selectedIndex="1">
<input key="4357451a-56c0-4dd0-86d8-e041cd8f4dbb" number="12" type="VideoList" title="GR Images - On Air_.png" shortTitle="GR Images" state="Paused" position="0" duration="0" loop="False" muted="True" volume="100" balance="0" solo="False" audiobusses="" meterF1="0" meterF2="0" selectedIndex="2">
So I assume I can have the If statement define the condition based on selectedIndex? or could it be defined by the title? How would I go about writing that?
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,221 Location: Belgium Thanks: 293 times Was thanked: 955 time(s) in 790 post(s)
|
This Forum has a neat "search" option.
Lots of post regarding scripting
especially "scripting for dummies" post where the first post already shows how to retrieve info from the API XML
|
|
|
|
Rank: Member
Groups: Registered
Joined: 9/17/2020(UTC) Posts: 18 Location: Leeds Thanks: 2 times Was thanked: 3 time(s) in 3 post(s)
|
Appreciate your reply. I have spent quite a bit of time searching for this but as yet I haven't found it. I will continue to look.
Thanks.
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,221 Location: Belgium Thanks: 293 times Was thanked: 955 time(s) in 790 post(s)
|
|
|
|
|
Rank: Member
Groups: Registered
Joined: 9/17/2020(UTC) Posts: 18 Location: Leeds Thanks: 2 times Was thanked: 3 time(s) in 3 post(s)
|
Hi
I just wanted to say thanks very much for your help. I managed to work it out (once i understood the "console.writeline" bit referred to the command line area underneath the scripting list, this helped me to workout what was what and that the information was being retrieved from the API.
This is how it ended up -
So shortcut commands as follows - first command toggles Input to Bus,
Function=AudioBus&Input=Zoom1&Value=M Function=scriptstart&value=livestatus
second command runs the script as below -
dim xml = API.XML() dim x as new system.xml.xmldocument x.loadxml(xml)
'define the input to look at by editing the short title referenced in the API and also what part to look at - in this case "audiobuses" 'Will feed back a value of each bus seperated by a "," eg. "M,A" or "A" or "A,G" etc. dim INPUTMASTER = (x.SelectSingleNode("//input[@shortTitle='Zoom1']/@audiobusses").Value)
'not needed but saving for future reference 'dim SI = (x.SelectSingleNode("//input[@shortTitle='GR Images']/@selectedIndex").Value)
If INPUTMASTER = "A" Then API.Function("Selectindex", Value:="1", Input:="GR Images") ElseIf INPUTMASTER = "M,A" Then API.Function("Selectindex", Value:="2", Input:="GR Images") End if
|
|
|
|
vMix Forums
»
General
»
General Discussion
»
Scripting IF statement based on list value
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