View Full Version : Does Multiple USES Cause Problems
peralta_mike
04-05-2011, 01:48
Will repeated USES for the same module cause problems? :confused:
I am using the #include to include file(s) which contains USES for various modules.
If my main script (which has the #include statement) repeats the USES for the same module(s) will this cause me any problems?
Petr Schreiber
04-05-2011, 08:33
Hi,
the behavior of Uses is documented in help file. If you load the same module second time, ThinBASIC knows it and does not reinitialize it, it only gives different return value to programmer to know about "redundant uses".
'
Long firstTime, secondTime
firstTime = Uses "UI"
secondTime= Uses "UI"
MsgBox 0, "FirstTime:"+$TAB(2)+DecodeError_Uses(firstTime) & $CRLF & "SecondTime:"+$TAB+DecodeError_Uses(secondTime)
Function DecodeError_Uses( nErr As Long ) As String
Select Case nErr
Case >= 0
Return "No Error"
Case -1
Return "Library not found"
Case -2
Return "Library is not ThinBASIC module"
Case -3
Return "Library already loaded"
End Select
End Function
Petr
ErosOlmi
04-05-2011, 10:06
Thanks Petr for your support.
Mike, please have look at USES help or check into online help at http://www.thinbasic.com/public/products/thinBasic/help/html/uses.htm
If module is already loaded, script execution will contine and USES will return error code -3. This is more a warning than an error code.
Ciao
Eros
peralta_mike
04-05-2011, 16:46
Thanks Petr and Eros. :rolleyes:
Thanks for the info about it being more of a warning.
I had already looked at the help info.
I just didn't know if calling USES for the same module would harm anything
(other than the return value).