598 posts
Location
The United States
Posted 18 July 2014 - 03:01 AM
From what I've read
here, I believe I'm using it correctly, but the output of this should be "Test2/test" or something similar to that (since my program is in that exact root"
This is my code.
print(shell.resolve(""))
And there is no output. If I do this,
print(shell.resolve("Test!"))
Then it just prints "Test!".
Again, my program is named "test" and is in the folder "Test2" which is in root. Please help, this is getting very annoying.
7083 posts
Location
Tasmania (AU)
Posted 18 July 2014 - 03:16 AM
Lemme guess, you're not in the "Test2" folder when you run "test"?
shell.getRunningProgram() gives you the path to the currently running script.
fs.getDir() (CC1.63+) hands you the folder the file at the end of a given path is stored in (by discarding the last slash in the string along with everything that follows it).
598 posts
Location
The United States
Posted 18 July 2014 - 03:18 AM
Lemme guess, you're not in the "Test2" folder when you run "test"?
shell.getRunningProgram() gives you the path to the currently running script.
fs.getDir() (CC1.63+) hands you the folder the file at the end of a given path is stored in (by discarding the last slash in the string along with everything that follows it).
Okay, thank you, I'll try that and see if it works.
Edit: Yep! It worked! Thank you so much Bomb Bloke :D/>
Edited on 18 July 2014 - 01:19 AM
7508 posts
Location
Australia
Posted 18 July 2014 - 03:28 AM
Just to clear things up further and actually explain why
shell.resolve didn't work… Taking a look at the
source for
shell.resolve you'll find that it doesn't find your program for you. It simply resolves the path you supply it, for example if you supply it with
//rom/..//Test2/test it will resolve that to
Test2/test. If searching for a program in rom/programs whether it is by the program name or via an alias you can use
shell.resolveProgram. As Bomb Bloke stated however you can use
shell.getRunningProgram to find out the path of the currently running program. He also stated that you can get the directory with
fs.getDir, you can also get the filename with
fs.getName. It should be noted that if you're using CC1.6+ and you want to find a file, you can also use
fs.find.