模型中的一些问题 window

Some problems in model window

我创建了一个模型 window(新子堆栈)用于在滚动字段中查找文本。但它不起作用我正在使用以下代码

下面的代码调用模态window

on mouseUp
modal stack "sub"
end mouseUp

以下代码用于在滚动字段中查找字符串

on mouseUp
     if field "EE" is empty  then
      answer "Please enter the filename" with "Ok"
   end if
   if field "EE" is not empty  then
      put the text of field "EE" into xx
      --answer xx
       repeat for each word myword in fld "MytextField"
if  fld "MytextField" contains xx then find xx in fld "MytextField"
           exit to top
  end repeat
      end if
end mouseUp

此处"MytextField"在主堆栈中

您没有解释 "not working" 的含义,但很可能是因为堆栈 "sub" 是不同的堆栈,您需要对该字段使用显式引用:

field "EE" of stack "myMainStack"

另一种选择是将 defaultStack 属性 设置为您的主堆栈的名称,这样您就不需要使用显式对象引用:

set the defaultStack to "myMainStack"
if field "EE" is empty then...

如果您需要引用子堆栈中的对象,请记住将 defaultStack 改回您的子堆栈。

您也不需要重复循环或 "contains" 的测试。循环没有做任何事情。你只需要

find xx in field "MytextField"

如果文本不存在,结果将为 "not found",否则文本将被加框。

   put the text of field "EE" into xx
   if xx is not empty then
       find xx in field "MytextField"                                          
      if the result is not empty then
         answer the result 
      end if
    end if