ACCEPTFILEDROP: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 22: Line 22:
''Example:'' Accepting files dragged from a folder and processing the list received sequentially.
''Example:'' Accepting files dragged from a folder and processing the list received sequentially.
{{CodeStart}}
{{CodeStart}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(128, 25, 0)
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}({{Text|128|#F580B1}}, {{Text|25|#F580B1}}, {{Text|0|#F580B1}})


{{Cl|_ACCEPTFILEDROP}} 'enables drag/drop functionality
{{Cl|_ACCEPTFILEDROP}} {{Text|<nowiki>'enables drag/drop functionality</nowiki>|#919191}}
{{Cl|PRINT}} "Drag files from a folder and drop them in this window..."
{{Cl|PRINT}} {{Text|<nowiki>"Drag files from a folder and drop them in this window..."</nowiki>|#FFB100}}


{{Cl|DO}}
{{Cl|DO}}
     {{Cl|IF}} {{Cl|_TOTALDROPPEDFILES}} {{Cl|THEN}}
     {{Cl|IF}} {{Cl|_TOTALDROPPEDFILES}} {{Cl|THEN}}
         {{Cl|FOR}} i = 1 {{Cl|TO}} {{Cl|_TOTALDROPPEDFILES}}
         {{Cl|FOR}} i = {{Text|1|#F580B1}} {{Cl|TO}} {{Cl|_TOTALDROPPEDFILES}}
             a$ = {{Cl|_DROPPEDFILE}} 'reads the list sequentially; when the result is empty ("") it means the list is over
             a$ = {{Cl|_DROPPEDFILE}} {{Text|<nowiki>'reads the list sequentially; when the result is empty ("") it means the list is over</nowiki>|#919191}}
             {{Cl|COLOR}} 15
             {{Cl|COLOR}} {{Text|15|#F580B1}}
             {{Cl|PRINT}} i,
             {{Cl|PRINT}} i,
             {{Cl|IF}} {{Cl|_FILEEXISTS}}(a$) {{Cl|THEN}}
             {{Cl|IF}} {{Cl|_FILEEXISTS}}(a$) {{Cl|THEN}}
                 {{Cl|COLOR}} 2: {{Cl|PRINT}} "file",
                 {{Cl|COLOR}} {{Text|2|#F580B1}}: {{Cl|PRINT}} {{Text|<nowiki>"file"</nowiki>|#FFB100}},
             {{Cl|ELSE}}
             {{Cl|ELSE}}
                 {{Cl|IF}} {{Cl|_DIREXISTS}}(a$) {{Cl|THEN}}
                 {{Cl|IF}} {{Cl|_DIREXISTS}}(a$) {{Cl|THEN}}
                     {{Cl|COLOR}} 3: {{Cl|PRINT}} "folder",
                     {{Cl|COLOR}} {{Text|3|#F580B1}}: {{Cl|PRINT}} {{Text|<nowiki>"folder"</nowiki>|#FFB100}},
                 {{Cl|ELSE}}
                 {{Cl|ELSE}}
                     {{Cl|COLOR}} 4: {{Cl|PRINT}} "not found", 'highly unlikely, but who knows?
                     {{Cl|COLOR}} {{Text|4|#F580B1}}: {{Cl|PRINT}} {{Text|<nowiki>"not found"</nowiki>|#FFB100}}, {{Text|<nowiki>'highly unlikely, but who knows?</nowiki>|#919191}}
                 {{Cl|END IF}}
                 {{Cl|END IF}}
             {{Cl|END IF}}
             {{Cl|END IF}}
             {{Cl|COLOR}} 15
             {{Cl|COLOR}} {{Text|15|#F580B1}}
             {{Cl|PRINT}} a$
             {{Cl|PRINT}} a$
         {{Cl|NEXT}}
         {{Cl|NEXT}}
     {{Cl|END IF}}
     {{Cl|END IF}}


     {{Cl|_LIMIT}} 30
     {{Cl|_LIMIT}} {{Text|30|#F580B1}}
{{Cl|LOOP}}
{{Cl|LOOP}}
{{CodeEnd}}
{{CodeEnd}}

Latest revision as of 13:02, 19 March 2023

The _ACCEPTFILEDROP statement prepares a program window to receive files dropped from Windows Explorer in a drag/drop operation.


Syntax

_ACCEPTFILEDROP [{ON|OFF}]


Description


Availability

  • Version 1.3 and up.


Examples

Example: Accepting files dragged from a folder and processing the list received sequentially.

SCREEN _NEWIMAGE(128, 25, 0)

_ACCEPTFILEDROP 'enables drag/drop functionality
PRINT "Drag files from a folder and drop them in this window..."

DO
    IF _TOTALDROPPEDFILES THEN
        FOR i = 1 TO _TOTALDROPPEDFILES
            a$ = _DROPPEDFILE 'reads the list sequentially; when the result is empty ("") it means the list is over
            COLOR 15
            PRINT i,
            IF _FILEEXISTS(a$) THEN
                COLOR 2: PRINT "file",
            ELSE
                IF _DIREXISTS(a$) THEN
                    COLOR 3: PRINT "folder",
                ELSE
                    COLOR 4: PRINT "not found", 'highly unlikely, but who knows?
                END IF
            END IF
            COLOR 15
            PRINT a$
        NEXT
    END IF

    _LIMIT 30
LOOP


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link