Skip to main content

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

It doesn’t, but only because I simplified the example in my comment. I’m actually testing based on a column value, and I probably should have called my fake column “id” instead of “index”. In that case, a little testing in the listener gave me a workable pattern like the one you suggested. For example, testing if a row with id=5 exists looks like:

if 5 in grid.value.id
 # ...
end

…which looks much better, but unfortunately, my actual grid is using a compound key. Consider:

t:insert page id text with 1 1 "frst" 1 2 "scnd" 2 1 "pg2" end
# +------+------+------+
# | page |  id  | text |
# +------+------+------+
# |    1 |    1 | frst |
# |    1 |    2 | scnd |
# |    2 |    1 | pg2  |
# +------+------+------+

And what I want to do is check to see if a given entry is the last entry for that page, which I’m doing by checking to see if the entry afterwards exists. So:

p:1
i:2
if extract where page=p where id=i+1 from t
 0
else
 # this executes, as page 1 id 3 is not in the table
end

i:1
if extract where page=p where id=i+1 from t
 0
else
 # this doesn't, as page 1 id 2 is in the table
end

Maybe there’s a cleaner way to do this, but if there is, I haven’t found it yet.

Well, you can apply the "join" operator to a pair of lists to zip them together into tuples:

t.page join t.id
# ((1,1),(1,2),(2,1))

You can use the "in" operator to search for a tuple, but you'll have to enlist the tuple and then unpack the result from a count-1 list to avoid searching for individual components of the tuple in the zipped list:

(1,2) in t.page join t.id
# (0,0)
first (list 1,2) in t.page join t.id
# 1
first (list 1,3) in t.page join t.id
# 0