File or Directory - Printable Version +- yab | yet another Basic for HAIKU (https://yab.orgfree.com/forum) +-- Forum: Programming in yab (https://yab.orgfree.com/forum/forumdisplay.php?fid=1) +--- Forum: Snippets (https://yab.orgfree.com/forum/forumdisplay.php?fid=3) +--- Thread: File or Directory (/showthread.php?tid=25) |
File or Directory - bbjimmy - 07-15-2015 Rre-posted and translated from http://www.beusergroup.de/ ( witrh permission from lelldorin. ab - File or directory Category: Applications Published on Saturday, 11 July 2015 19:34 Written by Christian Albrecht Hits: 13 How do I find out if I have a file or directory on a file panel or Dropzone must process? My solution in this regard includes an IF query and a subroutine. If statement: Code: Folder$=Quellvariable$ Subroutine: Code: sub IfDirectory(filename$) To find out if I have to process a directory or file on a file panel or drop zone, I commend my path to the variable Folder $ and use the test command to check whether I have passed a directory in the variable. If the check is positive, the number variable is_an_directory is set to 1 by the if statement. Is it not a directory, the value is set to 2. Example: No matter what is passed, it will detect the file path If statement: Code: if(IfDirectory(Quellvariable$)) then Subroutine: Code: sub IfDirectory(filename$) In this example, we are expanding this test and determine no matter what we ask for (file or directory) as the file path. "Not" determined the test command list, the source variable over an array (SplitFolderPath $ ()) is cut into its individual parts. To do this, for each "/" mark is applied a new entry in the array. After all array entries are reassembled, with the exception of the last entry. |