I've built a QuoteServer.XLAM which includes numerous functions to fetch stock market data. I incorporate this in other projects which require stock market data. I am having a problem with the scope of an array declared in the QuoteServer.
One module of the QuoteServer includes global variables and utilities including a declaration for Public array varrTickerQuotes.
Another module of the QuoteServer includes a Public Sub which loads the array upon request. This works perfectly in module test mode and when called from another project:
Another module of the QuoteServer includes a Public Function which extracts data from the array and returns it. This works perfectly in module test mode but does not work when called from another project:
I am working on a project in a separate XLSM which includes QuoteServer.XLAM. I am referencing both routines in the QuoteServer:
1) From project: I call QS_BuildTickerArray with a symbol list for which to collect data and fill the array. The array is properly filled as shown by debug.print statements.
2) From project: later, I ask Function QS_GetTickerQuote to return selected data from the array. This throws an error.
The debugger shows that the error is thrown because the subscript is out of range when attempting to reference varrTickerQuotes in Function QS_GetTickerQuote. This suggests to me that array varrTickerQuotes is somehow out of scope or its contents are being lost upon return to the caller following the first call to build the array.
Is there a way to preserve the contents of the loaded array when control returns to the caller? Or must I return the array to the caller and then pass it back to QuoteServer in the request to extract data?
Thank you.
Earl
Bookmarks