Announcement

Collapse
No announcement yet.

Search: How to find any file containing search keyword

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Search: How to find any file containing search keyword

    Ok, a short description of my project...
    It contains all of the albums, singles, & songs by my favorite band. I have it so you can browse by album or single. You can choose to play the entire cd you've picked, or just a song from the cd(they are in .mp3 format). I would like to have a quick search feature where I can type in the name of the song, and it will bring back a list of songs found. However, I have only been able to get it to work by searching for the exact filename, which means I might as well have found it myself, as I would need to know the exact filename every time. I need to be able to type in "freak", and get back any file name that has the word "freak" in it. Another problem I'm having is, say I search for freaky.wav, it will find it, and when displayed in a listbox, I can double click it and it will play. I cannot seem to get it to do this with mp3s, or any other file type for that matter. Has anybody else had this problem? I have been trying to play around with it for days now.....HELP!!!
    I LOVE THIS PROGRAM!!!!!

  • #2
    Re: Search: How to find any file containing search keyword

    Hi RobbyH - You need to do a file search for anything containing the specified string, ie: *love* instead of: love
    Adding the wildcards will make all the difference.

    I made up a quick example for you which searched a directory and seemed to work very well.
    I added to a page an EditField Object a ListBox Object and a Text Object (for use as a button). You'll also need to create a global list called "files", unless you edit the code to the name you have chosen.

    The Actions for the button are thus:
    %ObjectText% = EditFieldObject[EditField1].GetText
    %Files% = File.Search ("*%ObjectText%*.mp3", CustomPaths)
    %FileCount% = String.CountDelimitedStrings ("%Files%", ";;")
    %w% = "0"
    <font color=blue>WHILE (%w% <= %FileCount%)</font color=blue>
    <font color=purple>%Full_Path% = String.GetDelimitedString ("%Files%", ";;", %w%)
    %Filename% = String.ParsePath ("%Full_Path%", Filename)
    GlobalList[files].Add (End, "%Filename%")
    %w% = Evaluate (%w% + 1)</font color=purple>
    <font color=blue>END WHILE</font color=blue>
    %ListItem% = GlobalList[files].GetItem (All)
    ListBoxObject[ListBox1].Add (End, "%ListItem%")

    and the Actions for the ListBox Object:
    </font color=purple>%ItemText% = ListBoxObject[ListBox1].GetItemText (Selected)
    MP3.Load ("D:\Music\mp3\Singles\%ItemText%")
    MP3.Play</font color=purple>

    - of course you'll need to change the path I have used to suit your own. You could even make the path a variable with a few more Actions [img]/ubbthreads/images/icons/smile.gif[/img]

    Here are the actions FYC:

    <font color=blue>[for the button]</font color=blue>
    <font color=green><IR_ACTIONS_LIST>
    <Action name="Get Text">
    <Type>78</Type>
    <Function>0</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Variable>%ObjectText%</Variable>
    <ObjectName>EditField1</ObjectName>
    </Action>
    <Action name="Search">
    <Type>18</Type>
    <Function>0</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Variable>%Files%</Variable>
    <Delimiter>;;</Delimiter>
    <FileName>*%ObjectText%*.mp3</FileName>
    <LocalFixedDrives>0</LocalFixedDrives>
    <RemoteDrives>0</RemoteDrives>
    <RemovableDrives>0</RemovableDrives>
    <CDROMDrives>0</CDROMDrives>
    <SpecificDirectoriesDrives>1</SpecificDirectoriesDrives>
    <CustomDirectoriesDrives>D:\Music\mp3\Singles</CustomDirectoriesDrives>
    <RecurseCustom>0</RecurseCustom>
    <DialogTitle>Searching for Files</DialogTitle>
    <DialogText>Searching for files. This may take a few moments.</DialogText>
    <ShowDialog>1</ShowDialog>
    </Action>
    <Action name="Count Delimited Strings">
    <Type>63</Type>
    <Function>0</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Variable>%FileCount%</Variable>
    <Source>%Files%</Source>
    <Delimiter>;;</Delimiter>
    </Action>
    <Action name="Set Value">
    <Type>6</Type>
    <Function>0</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Variable>%w%</Variable>
    <Value>0</Value>
    <Evaluate>0</Evaluate>
    </Action>
    <Action name="WHILE">
    <Type>204</Type>
    <Function>1</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Condition>%w% &amp;lt;= %FileCount%</Condition>
    </Action>
    <Action name="Get Delimited String">
    <Type>64</Type>
    <Function>0</Function>
    <DTIndentLevel>1</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Variable>%Full_Path%</Variable>
    <Source>%Files%</Source>
    <Delimiter>;;</Delimiter>
    <ItemIndex>%w%</ItemIndex>
    </Action>
    <Action name="Parse Path">
    <Type>62</Type>
    <Function>0</Function>
    <DTIndentLevel>1</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Variable>%Filename%</Variable>
    <Source>%Full_Path%</Source>
    <ParseType>4</ParseType>
    </Action>
    <Action name="Add">
    <Type>111</Type>
    <Function>0</Function>
    <DTIndentLevel>1</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <TargetList>files</TargetList>
    <AddType>1</AddType>
    <Index/>
    <Text>%Filename%</Text>
    <Delimiter>;;</Delimiter>
    </Action>
    <Action name="Set Value">
    <Type>6</Type>
    <Function>0</Function>
    <DTIndentLevel>1</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Variable>%w%</Variable>
    <Value>%w% + 1</Value>
    <Evaluate>1</Evaluate>
    </Action>
    <Action name="END WHILE">
    <Type>205</Type>
    <Function>1</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    </Action>
    <Action name="Get Item">
    <Type>112</Type>
    <Function>0</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <TargetList>files</TargetList>
    <GetType>1</GetType>
    <Index/>
    <IndexDelimiter>;;</IndexDelimiter>
    <Variable>%ListItem%</Variable>
    <VarDelimiter>;;</VarDelimiter>
    </Action>
    <Action name="Add">
    <Type>118</Type>
    <Function>0</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <TargetListBox>ListBox1</TargetListBox>
    <AddType>1</AddType>
    <Index/>
    <ItemToAdd>%ListItem%</ItemToAdd>
    <ItemDelimiter>;;</ItemDelimiter>
    </Action>
    </IR_ACTIONS_LIST></font color=green>

    <font color=blue>[and the list box]</font color=blue>
    <font color=green><IR_ACTIONS_LIST>
    <Action name="Get Item Text">
    <Type>117</Type>
    <Function>0</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <TargetListBox>ListBox1</TargetListBox>
    <GetType>0</GetType>
    <Index/>
    <IndexDelimiter>;;</IndexDelimiter>
    <Variable>%ItemText%</Variable>
    <VarDelimiter>;;</VarDelimiter>
    </Action>
    <Action name="Load">
    <Type>105</Type>
    <Function>0</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <MP3File>D:\Music\mp3\Singles\%ItemText%</MP3File>
    <External>1</External>
    </Action>
    <Action name="Play">
    <Type>106</Type>
    <Function>0</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    </Action>
    </IR_ACTIONS_LIST></font color=green>
    -
    = Derek
    ["All glory comes from daring to begin" - fortune cookie]

    Comment

    Working...
    X