Получить переменные в другом файле скрипта - PullRequest
0 голосов
/ 30 октября 2018

Я использую команду «Выполнить скрипт» для запуска программы для другого файла. Но это не показало результатов. Результатом является переменная, как мне получить эту переменную?

Код 1:

set xxx to {"ni", "bu", "en"}
set xxx2 to {"hao", "bu", "ni", "bu", "hao"}

repeat with item_number in xxx2
set booleanlist to {}
repeat with item_number_2 in xxx

    if contents of item_number_2 is not contents of item_number then
        set end of booleanlist to true
    end if

    if contents of item_number_2 is contents of item_number then
        set end of booleanlist to false
    end if

end repeat
set booleanlist_number to 0
repeat with booleanlist_number_2 in booleanlist
    if contents of booleanlist_number_2 is true then
        set booleanlist_number to booleanlist_number + 1
    end if
    if contents of booleanlist_number_2 is false then
        exit repeat
    end if
end repeat

if booleanlist_number = (count item of xxx) then
    set end of xxx to contents of item_number
end if

end repeat

Код 2:

set xx to run script file "Macintosh HD:Users:mingxianzhao:Library:Mobile Documents:com~apple~ScriptEditor2:Documents:示例:run script and on run:Untitled.scpt" with parameters Character_used_for_the_query
choose from list xx

Ответы [ 2 ]

0 голосов
/ 30 октября 2018

Как уже сказано @ foo , вам нужно добавить строки return xxx в конец скрипта "Код 1".

Посмотрев на «Код 1», кажется, что вы пытаетесь объединить списки xxx и xxx2 в один список, но объединенный список содержит только одну копию каждого пункт, т.е. вы хотите набор уникальных предметов.

Это может быть сделано более эффективно и чисто, чем ваша нынешняя реализация:

set xxx to {"ni", "bu", "en"}
set xxx2 to {"hao", "bu", "ni", "bu", "hao"}

set xxx to xxx & xxx2

return unique(xxx) --> {"ni", "bu", "en", "hao"}


on unique(L)
    local L

    script
        property array : L
        property list : {}
    end script

    tell the result
        repeat with x in its array
            if x is not in its list then set ¬
                end of its list to x's contents
        end repeat

        its list
    end tell
end unique
0 голосов
/ 30 октября 2018

Добавьте return xxx в конец скрипта Code 1.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...