Sign in to follow this  
Followers 0
Thatsgreat2345

Find Text Go to Next Line

13 posts in this topic

Is there anyway to find text in a file and then tell it to get what line that is then tell it to read the next line. Im making a music player and i want a playlist but i cant figure this out can anyone help me?

Share this post


Link to post
Share on other sites



I'm not quite sure I understand 100% but I used a comment to mark what I thought it might be you were asking:

#include <File.au3>
$sPath = FileOpenDialog('Open Files', @ScriptDir, 'All files (*.*)')
$FindAndSkip = 'If Found Skip'
FindStringThenSkip($sPath, $FindAndSkip)

Func FindStringThenSkip($sPath, $FindAndSkip, $LineNumberDesired = '', $TextDesired = '')
    Local $nArray
    Local $GetLine
    _FileReadToArray($sPath, $nArray)
    For $i = 1 To UBound($nArray) - 1
        If StringInStr($nArray[$i], $FindAndSkip) Then
        ;$GetLine = $GetLine & 'Found on Line: ' & $i & @LF
        ; or you could use
        ;If $i = $LineNumberDesired And $nArray[$i] = $TextDesired Then
               ;Do something
        ;EndIf
        EndIf
    Next
EndFunc


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

yeah i dont think u understood ill explain it a little clearer, basicaly i want it to search for certain text in a c:\program files\thatsgreat2345\playlist.txt

if it finds that text then it will read the text on the next line

Im gonna use this for my next and previous button in my music player eh the comments got screwed up

#include <GuiConstants.au3>

;--------------------------------------GUI START--------------------------------------------------------

GUICreate("Music Player V 1.1", 450, 400, 192, 125)
GUISetCursor (0)
GUISetBkColor(0x000000)
$List = GuiCtrlCreateList("", 150, 220, 110, 175)
$Add = GuiCtrlCreateButton("Add", 60, 240, 60, 20)
GUICtrlSetLimit(-1,200); to limit horizontal scrolling
$clear = GuiCtrlCreateButton("Clear", 60, 270, 60, 20)
$Play = GuiCtrlCreateButton("Play", 10, 10, 50, 20)
$Next = GuiCtrlCreateButton("Next", 70, 10, 50, 20)
$Mute = GuiCtrlCreateButton("Mute", 190, 10, 50, 20)
$stop = GuiCtrlCreateButton("Stop", 250, 10, 50, 20)
$exit = GuiCtrlCreateButton("Exit", 310, 10, 50, 20)
$previous = GuiCtrlCreateButton("Previous", 130, 10, 50, 20)
$slider = GUICtrlCreateSlider (150,50,100,40)
GUICtrlSetData($Slider,100)
GUICtrlSetLimit ($Slider,100,0)
$Label_8 = GuiCtrlCreateLabel("Thatsgreat2345", 10, 50, 80, 20)
GUICtrlSetResizing (-1,$GUI_DOCKLEFT)
GuiSetState()
;---------------------------------------GUI END---------------------------------------------------------
;----------------------------------DIM VARS-------------------------
Dim $play
Dim $Mute
dim $stop
Dim $exit
Dim $slider
DIm $msg
Dim $playlist
Dim $list
Dim $file
Dim $line
DIm $previous
;--------------DIM END
func stop()
    while 1
        sleep(100)
    wend
endfunc ;==>stop
;-------------start--------------------
Do
    
    $msg = GUIGetMsg ()
    Select
