Livecode colorNames() 函数?

Livecode colorNames() function?

我正在尝试编写一个程序来删除名称中带有数字的所有颜色,然后将它们放入一个字段中。我 运行 遇到第 4 行的问题。有什么建议吗?

    on mouseup
       global choice
       put colorNames() into choice
       repeat for each line in choice
         if tcolor1 contains "1" || "2" then
             delete tcolor1 from choice
         end if
       end repeat
       put choice into fld "color list"
    end mouseup

这一行将所有不包含数字的颜色名称放入变量myList:

filter the colorNames without "*[0-9]*" into myList

您似乎忘记指定变量 -- tColor -- 来表示您的选择变量中的每一行。此外,当对每个使用 repeat 时,您最好构建一个新的所需结果列表,而不是尝试修改原始变量(选择)。

试试这样的东西:

on mouseUp
   global choice
   put colorNames() into temp
   repeat for each line tColor in temp
      if tColor contains "1" or tColor contains "2" then next repeat -- SKIP UNWANTED RESULTS
      put tColor & return after myColorList -- BUILD A NEW LIST
   end repeat
   delete last char of myColorList -- REMOVE THE LAST RETURN CHARACTER
   put myColorList into choice
   put myColorList into fld "color list"
end mouseUp

另请注意,您需要实际写出 "or"(假设您正在尝试这样做)——LiveCode 不使用该运算符的符号。