This is an example of source code capable of transferring data between two lists, SOURCE_OBJ and DEST_OBJ. COL1 and COL2 are columns in SOURCE_OBJ, and COL3 belongs to DEST_OBJ.
Three events must be managed:
/* Variables used
num_bin_4 ReturnCode
num_bin_4 ActionDone
bool AvailableFormat
num_bin_4 DataNumber
num_bin_4 Index
SOURCE_OBJ:DD_BeginDrag
/* enable drag and drop with the left mouse button (for example)
if SOURCE_OBJ:DD_MOUSE_STATE = _DD_LEFT_BTN
/* cancel any temporary data (as a precautionary measure)
call_method SOURCE_OBJ DD_CANCEL_DATA ReturnCode
/* specify the data to be transferred
read_lst SOURCE_OBJ:list *select
call_method SOURCE_OBJ DD_WRITE_DATA col1: 1 ReturnCode
call_method SOURCE_OBJ DD_WRITE_DATA col2: 1 ReturnCode
end_read_lst
/* start the drag and drop mechanism, enabling the data Copy
/* and Move actions
call_method SOURCE_OBJ DD_EXECUTE_DRAG 'MyFormat' -
_DD_ACTION_COPY_MOVE ActionDone ReturnCode
/* if the user has chosen the Move action, the data in the source
/* object must be deleted
if ActionDone = _DD_ACTION_MOVE
read_lst SOURCE_OBJ:list *select
delete_elt SOURCE_OBJ:list
end_read_lst
end
end
DEST_OBJ:DD_DragOver
/* with this event, you must specify what action would be performed
/* if the user released the mouse button; this is done using the
/* DD_ACTION_DROP property
/* default initialization
DEST_OBJ:DD_ACTION_DROP = _DD_ACTION_NONE
/* test whether the data format is supported by the destination object
call_method DEST_OBJ DD_DATA_AVAILABLE 'MyFormat' AvailableFormat ReturnCode
if AvailableFormat
/* process the actions permitted by the source
SWITCH DEST_OBJ:DD_ALLOWED_ACTIONS
if_value _DD_ACTION_COPY _DD_ACTION_MOVE
/* the user has no choice
DEST_OBJ:DD_ACTION_DROP = DEST_OBJ:DD_ALLOWED_ACTIONS
if_value _DD_ACTION_COPY_MOVE
/* keys are processed using the traditional convention:
/* if Ctrl is depressed, the user wants to copy the data; if not, they want
/* to move the data
if DEST_OBJ:DD_KEYBOARD_STATE = _DD_CTRL_KEY
DEST_OBJ:DD_ACTION_DROP = _DD_ACTION_COPY
else
DEST_OBJ:DD_ACTION_DROP = _DD_ACTION_MOVE
end
END_SWITCH
END
DEST_OBJ:GD_Drop
/* Read and process the transferred data
DataNumber = 1
Index = 1
call_method DEST_OBJ DD_READ_DATA 'MyFormat' col3: Index DataNumber ReturnCode
do_while DataNumber > 0
insert_elt DEST_OBJ:list
Index = Index + 1
call_method DEST_OBJ DD_READ_DATA 'MyFormat' col3: Index DataNumber ReturnCode
redo