The filebookmark( function converts a file or folder path into a binary data value that persistently links to the file, even if it is later moved or renamed.
This function has one parameter:
path – path to the file.
This function converts a file or folder path into a binary data value that persistently links to the file, even if it is later moved or renamed. If you are going to save a path permanently (in a database or file), you should use a bookmark instead of saving the text of the path. This example allows the user to choose an image with a dialog, then saves the name and location of that image in the myAvatar permanent variable.
local fileChoice choosefileDialog fileChoice,".jpg.gif.png" if fileChoice="" return endif letpermanent myAvatar = filebookmark(fileChoice)
Later, the current path and name of the file can be extracted from the permanent variable by using the bookmarkpath( function. This will work even if the file has been moved or renamed since the user chose the file (of course it will return an error if the file has been deleted).
let avatarImagePath = bookmarkpath(myAvatar)
|10.2||New||New in this version.|