View Full Version : thinBasic Beta 1.8.1.x
ErosOlmi
13-06-2010, 21:34
thinBasic Beta 1.8.1.0
Download from: http://www.thinbasic.biz/projects/thinbasic/thinBasic_1.8.1.0.zip
A preliminar beta in order to see if it fixes installation problems reported by tekrat at http://community.thinbasic.com/index.php?topic=3444
thinBasic Setup: now using latest Innosetup available so far 5.3.10
thinAir: improved right click on top file tabs
thinCore: improved REDIM
thinCore: improved PARSE
thinCore: improved interfaces with external functions
UI: improved Canvas control with few new functions working on user input
Oxygen module: updated to the latest available on SVN server (examples included)
TBGL module: updated to the latest available on SVN server
SDK: added "thinBasic_DeclareFunction"
... see thinBasic help for complete and detailed list of changes.
More updates in next few weeks
Regards
Eros
ErosOlmi
13-06-2010, 22:05
For those developing thinBasic modules, few words on new SDK interface function "thinBasic_DeclareFunction".
thinBasic_DeclareFunction is still experimental and can change in final thinBasic release.
It is declared as follows:
'----------------------------------------------------------------------------
'thinBasic_DeclareFunction
'----------------------------------------------------------------------------
' Add a new function using DECLARE statement and function pointer
'----------------------------------------------------------------------------
Declare Function thinBasic_DeclareFunction _
Lib "thinCore.DLL" _
Alias "thinBasic_DeclareFunction" _
( _
ByVal sDeclare As String , _
ByVal pFun As Dword _
) As Long
Its purpose is to pass to thinBasic Core engine a string used to declare your module function plus your module function pointer.
String passed to thinBasic Core follows the same syntax as a standard declare. In this way your module function can receive directly from thinBasic Core engine the necessary parameters without have to parse them in module.
An example. Imagine you want to create your personalized Left$ function called MyLeft. Using thinBasic_DeclareFunction SDK function you can now do like the following.
Create your module function in the classic way:
'----------------------------------------------------------------------------
Function MyInternalLeft(ByVal s As String, ByVal l As Long) As String
'----------------------------------------------------------------------------
Function = Left$(s, l) & "Whatever"
End Function
Inside "LoadLocalSymbols" function (it must always be present in your DLL in order to be a thinBasic module) define your new function in the following way:
thinBasic_DeclareFunction "DECLARE FUNCTION MyLeft(BYVAL s as string, byval l as long) AS string", CodePtr(MyInternalLeft)
thinBasic Core engine will parse your string declare and will automatically connect a new keyword called "MyLeft" with your "MyInternalLeft" registering all needed parameters and their passing methods.
Again, this new SDK is experimental and more limited compared with classic way of creating module functions but can help.
Regards
Eros
Charles Pegge
13-06-2010, 22:36
This feature is going to make module writing much easier Eros. Many thanks!
One question comes to mind: Do you support optional parameters in the declaration string?
Charles
ErosOlmi
13-06-2010, 23:42
I would say yes because it uses the same code used for DECLARE inside script but I've not tested it.
Jordi Vallès
14-06-2010, 13:41
Once more a false virus detection by ESET NOD32. :grrrr:
See image attached.
Jordi
ErosOlmi
14-06-2010, 15:27
Charles, this is for you :unguee:
It seems false positive are related to Oxygen scripts.
Michael Hartlef
14-06-2010, 17:23
I get AVIRA to choke on them too when I do a checkout on Charles SVN stuff.
Charles Pegge
14-06-2010, 17:31
Sorry about that. I think the virus checker dislikes the executables, at least when they are being installed. I can try to ensure that compiled examples are absent from the package.
You can delete the offending EXE and DLL example files. They are generated by some of the sample scripts.
BTW:
I have used the Avast virus checker for many years. It has never given me any problems and updates itself usually daily. I recommend it.
http://en.wikipedia.org/wiki/Avast!
Jordi Vallès
15-06-2010, 12:11
I feel very comfortable with the NOD32 antivirus. This product has solved me several problems and massive atacks and serious problems with the mail. Curiously, the only problems it has caused are related to ThinBasic and its components. Do not know why. :roll:
Jordi
ErosOlmi
15-06-2010, 15:06
I feel very comfortable with the NOD32 antivirus. This product has solved me several problems and massive atacks and serious problems with the mail. Curiously, the only problems it has caused are related to ThinBasic and its components. Do not know why. :roll:
Jordi
Well, it is not the only script engine having problems with AV.
Techniques used to embed script and DLLs into an EXE (like thinBasic does when creating bundled executables) and/or execute DLLs from memory (like some thinBasic modules do) are situations that can bring AV to determine false positive. Similar problems are possible with other scripting engine like AutoIt (used by thousands of users)
Often the false positive occurs just for few days, the time to post a request to AV software (I did it in the past) and they to fix in next update.
It is something we have to live with.
Eros
Charles Pegge
15-06-2010, 16:37
The Oxygen compilation for executable files is still evolving so I think it would be too early to send specimens to Avira and Nod32 at this stage.
I am relieved to hear that my little programs are not the only ones giving false positives!
Charles
ErosOlmi
15-06-2010, 17:05
Just yesterday I downloaded an application developed with Autoit because I was interested in how they did an User Interface and my kaspersky AV blocked it all since the beginning.
Application is neoSearch you can find at http://www.autoitscript.com/forum/index.php?app=downloads&showfile=63
Lionheart008
17-06-2010, 11:38
Its purpose is to pass to thinBasic Core engine a string used to declare your module function plus your module function pointer.
String passed to thinBasic Core follows the same syntax as a standard declare. In this way your module function can receive directly from thinBasic Core engine the necessary parameters without have to parse them in module.
An example. Imagine you want to create your personalized Left$ function called MyLeft. Using thinBasic_DeclareFunction SDK function you can now do like the following.
hi eros, this new declare function, does it work with current thinbasic 1.8.1.0 issue ?
I've tried it but doesn't work with new declare function or I have done something wrong.
I've used the old way with "MyExternalLeft" function and this one works.
thinbasic:
Module "tBDW_2"
dim res as long
Dim a,b As Long
Dim u As Ext
Dim str As String
TBDW_Test(u)
res = MsgBox(0, "U:" & Str$(u))
'a = myLeft(str, 1) '-- doesn't know this command "myLeft"
b = MsgBox 0, myExternalLeft(str,2) '------> ok :)
powerbasic (dll):
#IF 0
=============================================================================
Program NAME: UserDefinedLib.bas
Author : Eros Olmi
Version :
Description : DLL TO test thinBasic loading library
=============================================================================
'COPYRIGHT AND PERMISSION NOTICE
'============================================================================
Copyright (c) 2003 - 2005, Eros Olmi, <eros.olmi@thinbasic.com>
ALL rights reserved.
Permission TO use this software IS granted ONLY FOR the purpose TO develop
thinBasic language modules both FOR commercial OR non commercial purpose.
IN ANY CASE the above copyright notice AND this permission notice must appear
IN ALL copies.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
=============================================================================
#ENDIF
#COMPILE DLL
#REGISTER NONE
#DIM ALL
#RESOURCE "UserDefinedLib.PBR"
#INCLUDE "WIN32API.INC"
'---Every used defined thinBasic module must include this file
#INCLUDE "thinCore.inc"
'thinBasic_DeclareFunction
'----------------------------------------------------------------------------
' Add a new function using DECLARE statement and function pointer
'----------------------------------------------------------------------------
DECLARE FUNCTION thinBasic_DeclareFunction _
LIB "thinCore.DLL" _
ALIAS "thinBasic_DeclareFunction" _
( _
BYVAL sDeclare AS STRING , _
BYVAL pFun AS DWORD _
) AS LONG
'----------------------------------------------------------------------------
FUNCTION MyInternalLeft(BYVAL s AS STRING, BYVAL l AS LONG) AS STRING
'----------------------------------------------------------------------------
FUNCTION = LEFT$(s, l) & "What a beautiful weather here in germany :)"
END FUNCTION
'---------------------------------------------------------------------------
FUNCTION Exec_MyExternalLeft() AS STRING
'----------------------------------------------------------------------------
LOCAL s AS STRING
LOCAL l AS EXT
'---Parse open pares
IF thinBasic_CheckOpenParens() THEN
'---If ok, parse a numeric expression and return it's value.
' Remember to always use EXT numeric type even if you need a different one
thinBasic_ParseString s
IF thinBasic_CheckComma(%TRUE, %TRUE) THEN
thinBasic_ParseNumber l
END IF
'---At the end check if close parens was specified
thinBasic_CheckCloseParens()
FUNCTION = LEFT$(s, l) & "What a beautiful weather we have here in germany :)"
END IF
'End if
END FUNCTION
'----------------------------------------------------------------------------
FUNCTION Exec_HEX() AS STRING
'----------------------------------------------------------------------------
LOCAL lNumber AS EXT
LOCAL lDigits AS EXT
'---Parse open pares
IF thinBasic_CheckOpenParens() THEN
thinBasic_ParseNumber lNumber
IF thinBasic_CheckComma(%TRUE, %TRUE) THEN
thinBasic_ParseNumber lDigits
END IF
IF thinBasic_CheckCloseParens() THEN
IF lDigits > 0 THEN
FUNCTION = HEX$(lNumber, lDigits)
ELSE
FUNCTION = HEX$(lNumber)
END IF
END IF
END IF
END FUNCTION
'----------------------------------------------------------------------------
FUNCTION Exec_Console_FColor() AS EXT
'----------------------------------------------------------------------------
LOCAL R AS EXT, lR AS LONG
LOCAL G AS EXT, lG AS LONG
LOCAL B AS EXT, lB AS LONG
LOCAL Intense AS EXT, lIntense AS LONG
LOCAL ForeColor AS LONG
IF thinBasic_CheckOpenParens() THEN
thinBasic_ParseNumber R
IF thinBasic_CheckComma() THEN
thinBasic_ParseNumber G
IF thinBasic_CheckComma() THEN
thinBasic_ParseNumber B
IF thinBasic_CheckComma() THEN
thinBasic_ParseNumber Intense
IF thinBasic_CheckCloseParens() THEN
lR = R
lG = G
lB = B
lIntense = Intense
IF lR THEN ForeColor = %FOREGROUND_RED
IF lG THEN ForeColor = ForeColor OR %FOREGROUND_GREEN
IF lB THEN ForeColor = ForeColor OR %FOREGROUND_BLUE
IF lIntense THEN ForeColor = ForeColor OR %FOREGROUND_INTENSITY
FUNCTION = ForeColor
END IF
END IF
END IF
END IF
END IF
END FUNCTION
'----------------------------------------------------------------------------
SUB Exec_tBDW_Test
LOCAL VPTR AS LONG
LOCAL VAbsPos AS LONG
LOCAL myValue AS EXT
IF thinBasic_CheckOpenParens( ) THEN
thinBasic_VariableParse(VPtr, VAbsPos)
IF thinBasic_CheckCloseParens( ) THEN
MSGBOX STR$ (VPtr) & "," & STR$ (VAbsPos) & ", [" & "]", , "PowerBASIC"
MyValue = 06172010
thinBasic_ChangeVariableNumberDirect (VPtr, VAbsPos, MyValue)
END IF
END IF
END SUB
'----------------------------------------------------------------------------
FUNCTION LoadLocalSymbols ALIAS "LoadLocalSymbols" (OPTIONAL BYVAL sPath AS STRING) EXPORT AS LONG
thinBasic_LoadSymbol "MyHEX$", %thinBasic_ReturnString, CODEPTR(Exec_HEX), %thinBasic_ForceOverWrite
thinBasic_LoadSymbol "Console_fColor", %thinBasic_ReturnNumber, CODEPTR(Exec_Console_FColor), %thinBasic_ForceOverWrite
thinBasic_LoadSymbol "TBDW_Test", %thinBasic_ReturnNone, CODEPTR(Exec_tBDW_Test ), %thinBasic_ForceOverWrite
thinBasic_LoadSymbol "MyExternalLeft", %thinBasic_ReturnString, CODEPTR(Exec_MyExternalLeft), %thinBasic_ForceOverWrite
'-------- new declare function!
thinBasic_DeclareFunction "DECLARE FUNCTION MyLeft(BYVAL s as string, byval l as long) AS string", CODEPTR(MyInternalLeft)
'-------- new declare function!
thinBasic_AddEquate "%MyNumericEquate", "" , 1
thinBasic_AddEquate "$MyStringEquate", "ABC" , 0
END FUNCTION
'----------------------------------------------------------------------------
FUNCTION UnLoadLocalSymbols ALIAS "UnLoadLocalSymbols" () EXPORT AS LONG
FUNCTION = 0&
END FUNCTION
FUNCTION LIBMAIN ALIAS "LibMain" (BYVAL hInstance AS LONG, _
BYVAL fwdReason AS LONG, _
BYVAL lpvReserved AS LONG) EXPORT AS LONG
SELECT CASE fwdReason
CASE %DLL_PROCESS_ATTACH
FUNCTION = 1
EXIT FUNCTION
CASE %DLL_PROCESS_DETACH
FUNCTION = 1
EXIT FUNCTION
CASE %DLL_THREAD_ATTACH
FUNCTION = 1
EXIT FUNCTION
CASE %DLL_THREAD_DETACH
FUNCTION = 1
EXIT FUNCTION
END SELECT
END FUNCTION
new declare function I did at the beginning of powerbasic code example.
my fully example I add in zip folder (*.bas, *.tbasic, dll)
best regards, frank
ErosOlmi
17-06-2010, 12:33
Did you get new thinCore.inc file?
You can find it into \thinBasic\SDK\SDK.ZIP under PowerBasic directory
Let me know.
Eros
Lionheart008
17-06-2010, 14:17
Did you get new thinCore.inc file?
You can find it into \thinBasic\SDK\SDK.ZIP under PowerBasic directory
new thinbasic 1.8.1.0: my dowloaded version of "thinCore.inc" has 88 kByte size, date: 17. february 2010. I can imagine it's an old one? ;)
servus, frank
Michael Clease
17-06-2010, 14:31
This is from the SDK supplied with the current Beta
PowerBasic
File NAME : thinCore.inc
Author : Eros Olmi
Version : 1.7.10.2
Description : thinBasic external library interface definitions
FreeBasic
File NAME : thinCore.inc
Author : Eros Olmi
Version : 1.8.0.0
Description : thinBasic external library interface definitions
ErosOlmi
17-06-2010, 14:48
Check this example.
You need to put "thinBasic_TestDeclare.dll" into \thinbasic\lib\ directory
Than example in whatever directory
Let me know.
Eros
Petr Schreiber
17-06-2010, 15:40
Hi Eros,
it seems there is older PB SDK version in the beta, but the example you posted works good.
I get the following timing:
1000000 Standard module calls - Time: 0.516 seconds
1000000 New DECLARE module calls - Time: 0.765 seconds
--------------------------------------------------------------
Press a key to continue
Thanks a lot. This will allow creation of modules which will be usable as standard DLLs in other languages as well.
Petr
Michael Hartlef
17-06-2010, 16:03
To bad we don't have a working C SDK, this could help porting a lot of code :unguee:
ErosOlmi
17-06-2010, 17:38
it seems there is older PB SDK version in the beta, but the example you posted works good.
Sorry, I will fix in next beta refresh.
ErosOlmi
17-06-2010, 17:41
To bad we don't have a working C SDK, this could help porting a lot of code :unguee:
I think the same.
C SDK was developed by Roberto, he was the "C" man. Who knows, maybe he will revamp his thinBasic pleasure.
I see him every day, we work together. But it seems more oriented in .Net now.
My C is very very bad. I can read and understand it but my programming experience in C in near to zero.
Lionheart008
17-06-2010, 18:24
now all is ok here, thanks! :)
I've made a new example with factorial function for
" thinBasic_DeclareFunction "DECLARE FUNCTION Factorial(BYVAL InVal AS LONG) AS EXT", CODEPTR(Factorial) "
and this works fine. many thanks for this new feature, eros.
hast la vista, frank