;------------------ STOP MUSIC-------------
        Case   $msg = $stop
            soundplay("C:\exit.mp3")
    ;---------------END STOP MUSIC---------
    ;--------- PLAY MUSIC ---------
        Case $msg = $play
            $line = FileReadLine(@ProgramFilesDir & "\Thatsgreat2345\Playlist.txt", 1)
            FileDelete(@ProgramFilesDir & "\Thatsgreat2345\Song.txt")
            FileInstall("C:\Documents and Settings\NEON\Desktop\song.txt", @ProgramFilesDir & "\Thatsgreat2345\song.txt")
            FileWrite(@ProgramFilesDir & "\Thatsgreat2345\song.txt", $line & @CRLF)
            Soundplay ($line)
    ;---------END PLAY MUSIC------
            
    ;--------------------------mute---------------
        Case $msg = $Mute
            send("{VOLUME_MUTE}")
    ;-----------END MUTE--------------
    ;------------------volume----------------
        Case $msg = $slider
            SoundSetWaveVolume (GUICtrlRead($slider))
    ;-------------END VOLUME---------------
    ;-------------------ADD SONG---------------
        Case $msg = $ADD
            $playlist=FileOpenDialog ("Choose music", "", "Musicfiles(*.mp3;*.wma;*.wav;*.wave;*.mid;*)")
            FileWrite(@ProgramFilesDir & "\Thatsgreat2345\Playlist.txt", $playlist & @CRLF)
            GUICtrlSetData($list, $playlist)
    ;-----------------END ADD SONG --------------------
    ;---------------------CLEAR SONG-------------------
        case $msg = $clear
            GUICtrlSetData($list,"")
            FileDelete(@ProgramFilesDir & "\Thatsgreat2345\Playlist.txt")
            FileInstall("C:\Documents and Settings\NEON\Desktop\Playlist.txt", @ProgramFilesDir & "\Thatsgreat2345\Playlist.txt")
    ;---------------------- END CLEAR SONG--------------------
    ;----------------------NEXT SONG----------------
        Case $msg = $Next
            $line = FileReadLine(@ProgramFilesDir & "\Thatsgreat2345\Playlist.txt", 1 + 1)
            FileDelete(@ProgramFilesDir & "\Thatsgreat2345\Song.txt")
            FileInstall("C:\Documents and Settings\NEON\Desktop\song.txt", @ProgramFilesDir & "\Thatsgreat2345\song.txt")
            FileWrite(@ProgramFilesDir & "\Thatsgreat2345\song.txt", $line & @CRLF)
            Soundplay ($line)
    ;------------------END NEXT SONG-----------------------
    ;-----------------PREVIOUS SONG--------------
        Case $msg = $previous
            $line = FileReadLine(@ProgramFilesDir & "\Thatsgreat2345\Playlist.txt", 2 - 1)
            FileDelete(@ProgramFilesDir & "\Thatsgreat2345\Song.txt")
            FileInstall("C:\Documents and Settings\NEON\Desktop\song.txt", @ProgramFilesDir & "\Thatsgreat2345\song.txt")
            FileWrite(@ProgramFilesDir & "\Thatsgreat2345\song.txt", $line & @CRLF)
            soundplay($line)
    ;---------------END PREVIOUS SONG----------------------
    ;-------------- EXIT-----------------------
        Case $msg = $exit

            exit
    EndSelect
Until $msg = $GUI_EVENT_CLOSE
;------------- END EXIT-----------------
Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

I think i know what you want. I will see what i can do.


"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
Share on other sites

yeah the NExt song and Previous song were just sumthin i was messing around with :P

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

This will get the next line... the previous and stuff I don't feel like doing at the moment... maybe kandie can figure that out... but it doesn't seem hard really.

#include <File.au3>
$sPath = FileOpenDialog('Open Files', @ScriptDir, 'All files (*.*)')
$TextToFind = 'If Found Skip'
FindStringThenSkip($sPath, $TextToFind)

Func FindStringThenSkip($sPath, $FindGetNextLine)
    Local $nArray
    Local $GetLine
    _FileReadToArray($sPath, $nArray)
    For $i = 1 To UBound($nArray) - 1
        If StringInStr($nArray[$i], $FindGetNextLine) Then
            $GetLine = $GetLine & $nArray[$i+1]
            ExitLoop
        EndIf
    Next
    Return $GetLine
