-
1. Re: Error while loading an XML document using a structured application
Russ Ward Apr 4, 2014 4:28 AM (in response to pieratt)Hi,
My guess is that the script can't find the file you want to open, not that it can't find structapps.fm. One question... what is this?
var filename = myLastFile.openDlg("Choose XML file ...", "*.xml", false);
Did you define this yourself? Have you tested 'filename' after the call? Try something like this afterwards to see what FrameMaker is actually trying to open:
alert(filename);
Russ
-
2. Re: Error while loading an XML document using a structured application
Russ Ward Apr 4, 2014 4:32 AM (in response to Russ Ward)Postscript... I realize now that openDlg() might be some core javascript method that I'm not familiar with, although I can't find much about it. In any case, see what filename equals afterwards. If it equals nothing, that is your problem. Consider using the FM ExtendScript method instead:
ChooseFile(title, directory, stuffVal, mode)
Russ
-
3. Re: Error while loading an XML document using a structured application
frameexpert Apr 4, 2014 4:41 AM (in response to pieratt)Hi Pierre, The openDlg method returns an ExtendScript File object, not a string. When you do this:
var fileObj = Open(filename, params, retParm);
filename is a File object instead of a string. You need this instead to get the full path as a string:
var fileObj = Open(filename.fsName, params, retParm);
Or, Russ's method should work as well.
-Rick
-
4. Re: Error while loading an XML document using a structured application
4everJang Apr 4, 2014 4:45 AM (in response to pieratt)Pierre,
Depending on the object "myLastFile", the method openDlg might not even exist (if the myLastFile object is not a File object, for instance). And I do not see any need for the myLastFile anyhow, as you are presenting a dialog to select a file to open. I recommend using the global ChooseFile( ) method instead. This will give you a filename as string in full path notation, or null when no file was selected in the dialog. I am not sure what your ExtendScript documentation states about the return value for ChooseFile, but if that differs from what I am telling you here, the documentation is wrong. So, if you replace the first lines of your code with the following it should work:
function openXMLFile ( ) {
var filename = ChooseFile ( "Choose XML file ...", "", "*.xml", Constants.FV_ChooseSelect );
While writing this, I see that Russ has already given you the same advice. Use the symbolic constant value I indicated to use the ChooseFile dialog to select a single file (it can also be used to select a directory or open a file - but you want to control the opening process yourself). Note that this method allows you to set a start directory for the dialog (second parameter). The ESTK autocompletion also gives you a fifth parameter "helplink" which is undocumented and can safely be ignored.
Good luck
Jang
-
5. Re: Error while loading an XML document using a structured application
pieratt Apr 4, 2014 5:00 AM (in response to frameexpert)Hi Russ, Hi Rick, Hi Jang,
Thanks for taking time on my problem.
You were right : filename was a File object, not a string ... that was the sole problem.
Thanks for your answer, it now works.


