To fully-import an external file into the cast, use the importFileInto command:
importFileInto cast whichCast, whichFileThis will place the contents of whichFile into whichCast, regardless of whether there is something in the cast already (assuming the file named in whichFile actually exists).
To add a linked castmember on the fly, use the fileName of cast property:
set the fileName of cast whichCast = newFileNameThis only works if whichCast already contains a linked castmember. Unlinked casts can't have their filenames reassigned because they don't have 'em. However, you can easily add new linked castmembers by doing something like this:
-- keep a small linked castmember in cast "dummyLink"
-- if you've a large cast it's probably more efficient to
-- reference this by its number rather than the name
on createNewLink newFileName
-- locate an empty cast slot to use
put findEmpty(cast 1) into newCast
-- copy our dummy linked cast into it
duplicate cast "dummyLink", cast newCast
-- reset its filename
set the fileName of cast newCast = newFileName
-- return the cast number so we know where it is for future use
return newCast
end createNewLink
When linking external files on the fly, it's important to ensure that the files really are where you expect them. Judicious use of the pathName function can save a lot of grief.
In addition to the above methods, the FileIO XObject provides a method called mReadPict which allows you to import a PICT file on the fly. However, in all cases that I can think of, this has been rendered superfluous by the internal methods described above (as a general rule: if you can do it more efficiently in Lingo, don't use an XObject).