Page 1 of 1
Getting files into a Option menu
Posted: Tue Feb 28, 2012 1:28 pm
by ivaho
Hi,
I'am trying to get files from a directory into an Option Menu.
I want to select a file in the option menu and send it to a server.
The sending part is not a problem only the getting the files in the Option menu.
I've read the beginners manual and am able to get the files in a field but not into an Option menu.
Kind regards
Re: Getting files into a Option menu
Posted: Tue Feb 28, 2012 2:37 pm
by Klaus
Hi ivaho,
welcome to the forum!
Here some great leraning resources:
http://www.runrev.com/developers/lesson ... nferences/
OK, what did you try so far to "get the files into an option menu"?
You could:
...
put the files into tFiles
set the text of btn "your option menu here" to tFiles
...
OR simply:
...
put tFiles into btn "your option menu here"
...
Is that what you mean?
Best
Klaus
Re: Getting files into a Option menu
Posted: Sun Mar 04, 2012 12:15 pm
by ivaho
Hi Klaus,
Thanks for your reply.
[put tFiles into btn "your option menu here"] was the solution i was looking for, had no idea i could just put them into the button and the files would appear as choises.
I'am trying to write a simple program for playing files using a server(CasparCG)
Now i have the files in my Option Menu, i would like that the .mp4 or .mov extensions are not visible in the list.
I've read it somewhere on the forum here but cant find it any more.
After that i need to send the following command to the server.
write "play 1 (option menu choice) " & format("\r\n") to socket "localhost:5250"
the command for playing a file on the server onder a normal button is
write "play 1 amb" & format("\r\n") to socket "localhost:5250" where amb is the file on the server.
kind regards
Ivo
Re: Getting files into a Option menu
Posted: Sun Mar 04, 2012 5:07 pm
by kdjanz
Since the list of files is just a list of lines of text, you can loop through them and trim the ends off each line in tFiles - before you put that text into your button menu. You can look up working with chunk data if you don't know how to do that -
http://lessons.runrev.com/s/lessons/m/4 ... -with-text - might be a good place to start.
Kelly
Re: Getting files into a Option menu
Posted: Sun Mar 04, 2012 5:33 pm
by Klaus
Hi Ivo,
you can use the "filter" command!
...
put the files into tFiles
## "filter without" is our friend

filter tFiles without "*.mp4"
filter tFiles without "*.mov"
...
Done
Best
Klaus
Re: Getting files into a Option menu
Posted: Tue Mar 06, 2012 5:00 pm
by ivaho
Hi klaus,
If i put
filter listFiles without "*.mp4"
put listFiles(currentFolder(), ) into button "Option Menu"
there are still files showing with .mp4 on the end.
And i think the filter works as that files with extention .mp4 will not be showing, but i want those files to be showing but without the .mp4 extennsion.
I need the files to be displayed without there extension.
Re: Getting files into a Option menu
Posted: Tue Mar 06, 2012 5:48 pm
by Klaus
Hi Ivo,
well, it might be a good idea to FIRST get the files and THEN filter them
...
## I think this is your function that gets the files, right?
## Is the COMMA corect in the function call? -> listFiles(currentFolder(), ) ?
put listFiles(currentFolder(), ) into tFiles
filter tFiles without "*.mp4"
put tFiles into button "Option Menu"
...
Best
Klaus
Re: Getting files into a Option menu
Posted: Thu Mar 15, 2012 7:33 pm
by ivaho
Hi Klaus,
Sorry for the late responce but I wasn't able to check things out.
Your option works but it removes the files with *.mp4 from my list.
What i was looking for was a solution to remove the extension .mp4 or .avi or .???
So basicly remove the last 4 characters
I've got this to work but it works only for the first line
put listFiles(currentFolder(), ) into field "fFiles"
delete char -4 to -1 of word 1 of field "fFiles"
How to go throuh the entire list of files??
Kind regards Ivo
Re: Getting files into a Option menu
Posted: Thu Mar 15, 2012 7:40 pm
by Klaus
Hi Ivo,
ah, you only want to see MP4 files in the menu but without the siffix .mp4, right?
Simply use REPLACE with EMPTY

...
put listFiles(currentFolder(), ) fFiles
filter tFiles with "*.mp4"
replace ".mp4" with EMPTY in tFiles
put tFiles into fld "fFiles"
## or into button...
...
Best
Klaus
Re: Getting files into a Option menu
Posted: Thu Mar 15, 2012 7:42 pm
by mwieder
Any number of ways to do this. Here's one:
Code: Select all
put listFiles(currentFolder(), ) into tFiles
set the itemdelimiter to "."
repeat for each line tFileName in tFiles
put item 1 of tFileName & cr after field "fFiles"
end repeat
(Klaus - unfortunately the replace command won't replace wildcard templates)
Re: Getting files into a Option menu
Posted: Thu Mar 15, 2012 7:50 pm
by ivaho
Thank you
Your code was adding the files to the files list but putting
put empty into field "fFiles"
before the code, solved that to for me