Ciao xLeaves
first of all thanks a lot for using thninBasic SDK Core engine, great work.
I think you are one of the few I know doing that so, thanks again.
I've seen that SDK for FreeBasic is not much complete as SDK for PowerBasic. My fault.
I will try to implement it in future thinBasic versions in order to have all the thinCore exported functions available also for FreeBasic.
Anyway, I've tested your library and seems ok to me in terms of execution.
Capture.jpg
Regarding strange behaves ... I've only few doubts on how you parse some values using thinCore SDK.
The fact that code exit without executing all the parsing steps seems related to the fact that some of your functions generate a runtime error (GPF) exiting before the end but without crashing thinCore engine.
For example in Rtl_ToUnixTime SDK function "thinBasic_ParseDouble(dTime)" is executed even if ToUnixTime in script is called passing no parameters like "ToUnixTime()" and this can bring to strange behaves:
Function Rtl_ToUnixTime() As UInteger
Dim ParensPresent As Long = thinBasic_CheckOpenParens_Optional
Dim dTime As Double
Dim bMS As Integer
thinBasic_ParseDouble(dTime)
If dTime = 0 Then
dTime = Now()
EndIf
If thinBasic_CheckComma_Optional() = TB_TRUE Then
thinBasic_ParseLong(bMS)
Else
bMS = FALSE
EndIf
If bMS Then
Function = DateDiff("s", 25569.3333333333, dTime, 0, 0) * 1000
Else
Function = DateDiff("s", 25569.3333333333, dTime, 0, 0)
EndIf
If ParensPresent = TB_TRUE Then thinBasic_CheckCloseParens_Mandatory
End Function
I would have written something like the following that is a little more longer but more secure and can prevent some behaves from programming style:
Function Rtl_ToUnixTime() As UInteger
Dim dTime As Double
Dim bMS As Integer
'---Set default values
dTime = Now()
bMS = FALSE
'---Start parsing ...
'---First of all check if there is a (
If thinBasic_CheckOpenParens_Optional <> 0 Then
'---Check if user just called function with () without passing any parameter
If thinBasic_CheckCloseParens_Optional <> 0 Then
'---In this case do nothing! Function called as ToUnixTime()
Else
'---If there is a ( then we check if parameters were passed
'---OK start pasing some parameter
thinBasic_ParseDouble(dTime)
'---If optional , then we have another parameter
If thinBasic_CheckComma_Optional() = TB_TRUE Then
thinBasic_ParseLong(bMS)
End If
'---We anetered here because there was ( so there must e a )
thinBasic_CheckCloseParens_Mandatory
End If
End If
'---End parsing
'---Before executing we need to check if a runtime error occurred during parsing
If thinBasic_GetLastError = 0 Then
If bMS Then
Function = DateDiff("s", 25569.3333333333, dTime, 0, 0) * 1000
Else
Function = DateDiff("s", 25569.3333333333, dTime, 0, 0)
EndIf
End If
End Function
Let me know if it makes any difference.
Ciao
Eros
Bookmarks