List Box Saving

General HouseBot discussion. Any issues that don't fit into any of the other topics belong here.
Post Reply
James D
Senior Member
Posts: 134
Joined: Wed Jun 06, 2007 3:30 pm
Location: Baja California

List Box Saving

Post by James D »

Hey Forumer,

In my HB configuration, I created a panel that contains 2 list boxes for my Winamp plugin. .
Box 1 to the left I have a directory list box to display all my music files.
Box 2 to the right I have a list box, where i add the songs from Box 1 to create my playlist.
In between the two boxes I placed an add list Box to add selected songs to the playlist box to the right.

The question i have is; is there a way I can save the playlist i am creating from the alphalist in HB.

Currently what I do to retrieve the playlist I create is:
1. Export the AlphaList in HB
2. Convert to Excel
3. Remove all unnecessary fields
4. Save File as a .txt file
5. Open Notepad in Windows
6. Save file as a .M3u file
7. And the magic is DONE.

Is there a better way to retrieve these music file?
All I want to do is save the List Alpha files associated with the List box, to a M3u. file.
James D
Senior Member
Posts: 134
Joined: Wed Jun 06, 2007 3:30 pm
Location: Baja California

Post by James D »

Attached is a picture of my playlist manager. NOTHING FANCY!!! So No Jokes.
Attachments
Playlist.jpg
Playlist.jpg (78.8 KiB) Viewed 2922 times
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Post by Osler »

You will need to create a task. Call it "SavePlaylist" or some such. Have the task execute the script below. Copy the code to a text file in notepad and save with a .vbs extension (i.e., myscript.vbs).

The list you are populating is a standard list control and should be writing to a device and property. You can exploit this in a script to save your playlist from within HB. Use the following script:

Code: Select all

Dim fso				'As Object
Dim tf				'As Text File
Dim HBPlaylist		'As String


'Get the list from the list control property (insert your device and property name in the line below)
HBPlaylist = GetPropertyValue("<DeviceName>.<PropertyName>")

'Strip any <Tab> out of the list
HBPlaylist = Replace(HBPlaylist, vbTab, "")

'Replace Lf with CrLF in list
HBPlaylist = Replace(HBPlaylist, vbLf, vbCrLf)

'Create the file object
Set fso = CreateObject("Scripting.FileSystemObject")

'Open the file
Set tf = fso.OpenTextFile("C:\MyPlaylist.M3u", 2, True)

'Save the playlist
tf.Write(HBPlaylist)

'Destroy the objects
Set fso = Nothing
Set tf = Nothing
You will need to add your device name and property name to the script, as noted in the comments. In addition, you will need to change the save to site in the script to meet your needs. You could dynamically generate a save name using a device property, a property edit text box, and some sort of keyboard from within your theme as well. However, the above gives you the basics of what you asked for.

Osler
Steve Horn
HouseBot Guru
Posts: 757
Joined: Wed Apr 02, 2003 8:10 pm
Location: Pelham AL

Post by Steve Horn »

Before you go too far, you may want to consider using or looking at the THC Jukebox created by INCORONADO. I've been using it for some time now and its great. Integrates with Winamp, allows the creation of playlists, reads ID tags, does cover art, etc. Look in the VB Scripts section. The only caveat is that the music files currently must be MP3 format. I had to convert all my stuff (really just re-ripped) from WMA to MP3.
Steve
James D
Senior Member
Posts: 134
Joined: Wed Jun 06, 2007 3:30 pm
Location: Baja California

Post by James D »

I like to do things the hard way, Steve. LOL. I really do not like the short-cut approach, for right now. I am still very new to the VB Scripting side. But as I learn little features and commands and small scripts it helps increase my knowledge. Instead of looking at a 5 page script. I know; I looked at the script. And it will also help other new-bies on the forum, that might be scared of asking Stupid Questions about VBScripts so they can learn themselves.

I would like to thank the forum. I went from knowing nothing about VBScript and SQL about a couple of months ago to having a basis knowledge.

I appreciate all who helped. I might put my new knowledge on my resume' to get me a ten cents promotion. LOL
Steve Horn
HouseBot Guru
Posts: 757
Joined: Wed Apr 02, 2003 8:10 pm
Location: Pelham AL

Post by Steve Horn »

James, I understand the sentiment. And I still want to learn more using what's out there as a teaching aid. And, offered as a suggestion to those writing scripts for posting and sharing on this forum, how about commenting your code so that someone picking it up will be able to digest it more easily. English would help too. :wink: (I took some of Richard Naninck's code in Dutch and translated it using one of the internet translators. That was a hoot)
Steve
James D
Senior Member
Posts: 134
Joined: Wed Jun 06, 2007 3:30 pm
Location: Baja California

Post by James D »

The site that helped me a lot and that kind of broke some of the scripting "Lingo" down for me was...
http://www.w3schools.com/default.asp

It helped me a lot.
Richard Naninck
HouseBot Guru Extraordinaire
Posts: 1121
Joined: Tue Sep 28, 2004 7:49 am
Location: The Netherlands

Post by Richard Naninck »

Steve Horn wrote:(I took some of Richard Naninck's code in Dutch and translated it using one of the internet translators. That was a hoot)
Well Steve, I realised that myself so a while ago I started commenting in English. I guess some of my older scripts in the scripts section haven't been updated. If you need something specific, just ask so I can translate my own stuff for you. I know I can do a better job than an internet translator can;)
Steve Horn
HouseBot Guru
Posts: 757
Joined: Wed Apr 02, 2003 8:10 pm
Location: Pelham AL

Post by Steve Horn »

Richard. Thanks for the offer, and I hope you didn't take my comment personally. Actually the exercise really was a hoot.
As an old programmer in a previous life, I understand how commenting one's code can slow the development process down. But it sure helps me and anyone else who picks up the stuff know what's going on.
Steve
Post Reply