Page 1 of 1

Beanshell + Java : file path problem

Posted: Thu Apr 17, 2008 12:06 pm
by tanith
Hi everybody,

i'm asked to develop an extension for Calc in Beanshell.
The beanshell code import Java classes, and one of them had to use File.getPath function. My problem goes from the result of this function. The string is like : ${$SYSBINDIR/bootstrap.ini::UserInstallation}... And Java cannot work whith a such path.

So my question is :

Is there a way to convert ${$SYSBINDIR/bootstrap.ini::UserInstallation} into a windows path ?

thanks for answering

Re: Beanshell + Java : file path problem

Posted: Thu Apr 17, 2008 1:45 pm
by Villeroy

Re: Beanshell + Java : file path problem

Posted: Thu Apr 17, 2008 3:16 pm
by tanith
Your information explain the form of my path...but it seems that i need get a filepath without using this Bootstrap system.

Thanks for your answer

Re: Beanshell + Java : file path problem

Posted: Sun Jun 01, 2008 1:26 pm
by ms777
you do not have to use the bootstrap mechanism to use the services mentioned in the links above. Try this beanshell script ...

Code: Select all

sInput = "${$SYSBINDIR/bootstrap.ini::UserInstallation}";

oMacroExpander = XSCRIPTCONTEXT.getComponentContext().getValueByName("/singletons/com.sun.star.util.theMacroExpander");
sOutput = oMacroExpander.expandMacros(sInput);

javax.swing.JOptionPane.showMessageDialog(null, sOutput, sInput, javax.swing.JOptionPane.WARNING_MESSAGE);

return 0;