On my form there are command buttons to create a public array from an Excel table and another button to scan that array for any interesting pattern. Scanning that array works fine at the first time. However, when closing the form and start it again to create a fresh array and enter the scan mode the new public array disappeared. This happens alternatingly between success and failure. In the exit button there are only two commands RELEASE Thisform and CLOSE TABLES.
The reason to use a public array is because it takes a few minutes to create it, for the Excel tables I use are quite large.
In the creation button is code like this:
PUBLIC gaAPOBank[1,1]
loExcel = CREATEOBJECT("excel.application")
loBook = loExcel.Workbooks.Open(lcSourceFile)
loExcel.Visible = .T.
lnUsedRows = loBook.ActiveSheet.UsedRange.Rows.Count
lnUsedCol = loBook.ActiveSheet.UsedRange.Columns.Count
DIMENSION gaAPOBank(lnExRow,lnArrayCol)
Then fill the array ..
The code at the end looks now like this:
loBook.Close(.F.)
loExcel.Quit()
thisform.cmdSearch.Enabled = .T. (<<< here sits a breakpoint)
In the Debugger I can see that the array is filled with data each time. In the click method of the cmdSearch button the first command line is:
lnBankRows = ALEN(gaAPOBank,1) (<<< that is the place to check for success or failure)
So that means between my break and the click on the cmdSearch button, the public array got lost. This mysterious problem really annoys me, for I wasted a lot of time to find out what is going on here, without success.
However, in the meantime I developed a workaround wherewith I can live with. Moving the array into a from property, then this array never disappears. Therefore I create a form array and a public array at the same time. After entering the search mode and find that the public array disappears, then it can be created again.
Well, I leave up to the experts on this side to add their comments. May be someone might have a bright idea to uncover this strange behavior?
Regards, Klaus
The reason to use a public array is because it takes a few minutes to create it, for the Excel tables I use are quite large.
In the creation button is code like this:
PUBLIC gaAPOBank[1,1]
loExcel = CREATEOBJECT("excel.application")
loBook = loExcel.Workbooks.Open(lcSourceFile)
loExcel.Visible = .T.
lnUsedRows = loBook.ActiveSheet.UsedRange.Rows.Count
lnUsedCol = loBook.ActiveSheet.UsedRange.Columns.Count
DIMENSION gaAPOBank(lnExRow,lnArrayCol)
Then fill the array ..
The code at the end looks now like this:
loBook.Close(.F.)
loExcel.Quit()
thisform.cmdSearch.Enabled = .T. (<<< here sits a breakpoint)
In the Debugger I can see that the array is filled with data each time. In the click method of the cmdSearch button the first command line is:
lnBankRows = ALEN(gaAPOBank,1) (<<< that is the place to check for success or failure)
So that means between my break and the click on the cmdSearch button, the public array got lost. This mysterious problem really annoys me, for I wasted a lot of time to find out what is going on here, without success.
However, in the meantime I developed a workaround wherewith I can live with. Moving the array into a from property, then this array never disappears. Therefore I create a form array and a public array at the same time. After entering the search mode and find that the public array disappears, then it can be created again.
Well, I leave up to the experts on this side to add their comments. May be someone might have a bright idea to uncover this strange behavior?
Regards, Klaus