EndFunc

Edit See if this works... I hope I made it self explanitory...

#include <GuiConstants.au3>
#include <File.au3>
#include <Array.au3>
;--------------------------------------GUI START--------------------------------------------------------

GUICreate("Music Player V 1.1", 450, 400, 192, 125)
GUISetCursor (0)
GUISetBkColor(0x000000)
$List = GuiCtrlCreateList("", 150, 220, 110, 175)
$Add = GuiCtrlCreateButton("Add", 60, 240, 60, 20)
GUICtrlSetLimit(-1,200); to limit horizontal scrolling
$clear = GuiCtrlCreateButton("Clear", 60, 270, 60, 20)
$Play = GuiCtrlCreateButton("Play", 10, 10, 50, 20)
$Next = GuiCtrlCreateButton("Next", 70, 10, 50, 20)
$Mute = GuiCtrlCreateButton("Mute", 190, 10, 50, 20)
$stop = GuiCtrlCreateButton("Stop", 250, 10, 50, 20)
$exit = GuiCtrlCreateButton("Exit", 310, 10, 50, 20)
$previous = GuiCtrlCreateButton("Previous", 130, 10, 50, 20)
$slider = GUICtrlCreateSlider (150,50,100,40)
GUICtrlSetData($Slider,100)
GUICtrlSetLimit ($Slider,100,0)
$Label_8 = GuiCtrlCreateLabel("Thatsgreat2345", 10, 50, 80, 20)
GUICtrlSetResizing (-1,$GUI_DOCKLEFT)
GuiSetState()
;---------------------------------------GUI END---------------------------------------------------------
;----------------------------------DIM VARS-------------------------
Dim $play
Dim $Mute
dim $stop
Dim $exit
Dim $slider
DIm $msg
Dim $playlist
Dim $list
Dim $file
Dim $line
DIm $previous
Dim $Count

;--------------DIM END
func stop()
    while 1
        sleep(100)
    wend
endfunc;==>stop
;-------------start--------------------
Do
    
    $msg = GUIGetMsg ()
    Select
;------------------ STOP MUSIC-------------
        Case   $msg = $stop
            soundplay("C:\exit.mp3")
   ;---------------END STOP MUSIC---------
   ;--------- PLAY MUSIC ---------
        Case $msg = $play
            $line = FileReadLine(@ProgramFilesDir & "\Thatsgreat2345\Playlist.txt", 1)
            FileDelete(@ProgramFilesDir & "\Thatsgreat2345\Song.txt")
            FileInstall("C:\Documents and Settings\NEON\Desktop\song.txt", @ProgramFilesDir & "\Thatsgreat2345\song.txt")
            FileWrite(@ProgramFilesDir & "\Thatsgreat2345\song.txt", $line & @CRLF)
            Soundplay ($line)
   ;---------END PLAY MUSIC------
            
   ;--------------------------mute---------------
        Case $msg = $Mute
            send("{VOLUME_MUTE}")
   ;-----------END MUTE--------------
   ;------------------volume----------------
        Case $msg = $slider
            SoundSetWaveVolume (GUICtrlRead($slider))
   ;-------------END VOLUME---------------
   ;-------------------ADD SONG---------------
        Case $msg = $ADD
            $playlist=FileOpenDialog ("Choose music", "", "Musicfiles(*.mp3;*.wma;*.wav;*.wave;*.mid;*)")
            FileWrite(@ProgramFilesDir & "\Thatsgreat2345\Playlist.txt", $playlist & @CRLF)
            GUICtrlSetData($list, $playlist)
   ;-----------------END ADD SONG --------------------
   ;---------------------CLEAR SONG-------------------
        case $msg = $clear
            GUICtrlSetData($list,"")
            FileDelete(@ProgramFilesDir & "\Thatsgreat2345\Playlist.txt")
            FileInstall("C:\Documents and Settings\NEON\Desktop\Playlist.txt", @ProgramFilesDir & "\Thatsgreat2345\Playlist.txt")
   ;---------------------- END CLEAR SONG--------------------
   ;----------------------NEXT SONG----------------
        Case $msg = $Next
            $sPath = 'Path To File'
            $TextToFind = 'Text To Find And Skip To Next Line'
            $Count = $Count + 1
            $MainArray = FindStringThenSkip($sPath, $TextToFind)
            If IsArray($MainArray) Then 
                If $Count <= UBound($MainArray) - 1 And $Count > 0 Then Soundplay($MainArray[$Count])
            EndIf
   ;------------------END NEXT SONG-----------------------
   ;-----------------PREVIOUS SONG--------------
        Case $msg = $previous
            $sPath = 'Path To File'
            $TextToFind = 'Text To Find And Skip To Next Line'
            $Count = $Count - 1
            $MainArray = FindStringThenSkip($sPath, $TextToFind)
            If IsArray($MainArray) Then 
                If $Count <= UBound($MainArray) - 1 And $Count > 0 Then Soundplay($MainArray[$Count])
            EndIf
   ;---------------END PREVIOUS SONG----------------------
   ;-------------- EXIT-----------------------
        Case $msg = $exit

            exit
    EndSelect
