Jump to content




Shell Resolve won't work?


  • You cannot reply to this topic
3 replies to this topic

#1 Saldor010

  • Members
  • 467 posts
  • LocationThe United States

Posted 18 July 2014 - 02: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.

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 18 July 2014 - 02: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).

#3 Saldor010

  • Members
  • 467 posts
  • LocationThe United States

Posted 18 July 2014 - 02:18 AM

View PostBomb Bloke, on 18 July 2014 - 02:16 AM, said:

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 by Jiloacom, 18 July 2014 - 02:19 AM.


#4 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 18 July 2014 - 02: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.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users