I’m not an experienced JavaScript programmer. This is my first project using JS.
I’m developing on Linux and am at the point for my first release. Running the project on a Windows machine I came across the following …
global.DBSysInfo;
console.log("DBSysInfo =n" + DBSysInfo);
var pnt1 = DBSysInfo.indexOf('DBActive = "yes"');
console.log("pnt1 = " + pnt1);
var pnt2 = DBSysInfo.indexOf(os.EOL + os.EOL, pnt1) + 1;
console.log("pnt1 = " + pnt1 + "; pnt2 = " + pnt2);
console.log("DBSysInfo.substring =n" + DBSysInfo.substring(pnt1, pnt2));
The above code works as expected on Linux:
DBSysInfo =
SysLocation = "C:UsersmlakeMELGenKey"
DBActive = "yes"
DBName = "SOT2-KILLE20240704"
DBUserID = "2.0"
DBStatus = "1"
DBSecurity = "0"
DBLocation = "DBs/SOT2-KILLE20240704"
pnt1 = 42
pnt1 = 42; pnt2 = 176
DBSysInfo.substring =
DBActive = "yes"
DBName = "SOT2-KILLE20240704"
DBUserID = "2.0"
DBStatus = "1"
DBSecurity = "0"
DBLocation = "DBs/SOT2-KILLE20240704"
On Windows, the output is:
DBSysInfo =
SysLocation = "C:UsersmlakeMELGenKey"
DBActive = "yes"
DBName = "SOT2-KILLE20240704"
DBUserID = "2.0"
DBStatus = "1"
DBSecurity = "0"
DBLocation = "DBs/SOT2-KILLE20240704"
pnt1 = 42
pnt1 = 42; pnt2 = 0
DBSysInfo.substring =
SysLocation = "C:UsersmlakeMELGenKey"
I don’t understand why the output would be different on Windows. Why would pnt2 be 0? The only thing I can think is the second “indexOf” statement is treating “DBSysInfo” as an array. If so, why? Is global treated differently on Windows than it is on Linux?
I tried using both Edge and Firefox on Windows with the same results, but the code is in node and I wouldn’t think the browser used would make any difference in this instance.