Quantcast
Channel: Adobe Community : All Content - FrameMaker Scripting
Viewing all articles
Browse latest Browse all 888

Type mismatch ?

$
0
0

Dear experts,

I have an ini-file and want to read the value of a distinct entry. Within the script the item is found and its value also. Outside the script the value is undefined.

What happens? Any ideas are welcome.

 

var value;
GetIniValue ("FM-biblio.ini", "04_DoingBook", value);
alert ("value read is " + value);

function GetIniValue (sIniFile, sValueName, sValue) {
// ----------------------------------------------- Read an ini item into a variable
// iniFile must end with a line containing some blanks.
// sValueName is that used in the ini-file (with the prepending #_ (e.g. "04_DoingBook")
  var thisLine, match, notFound = true;  var regex = {    section: /^\s*\[\s*([^\]]*)\s*\]\s*$/,    param: /^\s*([\w\.\-\_]+)\s*=\s*(.*?)\s*$/,    comment: /^\s*;.*$/ } ;  settingsFile = new File($.fileName.replace (/[^\\\/]+$/i , sIniFile)); // method Ric Quatro  settingsFile.open("r");  while(true) {    thisLine = settingsFile.readln();                     if (settingsFile.eof) {                       // at end of the file we are done      break;    }    if (thisLine === null || thisLine === "") {   // skip blank lines      continue;    }    if (regex.comment.test(thisLine))  {          // skip comment lines      continue;    }    if (regex.section.test(thisLine))  {          // ignore section lines      continue;    }    match = thisLine.match(regex.param);          // ignore undefined contents    if (match[1] == sValueName) {      sValue = match[2];
alert ("GetIniValue: sValueName  " + sValueName + ", sValue read = " + sValue);      notFound = false;      break;                                      // no need to continue while loop    }  }  if (notFound) {    alert ("GetIniValue program error - sValueName " + sValueName + " not found in sIniFile " + sIniFile);    stop;  }  settingsFile.close();
} // --- end GetIniValue

 

The alert on line 34 reports "GetIniValue: sValueName  04_DoingBook, sValue read = no", but outside the value is undefined.

The ini file contains these lines:

 

...
03_ListItems      = yes
04_DoingBook      = no
05_Template       = FM-biblio-tpl.fm
...

Viewing all articles
Browse latest Browse all 888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>