Until $msg = $GUI_EVENT_CLOSE
;------------- END EXIT-----------------

Func FindStringThenSkip($sPath, $FindGetNextLine)
    Local $nArray
    Local $GetLine
    _FileReadToArray($sPath, $nArray)
    For $i = 1 To UBound($nArray) - 1
        If StringInStr($nArray[$i], $FindGetNextLine) Then
            If $i < UBound($nArray) - 1 Then $GetLine = $GetLine & $nArray[$i+1] & Chr(01)
        EndIf
    Next
    Return StringSplit(StringTrimRight($GetLine, 1), Chr(01))
EndFunc
Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

thanks it works except i have to add in some stuff cuz it only gets the next song i think i know why its cuz of the play button writing to the song.txt and having the next button reading the song.txt haha wow that was confusing cuz im kinda confused

#include <GuiConstants.au3>
#include <File.au3>
#include <Array.au3>
;--------------------------------------GUI START--------------------------------------------------------

GUICreate("Music Player V 1.1", 450, 400, 192, 125)
GUISetCursor (0)
GUISetBkColor(0x000000)
$List = GuiCtrlCreateList("", 150, 220, 110, 175)
$Add = GuiCtrlCreateButton("Add", 60, 240, 60, 20)
GUICtrlSetLimit(-1,200); to limit horizontal scrolling
$clear = GuiCtrlCreateButton("Clear", 60, 270, 60, 20)
$Play = GuiCtrlCreateButton("Play", 10, 10, 50, 20)
$Next = GuiCtrlCreateButton("Next", 70, 10, 50, 20)
$Mute = GuiCtrlCreateButton("Mute", 190, 10, 50, 20)
$stop = GuiCtrlCreateButton("Stop", 250, 10, 50, 20)
$exit = GuiCtrlCreateButton("Exit", 310, 10, 50, 20)
$previous = GuiCtrlCreateButton("Previous", 130, 10, 50, 20)
$slider = GUICtrlCreateSlider (150,50,100,40)
GUICtrlSetData($Slider,100)
GUICtrlSetLimit ($Slider,100,0)
$Label_8 = GuiCtrlCreateLabel("Thatsgreat2345", 10, 50, 80, 20)
GUICtrlSetResizing (-1,$GUI_DOCKLEFT)
GuiSetState()
;---------------------------------------GUI END---------------------------------------------------------
;----------------------------------DIM VARS-------------------------
Dim $play
Dim $Mute
dim $stop
Dim $exit
Dim $slider
DIm $msg
Dim $playlist
Dim $list
Dim $file
Dim $line
DIm $previous
Dim $Count
Dim $4

