Using arrays in DLP labTALK

DVD-lab, DVD-lab Studio and DLP2
Post Reply
peterlloyd
Posts: 55
Joined: Sat Nov 13, 2010 9:21 pm

Using arrays in DLP labTALK

Post by peterlloyd »

Hi,
I am seeking a simple example of how to read an integer array into a labTALK script. The array is of small but of unknown size ~20-30 integers to be read and counted.
Thanks
Peter

Vapymid
Posts: 291
Joined: Wed Oct 27, 2010 4:38 am
Location: London, UK

Re: Using arrays in DLP labTALK

Post by Vapymid »

Can you please clarify what do you mean by "reading into"? Is the data stored outside DVDLab (in that case I believe you will need to write your entire script an external plugin using DVDLab's SDK)?

Regards

peterlloyd
Posts: 55
Joined: Sat Nov 13, 2010 9:21 pm

Re: Using arrays in DLP labTALK

Post by peterlloyd »

Re Can you please clarify what do you mean by "reading into"? Is the data stored outside DVDLab (in that case I believe you will need to write your entire script an external plugin using DVDLab's SDK

Vapymid,
I would like to use the labTALK input function to read from the terminal a list of integers like {1,2,3,67,999,2007} is there a way?
Thanks
Regards
Peter

Vapymid
Posts: 291
Joined: Wed Oct 27, 2010 4:38 am
Location: London, UK

Re: Using arrays in DLP labTALK

Post by Vapymid »

Try this:

Code: Select all

i = 1

10
input "Enter parameter value:", a[i]

if bCancelInput then
	nElements = i - 1
	goto 20
else
	i = i + 1
	goto 10
endif

20
print "Total elements in the array: ", nElements
for i = 1 to nElements
	print "Element ", i, " value: ", a[i]
next
Regards

peterlloyd
Posts: 55
Joined: Sat Nov 13, 2010 9:21 pm

Re: Using arrays in DLP labTALK

Post by peterlloyd »

Vapymid,
Thanks for your help. Indeed that gets the data in one at a time. I had hoped there might be trick to assign a comma delimited list typed into an input box which could be assigned directly to an array.
The wished for format in code might be:

ARRAYINPUTBOX(" enter your array elements here", MyArray)

Cheers
Peter

Vapymid
Posts: 291
Joined: Wed Oct 27, 2010 4:38 am
Location: London, UK

Re: Using arrays in DLP labTALK

Post by Vapymid »

No, I don't think there is anything like that in LabTalk, sorry.

Regards

supernoodledoodle
Posts: 11
Joined: Thu Mar 22, 2012 1:20 pm

Re: Using arrays in DLP labTALK

Post by supernoodledoodle »

I know it's bad form to resurrect a dead post, but the more info on Labtalk that's out there the better I think.

To that end, would it be possible to use the text file input from the special input commands on this page:

http://www.mediachance.com/dvdlab/helpp ... etails.htm

File box with browse button
This is done by setting FILE: inside the string
a = "C:\\myfile.txt"

input "FILE:Set file", a

It would then be theoretically possible to parse the comma separated values into an array by manipulating the resulting variable 'a', perhaps by using:

string = LEFT(input, x)

which says it gets first x character from left of the input string. So let's say that all the integers were the in the format 0001,0002...2009, we might then somehow knock off the left 5 characters from the string and run again until the string is empty, building the array as we go.

I can't see if there's a command to modify the string like that, does anyone have any ideas?

videonut
Posts: 7
Joined: Wed Jan 15, 2014 9:37 pm

Re: Using arrays in DLP labTALK

Post by videonut »

For the record, when you use the "FILE:" parameter with input, all you get is the full path and filename of the file you open. For text files, you could then, conceivably, paste that text into a text box on a menu with ObjectAddFrom(menu,sFile). I say "conceivably" because I've never had the need to try it. And, you might have to use that function as the "sText" parameter of ObjectSetText(menu,object,sText) to get it to work.

You can't read the file contents directly into a variable or array because labTALK is missing all the necessary file commands, like OPEN, READ, READLN, WRITE, WRITELN & CLOSE. And, if that wasn't enough, labTALK is also missing key string manipulation functions like; LEN(string) and MID(string,nFrom,nChars). For those, I had to write my own, which is tricky because both of the two (count 'em... *2*) included functions, LEFT(string,x) and RIGHT(string,x), will return an empty string if x = the string length.
My scripts use no politically-correct language,
and my components contain no Chinese parts.

Vapymid
Posts: 291
Joined: Wed Oct 27, 2010 4:38 am
Location: London, UK

Re: Using arrays in DLP labTALK

Post by Vapymid »

I would say - if you have a text file with the input numbers - just add "a = " in front of them in the source file and copy/paste the whole block into the script before running it...

Regards

Post Reply