strange Windows crash

I’m running Xojo 2016 r4.1 on an iMac. I can run Windows 10 using Parallels.

I have a project which successfully runs on Mac and Linux, with no problems to date. Windows has a peculiar problem. My project uses RBScript, so the user enters his script in a TextArea. With a good script the Windows program works perfectly. With a bad script, such as just “a”, the Windows program puts up a MsgBox saying

Line Number 361: Undefined identifier.

But the Mac and Linux programs for the same bad script put up

Line Number 1: Undefined identifier.

which is what I wanted. Why did Windows put in 361 rather than 1?

In the RBScript error handling here is the code to generate that message:

errorString="Line Number "+Str(line+1-numLinesPrefix)+": "+errorString
MsgBox(errorString)

numLinesPrefix is a global Integer property belonging to main Window1. It is initialized in the Open event of Window1 by:

TextAreaPrefix.text = ReplaceLineEndings(TextAreaPrefix.text, EndOfLine.OSX)
numLinesPrefix = CountFields(TextAreaPrefix.text, EndOfLine.OSX)

I did it that way so if I changed the prefix to the user script, then numLinesPrefix would be adjusted to the proper value.

In order to check things out I inserted a single line into my error reporting code, so it read

errorString="Line Number "+Str(line+1-numLinesPrefix)+": "+errorString
MsgBox "numLinesPrefix = " + Str(numLinesPrefix)
MsgBox(errorString)

When the new built programs were run on Mac and Linux, they reported the error as

numLinesPrefix = 361

and then
Line Number 1: Undefined identifier.

as expected.

But the Windows program crashed on opening with a Runtime error saying

Common\Loaders\LoaderWindows.cpp: 139
Failure Condition: bytesRead == mImportSection.DataLength

I’ve repeated the process of inserting and removing that single line of code
MsgBox "numLinesPrefix = " + Str(numLinesPrefix)
several times and gotten the same results.

Why is Windows giving this problem?

Bob

I should also have said the RBScript is a Window1 control.

Bob

File a bug report please.

I found the problem. When I did

TextAreaPrefix.text = ReplaceLineEndings(TextAreaPrefix.text, EndOfLine.OSX)
numLinesPrefix = CountFields(TextAreaPrefix.text, EndOfLine.OSX)

I changed the LineEndings in TextAreaPrefix.text. Changing this code to

Dim prefixString As String
prefixString = ReplaceLineEndings(TextAreaPrefix.text, EndOfLine.OSX)
numLinesPrefix = CountFields(prefixString, EndOfLine.OSX)

solved the Windows problem - no crash and got the 1 rather than the 361 Line Number.

What I now don’t understand is that without that offending MsgBox line but with the original code changing the LineEndings in TextAreaPrefix.text, the application worked on Windows in doing the job for which it was intended. That is, the prefix script was, and had to be, used correctly in spite of the change in LineEndings.

Bob