logo

Live Production Software Forums


Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
FrankLeggett  
#1 Posted : Wednesday, November 11, 2020 4:49:25 AM(UTC)
FrankLeggett

Rank: Advanced Member

Groups: Registered
Joined: 11/22/2018(UTC)
Posts: 94
United Kingdom
Location: Worthing

Thanks: 1 times
Was thanked: 4 time(s) in 3 post(s)
Hi,

This forum has been very helpful to me and so I am scrounging again for advice.

I am trying to script a loop of data from a spreadsheet but I need work out what the syntax in a VB.NET script is for DataSourceSelectRow
I understand that I need to name the datasource and the sheet and the row I want to show but I can't work out the syntax. I have tried the following below:
api.Function("DataSourceSelectRow",Input:= "Excel Workbook", "Sheet1", value:=x)
How far am I away from the correct syntax
doggy  
#2 Posted : Wednesday, November 11, 2020 4:57:22 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,216
Belgium
Location: Belgium

Thanks: 291 times
Was thanked: 955 time(s) in 790 post(s)
There should not be an input reference and the value is the table, sheet , index

if its not an excel you can omit the sheet part

Think its something like API.Function("DataSourceSelectRow",Value:="DataTableName,Sheet,Index")
FrankLeggett  
#3 Posted : Wednesday, November 11, 2020 5:13:54 AM(UTC)
FrankLeggett

Rank: Advanced Member

Groups: Registered
Joined: 11/22/2018(UTC)
Posts: 94
United Kingdom
Location: Worthing

Thanks: 1 times
Was thanked: 4 time(s) in 3 post(s)
Thanks but that didn't work it saved without error but it didn't change the row on the selected DataSource

The DataSource in this instance is a Excel Workbook and it is Sheet2
I have tried the following
API.Function("DataSourceSelectRow",Value:="TableName,Sheet,1")
API.Function("DataSourceSelectRow",Value:="TableName,Sheet, index:=1")
both have saved but neither selects Row 1 on the sheet on the specified Workbook?

by the way if I save it as a Webscript this works and selects row 1
Function=DataSourceSelectRow&Value=TableName,Sheet,0
doggy  
#4 Posted : Wednesday, November 11, 2020 5:32:44 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,216
Belgium
Location: Belgium

Thanks: 291 times
Was thanked: 955 time(s) in 790 post(s)
eliminate the index:= just use the index value

API.Function("DataSourceSelectRow",Value:="Excel Workbook,Sheet2,1")

Personally i prefer to name the data source table more simple (one word)

btw row 1 is index 0 ;-)
FrankLeggett  
#5 Posted : Wednesday, November 11, 2020 5:52:34 AM(UTC)
FrankLeggett

Rank: Advanced Member

Groups: Registered
Joined: 11/22/2018(UTC)
Posts: 94
United Kingdom
Location: Worthing

Thanks: 1 times
Was thanked: 4 time(s) in 3 post(s)
Yes that worked, is there a way to change the row to a variable inside a loop.

I tried a loop 1 to 5 but couldn't get it to change row based on the value of x (I get the part about Row 1 being index 0 :-)

dim x as integer
Dim Index as integer =0
'API.Function("PreviewInput",Input:="race1.mp4")
Do while Index <=100
for x = 1 to 5
api.Function("DataSourceSelectRow",Value:="Excel Workbook,Sheet,x")
sleep(10000)
next x
index +=1
loop
doggy  
#6 Posted : Wednesday, November 11, 2020 6:27:59 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,216
Belgium
Location: Belgium

Thanks: 291 times
Was thanked: 955 time(s) in 790 post(s)
you can also use DataSourceSelectRow once you have set it to your first row

else it's something like api.Function("DataSourceSelectRow",Value:="Excel Workbook,Sheet," & x.tostring)
FrankLeggett  
#7 Posted : Wednesday, November 11, 2020 7:52:10 AM(UTC)
FrankLeggett

Rank: Advanced Member

Groups: Registered
Joined: 11/22/2018(UTC)
Posts: 94
United Kingdom
Location: Worthing

Thanks: 1 times
Was thanked: 4 time(s) in 3 post(s)
Thanks I didn't know how to integrate the string.

I will pop this into the script for dummies forum along with all the others you have solved.
lance_05  
#8 Posted : Saturday, January 15, 2022 11:40:14 AM(UTC)
lance_05

Rank: Newbie

Groups: Registered
Joined: 1/15/2022(UTC)
Posts: 7
Philippines
Location: Manila

Thanks: 2 times
Originally Posted by: doggy Go to Quoted Post
you can also use DataSourceSelectRow once you have set it to your first row

else it's something like api.Function("DataSourceSelectRow",Value:="Excel Workbook,Sheet," & x.tostring)


Hi doggy,

Is there a way to:

1. Get and Print the index of the current selected record in datasource and use it to select the next record.
2. If current position is the last record, select the 1st record in datasource.
3. no looping.

Thanks in advance!
doggy  
#9 Posted : Saturday, January 15, 2022 5:06:36 PM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,216
Belgium
Location: Belgium

Thanks: 291 times
Was thanked: 955 time(s) in 790 post(s)
Originally Posted by: lance_05 Go to Quoted Post


Hi doggy,

Is there a way to:

1. Get and Print the index of the current selected record in datasource and use it to select the next record.


No ( unless you keep track of it somehow ) . remember there is a function to jump to the next row already!

Quote:
2. If current position is the last record, select the 1st record in datasource.


with a script when you do a next row one can check if the "previous" content is the same as the "next" indicating its in fact the same row = last row ( works only if each row is unique in data) and instruct to jump to first row

Quote:
3. no looping.


You just asked for a loop in point 2 ?


Alternatively one can have an external app reading your data source and program in anything you want to do with it including knowing the row number .
How it was done before data sources were introduced and scripting

lance_05  
#10 Posted : Monday, January 17, 2022 2:09:04 PM(UTC)
lance_05

Rank: Newbie

Groups: Registered
Joined: 1/15/2022(UTC)
Posts: 7
Philippines
Location: Manila

Thanks: 2 times
As usual, Thanks a lot for the helpful response doggy.

Actually my question mainly depends on getting that index variable so it can be used with the selectrow function. (like using a single shortcut key to rundown all records in each press, instead of 1 key each to select either next/previous record which I already have). By the way, nice workaround on my 2nd question.

You see, I wanted to experiment more using datasource and also learn scripting to further automate my setup. (Been using most of your responses as reference actually)

But since there's no way to get index easily within vmix, I agree that looping is needed.

Thanks again!
Users browsing this topic
Guest (2)
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.