Solved: script not found

In calc under this LO Version:
Build ID: 1:6.1.5-3+rpi1+deb10u6+rpt1
CPU threads: 4; OS: Linux 5.10; UI render: default; VCL: x11; 
Locale: en-US (en_US.UTF-8); Calc: group threaded

I split some testing routines into a separate module called 'forTesting' 
under Standard.
Now I'm getting this Error message:
BASIC runtime error.
An exception occurred 
Message: The following Basic script could not be found:
library: 'Standard'
module: 'forTesting'
method: '_setSymbolColor'
location: 'document'

This is the Sub I'm calling that's drawing the error:
Sub setSymbolColor()
'   color stock symbol based on performance
  Dim oRange as object
  oRange = colStocksRange(stockSymbolCol)
  rtn = rangeWalkFn(oRange, "_setSymbolColor")
End Sub

rangeWalkFn() is used several other places with no problems. 
It visits every cell in a range using JohnSUN's [rumMacro()]( to set the 
backcolor based on various values.

setSymbolColor(), _setSymbolColor(), rangeWalkFn() and runMacro() 
are all in Standard/Module1.

Any idea why LO would look in forTesting rather than Module1? 
Or how to tell it not to look out of Module1?


@MikeMcClain46 One gets the impression that the error occurs when a nested macro call is made. At the next transition to “On Local Error GOTO NextIteration”, the macro suddenly jumps up two levels and uses not the actual values of the parameters, but the parameters of the previous level. Very strange error, trying to find the reason. This cycle may need to be changed.

Could you please attach an example with this error?

Take MacroAsParameter.ods|attachment, make sure the two calls to display() work well. Now add a new module and move to it, for example, Function Fn1(). The first call to display() will works well, the second fails because of ::com::sun::star::provider::ScriptFrameworkErrorException (Framework error getting script for URI). Run the macro step by step and observe the state of the call stack in the Calls window - when you try to get the Fn1() script from the utils module, an error occurs, the error handler sends the script to the NextIteration label, and at this moment the stack nesting level decreases

Thank you, this is very interesting!

@MikeMcClain46 As temporary workaround - please, move Function runMacro() to My Macros & Dialogs/Standard. The provider script seems to get confused when it tries to find something in the module that its own call is in.

Yes, it looks like problems with On error when called recursively.
One way to work around the problem:

' Returns script or Nothing if not found.
Function GetScript(oScriptProvider, macroUrl) As Object
   On Local Error GoTo ErrLabel
End Function
' ---
oScript = getScript(oScriptProvider, macroName) 
If Not (oScript Is Nothing) Then
  runMacro = oScript.invoke(inpParams, aOutParamIndex, aOutParam)
  Exit Function
End If  
' ---

@sokol92 Move the error source and its handler into a separate function? Great idea, it really works.

Sorry it took so long to get back to you, life got in the way, taxes, repairing a garden that the freeze destroyed, etc.

JohnSUN, your workaround worked.

sokol92 your solution also worked, had it been entered as a solution, I'd have bumped your karma. As it is and not knowing how to do that all I can say is "Thank You."

Perhaps I should have mentioned this before but I was focused on the failure.
rangeWalkFn() is called around 10 times in my code calling runMacro() for each cell in the range and only fails on this one function which is the last time rangeWalkFn() is called.
In looking at the code again after not having looked at it for several days I see that Function _setSymbolColor() can exit without setting a return value, this may be the difference.

None the less you've solved my problem and I again say "Thank You."

Be well,

Good luck!