AuToItItAlIaNlOv3R Posted June 12, 2010 Posted June 12, 2010 (edited) Hi to all, now i writing a radio program, hi contain a lot of radio station, over 6000 station! Now i would like to introduce in my program, a function that allows you to search your favorite radio between the radio available in my program.A function like this :I would introduce this function in my program how i can do that?This is my program example :expandcollapse popup;this is only an example #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Gui = GUICreate("example", 149, 49, 169, 166) $File = GUICtrlCreateMenu("&File") $Esci = GUICtrlCreateMenuItem("Exit", $File) $Station = GUICtrlCreateMenu("Station") GUISetState(@SW_SHOW) ;English station $english = GUICtrlCreateMenu("English", $station) $bbcnews = GUICtrlCreateMenuItem("BBC News", $english) $deepside = GUICtrlCreateMenuItem("Deepinside - Soulful House Station", $english) ;French station $french = GUICtrlCreateMenu("French", $Station) $cheriefm = GUICtrlCreateMenuItem("Chérie FM", $french) $CherieFMZen = GUICtrlCreateMenuItem("Chérie FM Zen", $french) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $bbcnews $gMediaObject.URL = "http://www.bbc.co.uk/worldservice/meta/tx/nb/assignment_au_nb.asx" Case $deepside $gMediaObject.URL = "http://www.deepinside.co.uk/ecoute-deepinside-wmp.m3u" Case $cheriefm $gMediaObject.URL = "mms://vipmms9.yacast.net/encodercheriefm" Case $CherieFMZen $gMediaObject.URL = "mms://vipnrj.yacast.net/cheriefm_webradio01" EndSwitch WEnd Func _CreateWMPlayer() $Object = ObjCreate("WMPlayer.OCX.7") $Object.URL = "" Return $Object EndFuncHow can introduce that function?...Hi and thank's a lot! Edited June 12, 2010 by AuToItItAlIaNlOv3R
PsaltyDS Posted June 12, 2010 Posted June 12, 2010 How do you maintain that list of stations? Is it all in an INI file, .CSV file, database, or what? Need to know that before determining how to search the list. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
AuToItItAlIaNlOv3R Posted June 12, 2010 Author Posted June 12, 2010 maintain that list of stations, such as example, with a lot of case : Case $bbcnews $gMediaObject.URL = "http://www.bbc.co.uk/worldservice/meta/tx/nb/assignment_au_nb.asx" Case $deepside $gMediaObject.URL = "http://www.deepinside.co.uk/ecoute-deepinside-wmp.m3u" Case $cheriefm $gMediaObject.URL = "mms://vipmms9.yacast.net/encodercheriefm" Case $CherieFMZen $gMediaObject.URL = "mms://vipnrj.yacast.net/cheriefm_webradio01" I've more than 6.000 case, for only radio Hi!
PsaltyDS Posted June 12, 2010 Posted June 12, 2010 (edited) maintain that list of stations, such as example, with a lot of case : I've more than 6.000 case, for only radio You hard-coded them all into the script?! You're insane, daft, loopy, cracked, in need of professional help, ...etc. Edit: How about an INI file like this: [English] BBC News=http://www.bbc.co.uk/worldservice/meta/tx/nb/assignment_au_nb.asx Deepside=http://www.deepinside.co.uk/ecoute-deepinside-wmp.m3u [French] Cherie FM=mms://vipmms9.yacast.net/encodercheriefm Cherie FM Zen=mms://vipnrj.yacast.net/cheriefm_webradio01 [Spanish] RNE Radio 3=http://www.rtve.es/rne/audio/RNE3.asx It would be MUCH easier to edit/maintain/search/etc. Edited June 12, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Thatsgreat2345 Posted June 12, 2010 Posted June 12, 2010 It's posts like these that make my day. Write a script to extract all those radio stations and store them externally, whether it be ini,csv,sqlite, anything else. Which this will also allow you to accomplish your search feature. Plus it will allow you to add extra information about the stations and make your search feature even more effective.
AuToItItAlIaNlOv3R Posted June 15, 2010 Author Posted June 15, 2010 Ok i've create a .ini file like this: [Albania] Radio Tirana 1=http://radiotirana.fly-dns.com/listen.pls|http://www.rtsh.al/|News/Talk/Features Radio Tirana 3=http://radiotirana.funkhaus.info:8000/listen.pls|http://www.rtsh.al/|Foreign service [Andorra] Radio Nacional d'Andorra=mms://194.158.91.91/Rna|http://www.rtvasa.ad/|News/features Andorra 7 Ràdio=http://www.andorra7radio.com:8008|http://www.andorra7radio.com/|Pop/Jazz [Armenia] Armenian National Radio=mms://wm12.spacialnet.com/armradionet|http://www.armradio.am/|News/information/Music AR Radio Intercontinental=mms://wm12.spacialnet.com/armyerevan|http://www.arradio.am/|Easy Listening/JazzIt's formed like this [State] Radio Name = Streaming Link|Web Site|GenreNow how i can create a search form like this :I would like search radio by name, states and Genre how i can do that? Thank's a lot for help!
Authenticity Posted June 15, 2010 Posted June 15, 2010 expandcollapse popup#include <GUIConstantsEx.au3> #include <GUIComboBox.au3> #include <GUIListView.au3> #include <WindowsConstants.au3> Local Const $aData = _Stations() Local $hGUI = GUICreate("Test", 640, 480) Local $hComboBox = _GUICtrlComboBox_Create($hGUI, "", 20, 20, 150) Local $ListView = GUICtrlCreateListView("Title|Country|Genre|Language", 20, 50, 600, 410, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT)) Local $hListView = GUICtrlGetHandle($ListView) Local $CheckCase = GUICtrlCreateCheckbox("Match &Case", 190, 20, 80, 25) Local $CheckExact = GUICtrlCreateCheckbox("Match &Whole", 290, 20, 100, 25) ;~ _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_COLUMNOVERFLOW, $LVS_EX_FULLROWSELECT)) For $i = 0 To _GUICtrlListView_GetColumnCount($hListView)-1 _GUICtrlListView_SetColumnWidth($hListView, $i, 140) Next _GUICtrlComboBox_BeginUpdate($hComboBox) For $i = 1 To $aData[0][0] _GUICtrlComboBox_AddString($hComboBox, $aData[$i][0]) Next _GUICtrlComboBox_EndUpdate($hComboBox) GUISetState() GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $sText, $iItem $hWndFrom = $ilParam $iIDFrom = BitAND($iwParam, 0xFFFF) $iCode = BitShift($iwParam, 16) Switch $hWndFrom Case $hComboBox Switch $iCode Case $CBN_EDITCHANGE $sText = _GUICtrlComboBox_GetEditText($hComboBox) If $sText <> "" Then _UpdateListView($sText) Else _GUICtrlListView_DeleteAllItems($hListView) EndIf Case $CBN_SELCHANGE $iItem = _GUICtrlComboBox_GetCurSel($hComboBox) If $iItem >= 0 Then $i = $iItem + 1 _GUICtrlListView_DeleteAllItems($hListView) GUICtrlCreateListViewItem($aData[$i][0] & "|" & $aData[$i][1] & "|" & $aData[$i][2] & "|" & $aData[$i][3], $ListView) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func _UpdateListView($sText) Local $sPattern = "" _GUICtrlListView_BeginUpdate($hListView) _GUICtrlListView_DeleteAllItems($hListView) If GUICtrlRead($CheckCase) = $GUI_CHECKED Then $sPattern &= "(?i)" If GUICtrlRead($CheckExact) = $GUI_CHECKED Then $sPattern &= "^\Q" & $sText & "\E$" Else $sPattern &= "\Q" & $sText & "\E" EndIf For $i = 1 To $aData[0][0] If StringRegExp($aData[$i][0], $sPattern) Then _ GUICtrlCreateListViewItem($aData[$i][0] & "|" & $aData[$i][1] & "|" & $aData[$i][2] & "|" & $aData[$i][3], $ListView) Next _GUICtrlListView_EndUpdate($hListView) EndFunc Func _Stations() Local $aReturn[13][5] = [[12], _ ; or load from an ini file ["Lollradio Dance (MP3 128K)", "Italy", "Dance/DJ", "Italian", "www.lollradiodance.com"], _ ["Lollradio Flashback (MP3 128K)", "Italy", "70s/80s", "Italian", "www.lollradioflashback.com"], _ ["Lollradio Happy (MP3 128K)", "Italy", "Adult Contemporary", "Italian", "www.lollradiohappy.com"], _ ["Lollradio Hits (MP3 128K)", "Italy", "Hit Radio", "Italian", "www.lollradiohits.com"], _ ["Lollradio Italia (MP3 128K)", "Italy", "Pop", "Italian", "www.lollradioitalia.com"], _ ["Lollradio Soft (MP3 128K)", "Italy", "Easy Listening", "Italian", "www.lollradiosoft.com"], _ ["Roflradio Dance (MP3 128K)", "Sweden", "Dance/DJ", "Swedish", "www.roflradiodance.com"], _ ["Roflradio Flashback (MP3 128K)", "Sweden", "70s/80s", "Swedish", "www.roflradioflashback.com"], _ ["Roflradio Happy (MP3 128K)", "Sweden", "Adult Contemporary", "Swedish", "www.roflradiohappy.com"], _ ["Roflradio Hits (MP3 128K)", "Sweden", "Hit Radio", "Swedish", "www.roflradiohits.com"], _ ["Roflradio Italia (MP3 128K)", "Sweden", "Pop", "Swedish", "www.roflradioitalia.com"], _ ["Roflradio Soft (MP3 128K)", "Sweden", "Easy Listening", "Swedish", "www.roflradiosoft.com"]] Return $aReturn EndFunc
AuToItItAlIaNlOv3R Posted June 15, 2010 Author Posted June 15, 2010 Thanks a lot, but something is not clear to me. How can load station to .ini file ? It's a part of my very long ini file [Albania] Radio Tirana 1=http://radiotirana.fly-dns.com/listen.pls|http://www.rtsh.al/|News/Talk/Features Radio Tirana 3=http://radiotirana.funkhaus.info:8000/listen.pls|http://www.rtsh.al/|Foreign service [Andorra] Radio Nacional d'Andorra=mms://194.158.91.91/Rna|http://www.rtvasa.ad/|News/features Andorra 7 Ràdio=http://www.andorra7radio.com:8008|http://www.andorra7radio.com/|Pop/Jazz [Armenia] Armenian National Radio=mms://wm12.spacialnet.com/armradionet|http://www.armradio.am/|News/information/Music AR Radio Intercontinental=mms://wm12.spacialnet.com/armyerevan|http://www.arradio.am/|Easy Listening/Jazz I've a lot and a lot of nation and station! ;) What is the function "Match Case" and "Match Whole"? And the ultimate question, i would like that if i've found the station, simply clicking on it starts, playing the radio, how can do it? Thank's a lot!!!!
PsaltyDS Posted June 21, 2010 Posted June 21, 2010 Not sure what you're asking for. You want to add items to the INI file? Where will the data come FROM? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
AuToItItAlIaNlOv3R Posted June 24, 2010 Author Posted June 24, 2010 (edited) I would like that program read information by ini file. My ini file is formed like that: [Albania] Radio Tirana 1=http://radiotirana.fly-dns.com/listen.pls|http://www.rtsh.al/|News/Talk/Features Radio Tirana 3=http://radiotirana.funkhaus.info:8000/listen.pls|http://www.rtsh.al/|Foreign service [Andorra] Radio Nacional d'Andorra=mms://194.158.91.91/Rna|http://www.rtvasa.ad/|News/features Andorra 7 Ràdio=http://www.andorra7radio.com:8008|http://www.andorra7radio.com/|Pop/Jazz [Armenia] Armenian National Radio=mms://wm12.spacialnet.com/armradionet|http://www.armradio.am/|News/information/Music AR Radio Intercontinental=mms://wm12.spacialnet.com/armyerevan|http://www.arradio.am/|Easy Listening/Jazz I've a lot and a lot of nation and station! ;) This is the scheme : [State] Radio Name = Streaming Link|Web Site|Genre Edited June 24, 2010 by AuToItItAlIaNlOv3R
Authenticity Posted June 24, 2010 Posted June 24, 2010 (edited) #include <Array.au3> Local $aSections = IniReadSectionNames("stations.ini"), $aKeys Local $aStations[2][2] = [[0]], $aTmp For $i = 1 To $aSections[0] $aKeys = IniReadSection("stations.ini", $aSections[$i]) For $j = 1 To $aKeys[0][0] $aStations[0][0] += 1 If $aStations[0][0] > UBound($aStations)-1 Then ReDim $aStations[$aStations[0][0]+50][4] $aStations[$aStations[0][0]][0] = $aKeys[$j][0] $aTmp = StringSplit($aKeys[$j][1], "|") For $k = 1 To $aTmp[0] If $k > UBound($aStations, 2)-1 Then ReDim $aStations[$aStations[0][0]+1][$k+1] $aStations[$aStations[0][0]][$k] = $aTmp[$k] Next Next Next ReDim $aStations[$aStations[0][0]+1][UBound($aStations, 2)] _ArrayDisplay($aStations) Edited June 24, 2010 by Authenticity
AuToItItAlIaNlOv3R Posted June 25, 2010 Author Posted June 25, 2010 (edited) Thank's but i would like that this script :expandcollapse popup#include <GUIConstantsEx.au3> #include <GUIComboBox.au3> #include <GUIListView.au3> #include <WindowsConstants.au3> Local Const $aData = _Stations() Local $hGUI = GUICreate("Test", 640, 480) Local $hComboBox = _GUICtrlComboBox_Create($hGUI, "", 20, 20, 150) Local $ListView = GUICtrlCreateListView("Title|Country|Genre|Language", 20, 50, 600, 410, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT)) Local $hListView = GUICtrlGetHandle($ListView) Local $CheckCase = GUICtrlCreateCheckbox("Match &Case", 190, 20, 80, 25) Local $CheckExact = GUICtrlCreateCheckbox("Match &Whole", 290, 20, 100, 25) ;~ _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_COLUMNOVERFLOW, $LVS_EX_FULLROWSELECT)) For $i = 0 To _GUICtrlListView_GetColumnCount($hListView)-1 _GUICtrlListView_SetColumnWidth($hListView, $i, 140) Next _GUICtrlComboBox_BeginUpdate($hComboBox) For $i = 1 To $aData[0][0] _GUICtrlComboBox_AddString($hComboBox, $aData[$i][0]) Next _GUICtrlComboBox_EndUpdate($hComboBox) GUISetState() GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $sText, $iItem $hWndFrom = $ilParam $iIDFrom = BitAND($iwParam, 0xFFFF) $iCode = BitShift($iwParam, 16) Switch $hWndFrom Case $hComboBox Switch $iCode Case $CBN_EDITCHANGE $sText = _GUICtrlComboBox_GetEditText($hComboBox) If $sText <> "" Then _UpdateListView($sText) Else _GUICtrlListView_DeleteAllItems($hListView) EndIf Case $CBN_SELCHANGE $iItem = _GUICtrlComboBox_GetCurSel($hComboBox) If $iItem >= 0 Then $i = $iItem + 1 _GUICtrlListView_DeleteAllItems($hListView) GUICtrlCreateListViewItem($aData[$i][0] & "|" & $aData[$i][1] & "|" & $aData[$i][2] & "|" & $aData[$i][3], $ListView) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func _UpdateListView($sText) Local $sPattern = "" _GUICtrlListView_BeginUpdate($hListView) _GUICtrlListView_DeleteAllItems($hListView) If GUICtrlRead($CheckCase) = $GUI_CHECKED Then $sPattern &= "(?i)" If GUICtrlRead($CheckExact) = $GUI_CHECKED Then $sPattern &= "^\Q" & $sText & "\E$" Else $sPattern &= "\Q" & $sText & "\E" EndIf For $i = 1 To $aData[0][0] If StringRegExp($aData[$i][0], $sPattern) Then _ GUICtrlCreateListViewItem($aData[$i][0] & "|" & $aData[$i][1] & "|" & $aData[$i][2] & "|" & $aData[$i][3], $ListView) Next _GUICtrlListView_EndUpdate($hListView) EndFunc Func _Stations() Local $aReturn[13][5] = [[12], _ ; or load from an ini file ["Lollradio Dance (MP3 128K)", "Italy", "Dance/DJ", "Italian", "www.lollradiodance.com"], _ ["Lollradio Flashback (MP3 128K)", "Italy", "70s/80s", "Italian", "www.lollradioflashback.com"], _ ["Lollradio Happy (MP3 128K)", "Italy", "Adult Contemporary", "Italian", "www.lollradiohappy.com"], _ ["Lollradio Hits (MP3 128K)", "Italy", "Hit Radio", "Italian", "www.lollradiohits.com"], _ ["Lollradio Italia (MP3 128K)", "Italy", "Pop", "Italian", "www.lollradioitalia.com"], _ ["Lollradio Soft (MP3 128K)", "Italy", "Easy Listening", "Italian", "www.lollradiosoft.com"], _ ["Roflradio Dance (MP3 128K)", "Sweden", "Dance/DJ", "Swedish", "www.roflradiodance.com"], _ ["Roflradio Flashback (MP3 128K)", "Sweden", "70s/80s", "Swedish", "www.roflradioflashback.com"], _ ["Roflradio Happy (MP3 128K)", "Sweden", "Adult Contemporary", "Swedish", "www.roflradiohappy.com"], _ ["Roflradio Hits (MP3 128K)", "Sweden", "Hit Radio", "Swedish", "www.roflradiohits.com"], _ ["Roflradio Italia (MP3 128K)", "Sweden", "Pop", "Swedish", "www.roflradioitalia.com"], _ ["Roflradio Soft (MP3 128K)", "Sweden", "Easy Listening", "Swedish", "www.roflradiosoft.com"]] Return $aReturn EndFuncread tha information about ini file ...how can i modify that script to read information from the ini file ?I would like to do a application like this Hi! Thanks! Edited June 25, 2010 by AuToItItAlIaNlOv3R
PsaltyDS Posted June 25, 2010 Posted June 25, 2010 Get the list of all sections in the file with IniReadSectionNames(). For/Next loop through that list and do IniReadSection() on each one. For/Next loop through each section's array to find matching items. Add each matching item to the results list view. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
AuToItItAlIaNlOv3R Posted June 25, 2010 Author Posted June 25, 2010 i can't do it i've never work with ini file
PsaltyDS Posted June 25, 2010 Posted June 25, 2010 i can't do it i've never work with ini file Time to learn then. Start with the example scripts in the help file, under the Ini* functions. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
AuToItItAlIaNlOv3R Posted June 26, 2010 Author Posted June 26, 2010 I try to do a little code but i dont know how to do it $var = IniReadSectionNames(@DesktopDir & "\station.ini") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $i = 1 To $var[0] ;And Now? Next EndIf $section = IniReadSection (@DesktopDir & "\station.ini",$var[0]) For $i = 1 To $section[0] [0] ;And now? Next Plaese help me!
PsaltyDS Posted June 27, 2010 Posted June 27, 2010 Try this with various values of $sSearchValue: $sSearchValue = "Rock" ; Get 1D array of section names $aSectionNames = IniReadSectionNames(@DesktopDir & "\station.ini") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $s = 1 To $aSectionNames[0] ; Get 2D array of section values/data $aSection = IniReadSection(@DesktopDir & "\station.ini", $aSectionNames[$s]) If @error Then MsgBox(16, "Error", "Failed to read section: " & $aSectionNames[$s]) Else For $i = 1 To $aSection[0][0] If StringInStr($aSection[$i][0], $sSearchValue) Then ConsoleWrite("Section = " & $aSectionNames[$s] & "; Value = " & $aSection[$i][0] & "; Data = " & $aSection[$i][1] & @LF) EndIf Next EndIf Next EndIf Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Gogi02 Posted July 2, 2010 Posted July 2, 2010 Hope Author of the tread doesn't mind me hijacking the teme. I'm having kind of a similar problem. I have data stored in sqlite. I'd like to be able to wirte a query to search for data that contains certain word. For example if user inputs "Gogi" into search, script would return: Gogi Gogi02 Gogi_2 . . . All the strings in colum of the table that contain word Gogi. Or if that isn't possible than to export data to ini or txt file (I know how to do that), and than search that file. Thanks for your help in advance.
PsaltyDS Posted July 2, 2010 Posted July 2, 2010 Hope Author of the tread doesn't mind me hijacking the teme. I'm having kind of a similar problem. I have data stored in sqlite. I'd like to be able to wirte a query to search for data that contains certain word. For example if user inputs "Gogi" into search, script would return:GogiGogi02Gogi_2...All the strings in colum of the table that contain word Gogi. Or if that isn't possible than to export data to ini or txt file (I know how to do that), and than search that file.Thanks for your help in advance.For future reference, NO, don't hijack other people's topics. As to the question, learn to write SQL queries. You just need a WHERE/LIKE clause similar to: "SELECT * FROM YourTable WHERE YourField LIKE 'Gogi%'" Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now