0

I downloaded the Myriad Tables Lib v1.0.8 AppleScript script library from here.

Run the following code, and you will notice that the code will run without error:

-- use script "Myriad Tables Lib" version "1.0.8"
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

on fetchStorableClipboard()
    set aMutableArray to current application's NSMutableArray's array() -- used to store contents
    -- get the pasteboard and then its pasteboard items
    set thePasteboard to current application's NSPasteboard's generalPasteboard()
    -- loop through pasteboard items
    repeat with anItem in thePasteboard's pasteboardItems()
        -- make a new pasteboard item to store existing item's stuff
        set newPBItem to current application's NSPasteboardItem's alloc()'s init()
        -- get the types of data stored on the pasteboard item
        set theTypes to anItem's types()
        -- for each type, get the corresponding data and store it all in the new pasteboard item
        repeat with aType in theTypes
            set theData to (anItem's dataForType:aType)'s mutableCopy()
            if theData is not missing value then
                (newPBItem's setData:theData forType:aType)
            end if
        end repeat
        -- add new pasteboard item to array
        (aMutableArray's addObject:newPBItem)
    end repeat
    return aMutableArray
end fetchStorableClipboard

Now, un-comment the very first line of this code:

use script "Myriad Tables Lib" version "1.0.8"

Once you compile your code, the following line:

set theTypes to anItem's types()

will automatically change to:

set theTypes to anItem's type {}

The issue is that types is changed to type. The effect is that this code no longer runs.

Does anyone know a workaround, or how to prevent this from occurring?

OS X El Capitan, version 10.11.6.

0

To get around this terminology conflict, use the following line:

set theTypes to anItem's |types|()

Here's more info (from this webpage):

You can force an illegal variable name to be legal by surrounding it with vertical bars, also known as "pipes."

The real effect of pipes is to tell AppleScript to suspend its compile-time parsing rules and turn what's inside the pipes into a token. The main reason this is genuinely useful is to avoid a conflict between a token name and a term already in use.

Note:

A variable name surrounded by pipes is case-sensitive. AppleScript will not touch the case of names in pipes after compilation.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .