Advanced filtering in table

Discussion in 'Questions (Windows Mobile)' started by ghale, Aug 5, 2009.

  1. ghale

    ghale Active Member Licensed User

    I'm building a search function but I'm stalled on a particular request I've received. :BangHead:

    Some users tell me they need to find in a populated table (not SQLite) words that contain at least a capitalized characters (the characters can be in every position of the word).

    How can I accomplish this?
    I have to use regular expressions?

    I'm using for other simple search the table.Filter function.
    Can .Filter and regular expressions be mixed up to give a powerful search function for table?

    Or I have to choose ONE of the TWO way to do a search (or .Filter or regular expression)?

  2. Ariel_Z

    Ariel_Z Active Member Licensed User

    How long is the table? Is it practical to search through all cells with a For loop?
  3. ghale

    ghale Active Member Licensed User

    Well, the table can contain from few rows up to 1000 rows.

    The problem is that users must search for any characters in the table, so I'm using .Filter method to filter table rows.

    Some user ask me to implement a "capitalized word search", in which the table must shows words with at least a capitalized character in it.

    The users can mix the search, for example they can search for words that are capitalized and that contains character "x" in them.

    I'm thinking about regular expressions, but I don't have idea how to user .Filter with regular expressions.

    If you think that a for loop is a good way to do this, how I can use it with the .Filter method, if possibile?
  4. Ariel_Z

    Ariel_Z Active Member Licensed User

    Do you know how to find if the desiered letter is found in just a simple string variable?

    If you do, it may be practical and simple to loop through the cells.
  5. ghale

    ghale Active Member Licensed User

    Sorry but I've not understood!

    Actually I use table.Filter("colname LIKE '*CHARS*'")
    where CHARS is the string users insert.

    The function I want to implement is "simple".
    I want to show all words that contains at least one capitalized chars. The chars can be one of the alphabet, I have not to specify this.

    Can you repeat your question, please?
    My english is not very good, today.
  6. copiloto

    copiloto Member Licensed User


    I'd do it in this way:

    first variable=table1.cell("column name",x)

    if first variable<>strtolower(first variable) then
    get it!!
    end if

    Perhaps is not the best or the faster solution, but it should work!!

    Another posible solution is to create another table similar to this, but you must convert all the cells to strtolower(table1.cell("column name",x)).
    Then you can easy comparate the same register of the two tables:

    if table1.cell("column name",x)=table2.cell("column name",x) then ......

    This last case is good if you plan to work very fast and intensive with this table...

    Last edited: Aug 5, 2009
  7. ghale

    ghale Active Member Licensed User

    Mmmhh, interesting.
    But how you can use this code and show only data that has capitalized characters in it?
    One solution can be to remove data that doesn't match, but I need all data, I have only to show (filter) a lot of rows and see only the rows that has capitalized text in that.

    Thanks for the suggestion, however.
  8. specci48

    specci48 Well-Known Member Licensed User

    Have you already thought about a second table?

    A possible workaround could be:
    Store all your data in an "internal" (non visible) table. Now write a "filter"-routine on your own and fill the second (visible) table with all rows matching your search criteria. If no filter ist needed, just fill the visible table with all available rows of the invisible one.

  9. ghale

    ghale Active Member Licensed User

    Yes, I'm working on a prototype using two tables, but at the end the solution is too heavy to implement.

    I'm searching for something that uses minus "tricks".

    So, eventually if I have to "associate" normal filtering with capitalized words, I can FIRST find capitalized words, the copy all this rows to the visible table, then use .Filter method on this table. Or not?

    I'm implementing all this in the application you find here, to understand.

    When I filter the table, at the end I have to save on a file all data on the tabel, including hidden (filtered) values.

    So, I think that it's impossible to achieve what I need.
    Last edited: Aug 5, 2009
  10. ghale

    ghale Active Member Licensed User

    This tiny code found a capitalized character in a string:

    Sub Globals
    'Declare the global variables here.
    End Sub

    Sub App_Start
        testString = 
    "this iS a string"
    If Regex.IsMatch(testString) Then
    Msgbox("Found Capital Letter(s)!")
    End If
    End Sub
    There is a way to merge this with a .Filter method for a Table object?
  11. ghale

    ghale Active Member Licensed User

    In theory, if I create a hidden (width = 0) column called for example Capitalized, and then set it to 1 (true) or 0 (false) according to the Regex.IsMatch,
    I can then use .Filter method like:
    table.Filter("colum1 LIKE 'something' AND Capitalized = 1")

    In this way I think I can accomplish "normal" filtering + regex results.

    Any comment?
    Last edited: Aug 5, 2009
  12. ghale

    ghale Active Member Licensed User

    Yes, it works very good!

    I'm releasing an updated version of my application. :sign0060:
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice