Copy link to clipboard
Copied
Dear all,
Again I'm stuck with some silly problem.
When I cancel the ChooseFile dialogue, I want to bail out of the function GetTheFile. However, I have not found the appropriate test for this.
The inputFile is reported to be null in the Cancel case:
var prompt = "Select the formatted Citation file";
GetTheFile ();
function GetTheFile () {
var inputFile = ChooseFile (prompt, GetDocPath (), "*.rtf", Constants.FV_ChooseSelect);
if (inputFile == 0) {
alert ("No input - no processing");
return;
}
alert ("Further processing of the inputfile = " + inputFile);
}
If I cancel, line 10 reports "Further processing of the inputfile = null".
Testing in line 6 for the string "null" does not help either.
The Scripting Guide says for this function:
«The method returns 0 if the user clicked Open, Select, Use, or Save; a nonzero value if the user clicked Cancel or an error occurred»
function GetDocPath () {
// ----------------------------------------------- Get the document/book path
var docFile, scrPath, lastBSlash;
if (app.ActiveBook.ObjectValid()) {
docFile = app.ActiveBook.Name;
} else {
docFile = app.ActiveDoc.Name;
}
lastBSlash = docFile.lastIndexOf("\\"); // \ needs escaping
scrPath = docFile.substring(0, lastBSlash);
return scrPath; // no final \ !
} // --- end GetDocPath
Testing in line 6 for !== 0 catches the valid input-file names (of course). So what is a valid test for the Cancelled function?
Hi Klaus
you have to write the word "null" :
if (inputFile == null)
then it should work
Copy link to clipboard
Copied
Looking into the FDK documentation confuses me even more.
Here a very first parameter *choice (aka selected file) is present
IntT F_ApiChooseFile(StringT *choice, StringT title, ...
and the function result is the error code.
In the JSX the function result is the selected string or nul or ... - but how to distinguish?
Copy link to clipboard
Copied
Hi Klaus
you have to write the word "null" :
if (inputFile == null)
then it should work
Copy link to clipboard
Copied
Super -
What is this null? A constant? The editor knows it as a keyword - but what is the nature of this?
Step by step my project evolves - it seems to be at 2/3 of the coding now.
Again, thank You very much, Klaus
Copy link to clipboard
Copied
"null" is a data type.
more infos you can get here :
English:
German: