CommandHelper

CommandHelper

46.5k Downloads

strange behavior with file_resolve() and other java file functions

LadyCailinBot opened this issue ยท 3 comments

commented

CMDHELPER-3073 - Reported by Mac.Niv

CH BUILD: #2884

I noticed file_resolve() is not running correctly. If I would use it in interpreter mode I am still getting the "Unknown command" message, like it isn't running correctly. This on it's own wouldn't be a big deal, but I am getting similar issues with a new function I am working on to get a parent directory of a file. It will also say the "Unknown command" message in the chat.

Now this is not the only thing that happens with this function. Let's say we have a file located as "directory1/directory2/file". if we would now use my function and do get_parent_dir('directory1/directory2/file'), it would return 'directory1/directory2', just like expected. But when we would do get_parent_dir(get_parent_dir('directory1/directory2/file')) it will somehow end up returning: 'directory1/directory2/directory/1'. It seems like it is appending the directory of directory2 onto the directory of the file.

I enclosed my function in a text document with this report

I have no idea if this is a bug or not or if I am doing something horribly wrong here. I hope someone could help me with these bugs :P

commented

Comment by Pieter12345

Please don't report bugs in your own extension. They are not bugs in CommandHelper. If you are getting "Unknown command", you are not in interpreter mode. Please update to the latest version of CommandHelper.

To get the parent directory of a file, you can script (in MS):
@filename = 'main.msa'
@Parts = split('/', file_resolve(@filename))
array_remove(@Parts, array_size(@Parts) - 1)
@parentPath = array_implode(@Parts, '/')
msg('Parent folder path: '.@parentPath)

commented

Comment by PseudoKnight

I think I know what's happening here with file_resolve() and "Unknown Command". If in interpreter mode, the output of file_resolve() starts with "/", which runs it as a command here:

https://github.com/EngineHub/CommandHelper/blob/master/src/main/java/com/laytonsmith/commandhelper/CommandHelperInterpreterListener.java#L171

commented

Comment by PseudoKnight

Ya, first problem is just macro support and second is unrelated to CH. Going to close.