Page 1 of 1

Function GoToDir(Path$)

Posted: Tue Aug 09, 2016 12:09 pm
by Dutchman
In my launcher (See viewtopic.php?f=20&t=1499) I wanted to have the facility to be redirected to a different folder. The function in the following test-program does the trick.

Code: Select all

'GoToDir()
'Function to activate a folder
Example$="/Examples/Editor Settings"
CALL GoToDir(Example$)
END

DEF GoToDir(Path$)
IF FILE_EXISTS(Path$) THEN
  File$=Path$&"/π Zombie.sb"
  IF FILE_EXISTS(File$) THEN FILE File$ DELETE
  FILE FILE$ PRINT "PRINT "&""""&"In "&Path$&""""
  FILE FILE$ PRINT "FILE "&""""&File$&""""&" DELETE"
  FILE FILE$ PRINT "END"
  RUN File$
ELSE
  TEXT ! TEXT CLEAR
  PRINT "Path '"&Path$&"' NOT found"
ENDIF
END DEF
It generates a program in the desired folder (directory) and gives the command to run it.
I have named that program "π Zombie.sb"
It will display the folder-name and delete itself. :D
If you press the '≣' button in the top bar then you'll see your desired folder and its contents. ;)
If, for some reason the file has not been deleted then, due to the "π"-character at the beginning of its name, it will be positioned at the lower end of the files-list. If you 'Run' it, it will delete itself.