;--------------DIM END
func stop()
    while 1
        sleep(100)
    wend
endfunc;==>stop
;-------------start--------------------
Do
    
    $msg = GUIGetMsg ()
    Select
;------------------ STOP MUSIC-------------
        Case   $msg = $stop
            soundplay("C:\exit.mp3")
  ;---------------END STOP MUSIC---------
  ;--------- PLAY MUSIC ---------
        Case $msg = $play
            $line = FileReadLine(@ProgramFilesDir & "\Thatsgreat2345\Playlist.txt", 1)
            FileDelete(@ProgramFilesDir & "\Thatsgreat2345\Song.txt")
            FileInstall("C:\Documents and Settings\NEON\Desktop\song.txt", @ProgramFilesDir & "\Thatsgreat2345\song.txt")
            FileWrite(@ProgramFilesDir & "\Thatsgreat2345\song.txt", $line & @CRLF)
            $4 = Filereadline("c:\Program Files\Thatsgreat2345\song.txt",1)
            Soundplay ($line)
  ;---------END PLAY MUSIC------
            
  ;--------------------------mute---------------
        Case $msg = $Mute
            send("{VOLUME_MUTE}")
  ;-----------END MUTE--------------
  ;------------------volume----------------
        Case $msg = $slider
            SoundSetWaveVolume (GUICtrlRead($slider))
  ;-------------END VOLUME---------------
  ;-------------------ADD SONG---------------
        Case $msg = $ADD
            $playlist=FileOpenDialog ("Choose music", "", "Musicfiles(*.mp3;*.wma;*.wav;*.wave;*.mid;*)")
            FileWrite(@ProgramFilesDir & "\Thatsgreat2345\Playlist.txt", $playlist & @CRLF)
            GUICtrlSetData($list, $playlist)
  ;-----------------END ADD SONG --------------------
  ;---------------------CLEAR SONG-------------------
        case $msg = $clear
            GUICtrlSetData($list,"")
            FileDelete(@ProgramFilesDir & "\Thatsgreat2345\Playlist.txt")
            FileInstall("C:\Documents and Settings\NEON\Desktop\Playlist.txt", @ProgramFilesDir & "\Thatsgreat2345\Playlist.txt")
  ;---------------------- END CLEAR SONG--------------------
  ;----------------------NEXT SONG----------------
        Case $msg = $Next
            $sPath = 'c:\Program Files\Thatsgreat2345\playlist.txt'
            $TextToFind = $4
            $Count = $Count + 1
            $MainArray = FindStringThenSkip($sPath, $TextToFind)
            If IsArray($MainArray) Then
                If $Count <= UBound($MainArray) - 1 And $Count > 0 Then Soundplay($MainArray[$Count])
            EndIf
  ;------------------END NEXT SONG-----------------------
  ;-----------------PREVIOUS SONG--------------
        Case $msg = $previous
            $sPath = 'c:\Program Files\Thatsgreat2345\playlist.txt'
            $TextToFind = $4
            $Count = $Count - 1
            $MainArray = FindStringThenSkip($sPath, $TextToFind)
            If IsArray($MainArray) Then
                If $Count <= UBound($MainArray) - 1 And $Count > 0 Then Soundplay($MainArray[$Count])
            EndIf
  ;---------------END PREVIOUS SONG----------------------
  ;-------------- EXIT-----------------------
        Case $msg = $exit

            exit
    EndSelect
Until $msg = $GUI_EVENT_CLOSE
;------------- END EXIT-----------------
Func FindStringThenSkip($sPath, $FindGetNextLine)
    Local $nArray
    Local $GetLine
    _FileReadToArray($sPath, $nArray)
    For $i = 1 To UBound($nArray) - 1
        If StringInStr($nArray[$i], $FindGetNextLine) Then
            If $i < UBound($nArray) - 1 Then $GetLine = $GetLine & $nArray[$i+1] & Chr(01)
        EndIf
    Next
    Return StringSplit(StringTrimRight($GetLine, 1), Chr(01))
