Jump to content

[VB6] Read Playlist from ini


Recommended Posts

Answer has been found.. nevermind...

ok.. kinda simple.. but i can't figure this out...

on form_load i have my program read from an ini file then if "list" = "[NOT FOUND]" I need it to not add it to my listbox... heres the code that i have so far... i want to make it simpler and not put If then statements all the way down...

list = INITool1.GetFromINI("Track1", "Location", App.Path & "\settings.ini")
playlist.AddItem list
list = INITool1.GetFromINI("Track2", "Location", App.Path & "\settings.ini")
playlist.AddItem list
list = INITool1.GetFromINI("Track3", "Location", App.Path & "\settings.ini")
playlist.AddItem list

so lets say... if for Track2 the user didn't put anything in it.. so it returns the string "[NOT FOUND]" but Track3 has something. If i use something like a Do Until event, it will stop on Track2.. insted of reading track 3 and so on..

any ideas?

Thanks

My Solution...

For i = 1 To 20
list = INITool1.GetFromINI("Track" & i, "Location", App.Path & "\settings.ini")
If list = "[NOT FOUND]" Then
'do nothing and don't add to the list
Else
playlist.AddItem list
End If
Next i
End Sub

Edited by Bi0haZarD
Link to comment
Share on other sites


If i just parse the folder for all .mp3's then it will come back into my listbox as "c:\my music\rock\metallica\Metallica - Master of puppets.mp3" and with an ini i can let the user pick the name of the song.. so insted of seeing the complete path they can set it to say "Metallica - Master of Puppets" it just makes it look a bit cleaner..

this is for my Unattended Audio Player btw.. so thats why i only have it support 20 MP3's since that should be plenty, and whoever makes the CD can set the names of the tracks and it'll look better ;)

Link to comment
Share on other sites

Ok I wasn't telling you how to do it just suggesting ideas. But thats possible also to strip file path returning only name. Or even load the dir to a File1 filter out .exe

Still waiting to try your next version

EDIT: One other idea maybe, After file is played delete it from dir?

Then If I used it at different place it would start next

Edited by maxXPsoft
Link to comment
Share on other sites

I know ;) Suggestions are always welcome. and yea, i could always strip out the path to get more of a play all files in the folder.

I don't see what the point of having it delete the file upon finishing the song would be. this unattended player is to go into the $OEM$ folder so it gets copied to the hard drive and played.. then at the end of the installation if you have your install.cmd (or whatever file) to delete the c:\install folder it deletes the songs and player off the hard drive. if the files were to stay on the CD, it would proably slow down the installation of your applications since it would constantly have to read from the CD. and it wouldn't be able to delete the songs from the CD.

Link to comment
Share on other sites

The reason I was suggesting remove the ini is 'INITool1.GetFromINI'

I think thats a separate exe isn't it?

no its a OCX Control file, i haven't tested to see if i have to bundle it.. i hope i don't since it would mean putting it in the system32 folder by putting it in "$OEM$\$$\System32"

Link to comment
Share on other sites

ahhh,

Yep very possible to use it will need to be included. I have seen a tool called initool.exe and was wondering, I have all my ini modding done by a .bas file included within my app. I searched for years for the right ini thing and came across this after trying nearly all.

Do you have a link to that ocx I can check it out?

Yeah this probably wouldn't play at User.cmd is reason I was thinking of delete file after play, then at runoncex start again new, I been experimenting play mp3's at different points with my app, still a work in progress...

Link to comment
Share on other sites

Sorry was uploading my new version UnattendXP then had to search.

I've done some modifying to this myself adding a couple features if you want it then MSG me and leave email and I'll send.

WriteToIni

Dim MyX As String, MyY As String
   MyX = Me.Top
   WriteToIni AddBackslash(App.Path) & "UnattendXP.ini", "ABOUT", "MainX", MyX

GetFromIni

   MyX = GetFromIni(AddBackslash(App.Path) & "UnattendXP.ini", "ABOUT", "MainX")

Get and save as IniMod.bas

Get the last post by Inverso, this has proved to be the easiest least confusing ini routine I have ever had. :thumbup and I have tried them all

Link to comment
Share on other sites

The AddBackslash routine which is great :thumbup

Just add it in the Public Functions seection of the inimod.bas

Public Function AddBackslash(strPath As String) As String
'Receives the App.Path and returns a path containing backslash
'USAGE:  SomePath = AddBackslash(App.Path) & "YourFile.xxx"
 If Right$(strPath, 1) <> "\" Then
   AddBackslash = strPath & "\"
 Else
   AddBackslash = strPath
 End If
End Function

Link to comment
Share on other sites

For i = 1 To 20
list = INITool1.GetFromINI("Track" & i, "Location", App.Path & "\settings.ini")
If list = "[NOT FOUND]" Then
'do nothing and don't add to the list
Else
playlist.AddItem list
End If
Next i
End Sub

Just a minor tweak, but you might want to try...

For i = 1 To 20
   list = INITool1.GetFromINI("Track" & i, "Location", App.Path & "\settings.ini")
       If list <> "[NOT FOUND]" Then
           playlist.AddItem list
       End If
   Next i
End Sub

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...