using the livecode language a small app to accept a drag drop folder and files then…
- User
using the livecode language a small app to accept a drag drop folder and files then create a zip
- Assistant
- User
error command missing put the files of pPath into tFiles
- Assistant
The error
command missingon the lineput the files of pPath into tFilesmeans that LiveCode doesn't recognize the expressionthe files of pPath.In LiveCode, to list files inside a directory/folder, you typically use:
put files(pPath) into tFiles - User
error bad validation type if pItems is a list then
- Assistant
The error
bad validation typeon the lineif pItems is a list thenhappens because LiveCode's
is a listoperator expects a specially formatted string. Drag data (the parameterpItemsindragEnteranddragDrophandlers) is usually a return-delimited list of file paths, but LiveCode might treat it as a plain string, andis a listcan be too strict here.In practice, the safest way is to check whether
pItemscontains any return characters or at least non-empty text.
How to fix?
Replace:
if pItems is a list thenwith something like:
- User
error accept and reject drag are not valid commands accept drag else reject drag
- Assistant
In LiveCode, the drag-and-drop handlers use
accept dragDroporreject dragDropcommands in certain contexts, and sometimes those commands might not be recognized depending on where the handler is placed or your LiveCode version.In particular:
accept dragandreject dragare the old syntax.- In newer LiveCode versions and depending on where the code is, these might not be available.
- Actually, for controlling drag acceptance, in a
dragEnterhandler you return true (accept) or false (reject).
How to fix the
dragEnterhandler:Instead of:
- User
error command missing zip tZipFile with sFileList
- Assistant
- User
from the livecode dictionary -- Add a text file directly to the zip file, using the UTF-8 -- text encoding local tContent, tData put "Hello, world!" into tContent put textEncode(tContent, "utf-8") into tData revZipAddItemWithData tArchive, "hello-world.txt", "tData"
- Assistant
- User
the card is not accepting dropped files
- Assistant