Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently January 10th, 2025, 6:37 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: File Selection
PostPosted: February 28th, 2005, 8:19 am 
Offline

Joined: February 26th, 2005, 6:09 am
Posts: 2
Location: Norwich
Does anyone know how i would go about the following:

I want to create a list box that lists all the files in a given directory (allowing for this to be changed if files are added or taken away). On selection of a file - this could then be played, stopped, paused, etc. using the standard media control buttons in Opus.

Any advice would be appreciated.

Cheers


Daniel Forster

_________________
Daniel Forster


For this message scubadive1 has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: February 28th, 2005, 12:16 pm 
Offline

Joined: October 25th, 2004, 12:27 pm
Posts: 526
Location: Digital Workshop
Hi,

Thank you for your enquiry.

The easiest way to achieve this would be to use an external batch file to create a list of all of the files in the specified directory. You could then use Opus' Storage actions to read the information from the generated list and display this information within a Listbox.

Please find attached an example publication and batch file which demonstrate this. Please ensure that both files are extracted to the same directory on your hard disk.

First, take a look at the contents of the batch file. To do this, simply right-click on the file and select Edit from the menu which appears. This should open the batch file into Notepad and you should see the following:

Code:
@echo off
dir "%USERPROFILE%\My Documents\My Pictures\*.jpg" /b /s > list.txt


The @echo off command tells the batch file to run silently so the end-user will not see the output of the 'dir' command on-screen.

As you are probably aware, the dir command is used to list files in a directory.

%USERPROFILE% is an environment variable which equates to the Documents and Settings folder for the currently logged-on user.

*.jpg tells the batch file to list every file which has a JPG file extension.

The /b switch tells the batch file to generate a list in 'bare' format and removes the usual volume and directory header information from the resulting list.

The /s switch tells the batch file to include subdirectories in its search, so if you have a subfolder named 'Holiday Photos' in your My Pictures directory, images in this folder will be included in the final list.

Usually, the results of a 'dir' command are simply displayed on-screen within the command window, but the > list.txt switch tells the batch file to 'print' the output to a file. As we have only specified the filename and not a path to the file, this 'list.txt' file will be created in the same location as the batch file.

Therefore, %USERPROFILE%\My Documents\My Pictures\*.jpg /b /s > list.txt tells the batch file to generate a bare list of the paths to every JPG file in the current user's My Pictures folder (including subfolders) and store this list to a text file named 'list.txt'.

If you now examine my publication, you will see that I have added an On Show trigger to the page, followed by these script actions (an explanation of each action has been added to each line of the script:

Code:
LaunchFile("list.bat") //launches the batch file in the publication directory
textObj = OpenFile("list.txt") //opens the text file which was generated by the batch actions
list = "" //initialises the 'list' variable to blank text
while (textObj.EndOfFile() == false) { //loops the following actions until the end of the text file is reached
currentfile = textObj.ReadLine() //reads the next line from the file and stores it to a variable named 'currentfile'
list = list + currentfile + "\n" //adds the currentfile to the existing list of files and appends a line return
wait() //pauses momentarily to allow the processor to catch up
} //ends the loop
Listbox.SetSelection(0,-1) //selects the entire contents of the Listbox object on the page
Listbox.ReplaceSelection(list) //inserts the list of files into the Listbox


I have created a Listbox object on the page (named 'Listbox') which displays the list of files and I have set this Listbox to store the text of any items selected to a new variable named 'image'.

Finally, I have added an Image object to the page and have set the filename of this Image object to the 'image' variable.

If you preview the publication, you should see a list of JPG files appear in the Listbox and clicking on one of these files should display the corresponding image within the Image object.

This should hopefully give you enough information to create your media player style publication, but please do not hesitate to contact me if you have any further queries.

Kind regards,


You do not have the required permissions to view the files attached to this post.

_________________
Robin Garrett
Digital Workshop Technical Support


For this message Robin Garrett has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Post back...
PostPosted: March 5th, 2005, 4:20 pm 
Offline

Joined: February 26th, 2005, 6:09 am
Posts: 2
Location: Norwich
Perfect, what more can i say... hopefully if i keep this up one day i will return the favour...

Cheers


Daniel

_________________
Daniel Forster


For this message scubadive1 has been thanked by : mackavi


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group