View Single Post
Old 03-20-2021, 08:46 PM   #7
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,500
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by capink View Post
Code:
program:
    f = field('#taglike');
    icons = '';
    sep = ':';
    icon_expression = 'film.png=^Some Movie|Some Other Movie$,iconforseries.png=One Entry of a Game Series';
    for item in icon_expression:
        icon = re(item, '(.+)=(.+)', '\1');
        expression = re(item, '(.+)=(.+)', '\2');
        val = contains(f, expression, icon, '');
        if val then
            icons = list_union(icons, val, sep)
        fi
    rof;
    ifempty(icons, 'unknown.png')
FWIW this is a good place to use list_split(). Without testing it, the for loop could be rewritten as
Code:
    for item in icon_expression:
        list_split(item, '=', 'part');
        if part_1 in f then
            icons = list_union(icons, part_0, sep)
        fi
    rof;
chaley is offline   Reply With Quote