Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+3)

Hello! I'm making a contraption that allows for you to search data on a hidden grid in the contraption itself. I want the user to be able to configure the columns that are shown when the search is done, and also to configure the column that will be the target of the search (the one that is used in the query). I tried the following code:

on click do
 # Variables to shorten the query line
 srch:search_col_val.text
 show:show_col_val.text
 term:search_terms.text
 # Query
 result:select show where srch like term from internal_copy.value
 # Display results
 search_entries.value:result
end

Where "search_col_val", "show_col_val" and "search_terms" are fields (with only search_terms being visible), "search_entries" being the visible search results grid, and "internal_copy" being the grid that is being searched.

I expected the query to show the elements whose searched column matches the search terms, but instead I get the value of show_col_val. How can I make this query do what I want it to do?

(+2)

Your "srch" and "show" variables contain strings. In the context of a query subexpression they will be interpreted as string values, not the contents of a column by name. You can, however, use the implicit "column" dictionary to perform this indirection, something like

result:select column[show] where column[srch] like term from internal_copy.value

(the "column" dictionary is also how you can reference columns whose names are not valid lil identifiers.)

You might want to take a look at the examples for the "_hideby" column in grids; it's designed to assist in searching and filtering grid contents without requiring an auxiliary source of truth.