EndFunc
Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Oh noes, i was beaten. :P Anyway, may i ask you why you are using the fileinstall function? If the file you are using is blank, which i think it is, then the easiest way to achieve what you want would be to use the _FileCreate function. Anyway, here is what i have, though it isn't as 1337(elite) as SmOke N.

I would suggest using his thing for the Next and Previous, but you may want to add the things i added.

#include <GuiConstants.au3>
#include <File.au3>
;--------------------------------------GUI START--------------------------------------------------------

GUICreate("Music Player V 1.1", 450, 400, 192, 125)
GUISetCursor (0)
GUISetBkColor(0x000000)
$List = GuiCtrlCreateList("", 150, 220, 275, 175)
$Add = GuiCtrlCreateButton("Add", 60, 240, 60, 20)
GUICtrlSetLimit(-1,200); to limit horizontal scrolling
$clear = GuiCtrlCreateButton("Clear", 60, 270, 60, 20)
$Play = GuiCtrlCreateButton("Play", 10, 10, 50, 20)
$Next = GuiCtrlCreateButton("Next", 70, 10, 50, 20)
$Mute = GuiCtrlCreateButton("Mute", 190, 10, 50, 20)
$stop = GuiCtrlCreateButton("Stop", 250, 10, 50, 20)
$exit = GuiCtrlCreateButton("Exit", 310, 10, 50, 20)
$previous = GuiCtrlCreateButton("Previous", 130, 10, 50, 20)
$slider = GUICtrlCreateSlider (150,50,100,40)
GUICtrlSetData($Slider,100)
GUICtrlSetLimit ($Slider,100,0)
$Label_8 = GuiCtrlCreateLabel("Thatsgreat2345", 10, 50, 80, 20)
GUICtrlSetResizing (-1,$GUI_DOCKLEFT)


;opens the playlist and then puts all the songs in the playlist file in the listbox
$filehandle = Fileopen(@ProgramFilesDir & "\Thatsgreat2345\Playlist.txt",0)

while 1
Local $Line = FileReadLine($filehandle)
    If @error Then ExitLoop
    GUICtrlSetData($list, $Line & "|")
Wend

Fileclose($filehandle)

GuiSetState()
;---------------------------------------GUI END---------------------------------------------------------
;----------------------------------DIM VARS-------------------------
Dim $play
Dim $Mute
dim $stop
Dim $exit
Dim $slider
DIm $msg
Dim $playlist
Dim $list
Dim $file
Dim $line
DIm $previous
dim $playlistpath = @ProgramFilesDir & "\Thatsgreat2345\Playlist.txt"
dim $songlistpath = @ProgramFilesDir & "\Thatsgreat2345\song.txt"
Global $linenumber = 1
;--------------DIM END
func stop()
    while 1
        sleep(100)
    wend
endfunc;==>stop
;-------------start--------------------
Do
    
    $msg = GUIGetMsg ()
    Select
;------------------ STOP MUSIC-------------
        Case   $msg = $stop
            soundplay("C:\exit.mp3")
  ;---------------END STOP MUSIC---------
  ;--------- PLAY MUSIC ---------
        Case $msg = $play
            $line = FileReadLine($playlistpath, $linenumber)
            FileDelete($songlistpath)
          ;FileInstall("C:\Documents and Settings\NEON\Desktop\song.txt", $songlistpath)
            _FileCreate($songlistpath)
            FileWrite($songlistpath, $line & @CRLF)
            Soundplay ($line)
  ;---------END PLAY MUSIC------
            
  ;--------------------------mute---------------
        Case $msg = $Mute
            send("{VOLUME_MUTE}")
  ;-----------END MUTE--------------
  ;------------------volume----------------
        Case $msg = $slider
            SoundSetWaveVolume (GUICtrlRead($slider))
  ;-------------END VOLUME---------------
  ;-------------------ADD SONG---------------
        Case $msg = $ADD
            $playlist=FileOpenDialog ("Choose music", "", "Musicfiles(*.mp3;*.wma;*.wav;*.wave;*.mid;*)")
            If not @error Then
                FileWrite($playlistpath, $playlist & @CRLF)
                GUICtrlSetData($list, $playlist)
            Endif
  ;-----------------END ADD SONG --------------------
  ;---------------------CLEAR SONG-------------------
        case $msg = $clear
            GUICtrlSetData($list,"")
            FileDelete($playlistpath)
          ;FileInstall("C:\Documents and Settings\NEON\Desktop\Playlist.txt", $playlistpath)
            _FileCreate($playlistpath)
  ;---------------------- END CLEAR SONG--------------------
  ;----------------------NEXT SONG----------------
        Case $msg = $Next
            If $linenumber <> _FileCountLines($playlistpath) Then
                $linenumber = $linenumber + 1
                $line = FileReadLine($playlistpath, $linenumber)
                FileDelete($songlistpath)
                _FileCreate($songlistpath)
        ; FileInstall("C:\Documents and Settings\NEON\Desktop\song.txt", $songlistpath)
                FileWrite($songlistpath, $line & @CRLF)
                Soundplay ($line)
            Endif
  ;------------------END NEXT SONG-----------------------
  ;-----------------PREVIOUS SONG--------------
        Case $msg = $previous
            If $linenumber > 1 Then
                $linenumber = $linenumber - 1
                $line = FileReadLine($playlistpath, $linenumber)
                FileDelete($songlistpath)
        ; FileInstall("C:\Documents and Settings\NEON\Desktop\song.txt", $songlistpath)
                _FileCreate($songlistpath)
                FileWrite($songlistpath, $line & @CRLF)
                soundplay($line)
            Endif
  ;---------------END PREVIOUS SONG----------------------
  ;-------------- EXIT-----------------------
        Case $msg = $exit

            exit
    EndSelect
Until $msg = $GUI_EVENT_CLOSE
;------------- END EXIT--------

I added a little thing at the end of your GUI that updates the listview with the contents of the playlist file when the script is first run. I also added error handling to your add to playlist button(no longer adds a 1 to the playlist if someone clicks cancel on the dialogue). I also added in the filecreate function and commented out your fileinstall. I believe your fileinstall installed an empty file, but if i am wrong then comment them out and delete my filecreate functions.

The next and previous buttons both work.

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

thx ill test urs out kandie im tired and need all the help i can get right now :P

hey kandie thanks i think urs is workin and i got smoke Ns to work to i think :lmao: thanks for all the help

that was just the big problem was having it read the song.txt and making it play it and all and writing from the playlist and blah

Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

Oh noes, i was beaten. :lmao: Anyway, may i ask you why you are using the fileinstall function? If the file you are using is blank, which i think it is, then the easiest way to achieve what you want would be to use the _FileCreate function. Anyway, here is what i have, though it isn't as 1337(elite) as SmOke N.

Wasn't a race Kandie... my wife decided to go out with her sisters (there's trouble :P ) so I decided to look at it again... Yours looks good, and should do what he wants... I just tend to look deeper into things than maybe I should...


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

haha yeah just one quick quesiton if the directory for example Thatsgreat2345 isnt made will it make it automaticaly?

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

I don't think so. Just add this to the beginning of the script:

If Not FileExists (@ProgramFilesDir & "\Thatsgreat2345\") Then
DirCreate(@ProgramFilesDir & "\Thatsgreat2345\")
EndIf
Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
Share on other sites

Are you talking to me?... Cuz I didn't look at your code at all.. so I don't know what your talking about :P... I just inserted it in the Next / Previous locations...:lmao:


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
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
Sign in to follow this  
Followers 0