PxPlus User Forum

Main Board => Discussions => Programming => Topic started by: Thomas Bock on March 27, 2019, 04:35:14 AM

Title: strange error 40
Post by: Thomas Bock on March 27, 2019, 04:35:14 AM
During the import of CSV-files to Excel our program does basically something like this:
Code: [Select]
import = sheet'queryTables'add(*connection, *range)
import'adjustColumnWidth = 1
import'textFileCommaDelimiter = 0
import'textFileDecimalSeparator$ = ","
import'textFileThousandsSeparator$ = "."
def object datatypes, %wdx$ + "*VARARRAY"
datatypes'setData(0, 2)
datatypes'setData(1, 2)
datatypes'setData(2, 1)
datatypes'setData(3, 4)
import'textFileColumnDataTypes.put(*datatypes)
This runs fine everywhere, but...
At one site the last statement throws an error 40. If I type "run" the program continues without errors.
Is this an issue of our program or an issue of Excel? Where does this error 40 come from, and why is it gone upon continuation?
Title: Re: strange error 40
Post by: Mike King on March 27, 2019, 04:54:57 PM
On windows we set an EXE exception handler for any math error (divide by zero or exponent overflow) to report a Error 40.

Generally however the PxPlus run-time interpreter checks for a divide by zero and report the error without generating an exception.

This, however, is not the case when you call your object to import the data and it throws an exception.  When this occurs we will report it as an error 40 (Divide by zero or overflow) as opposed to having your process crash due to an un-trapped exception.

Entering RUN to continue will attempt to continue from where it left off in your PxPlus code; not in the import process you called as we have no way to restore its context.