PDA

View Full Version : [Beta] thinBasic Beta 1.9.8.0



ErosOlmi
08-09-2013, 12:22
thinBasic Beta 1.9.8.0

Download from: http://www.thinbasic.biz/projects/thinbasic/thinBasic_1.9.8.0.zip

This is a real Beta in the sense there is a lot of new features all (more or less) to be finished and fully documented.
So, please use this version only for testing and not for real production scripts.

Have a look and please report any impression/problem/likes always remembering it is a beta!!!!!


Fixed some bugs
Added latest TBGL module from Petr Schreiber
...
List of changes can be found in Help file distributed with the product.

In this version I introduced a new way to handle Window Events.
Programmer can Name a Window using new Name "DialogName" option. Window name is used to create specific events callback functions automatically executed by thinBasic UI engine when such an event occurs. Window names is indicated in DIALOG NEW ... statement (see help)

Here an example:

uses "UI"
Uses "console"

Begin ControlID
%IDC_TIMER
%IDC_LABEL
%IDC_Start
%IDC_Stop
End ControlID

%TIMER_DELAY = 10 ' Timer delay (in milliseconds, not very accurate below about 100)

Global TimerValue As Double '---Will be used to calculate timer values

'------------------------------------------------------------------------------
' Main function
'------------------------------------------------------------------------------
FUNCTION TBMain() as long
LOCAL hDlg AS DWORD

Dialog New Name "TimerDialog", 0 , "Timer Example using CallBacks functions", -1, -1, 240, 40, %WS_OVERLAPPEDWINDOW To hDlg

CONTROL ADD BUTTON, hDlg, %IDC_Start, "Start" , 10, 10, 50, 20
CONTROL ADD LABEL , hDlg, %IDC_LABEL, "" , 90, 10, 55, 20, %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR %SS_CENTERIMAGE OR %SS_CENTER
CONTROL ADD BUTTON, hDlg, %IDC_Stop , "Stop" , 180, 10, 50, 20

Dialog Show Modal hDlg 'Call MainDialog_OnCallBack

END FUNCTION


'------------------------------------------------------------------------------
' OnCallBack
'------------------------------------------------------------------------------
CallBack Function TimerDialog_OnCallBack() As Long
PrintL Timer, Function_Name, CBMSG
End Function


'------------------------------------------------------------------------------
' OnCommand
'------------------------------------------------------------------------------
CallBack Function TimerDialog_OnCommand() As Long
Select Case CBCTL

'---Check which control as fired the event
Case %IDC_Start
'---If start, than enable/disable relevant buttons and activate the timer
Control Disable CBHNDL, %IDC_Start
Control Enable CBHNDL, %IDC_Stop

TimerValue = 0 '---Set the time counter to zero
Dialog Set Timer CBHNDL, %IDC_TIMER, %TIMER_DELAY

Case %IDC_Stop
'---If sstop, than enable/disable relevant buttons and destroy the timer
Control Disable CBHNDL, %IDC_Stop
Control Enable CBHNDL, %IDC_Start
Dialog Kill Timer CBHNDL, %IDC_TIMER

End Select
End Function

'------------------------------------------------------------------------------
' OnInit
'------------------------------------------------------------------------------
CallBack Function TimerDialog_OnLoad() As Long
Control Disable CBHNDL, %IDC_Stop
End Function

'------------------------------------------------------------------------------
' OnTimer
'------------------------------------------------------------------------------
CallBack Function TimerDialog_OnTimer() As Long
'---This event is fired by any timer created on the dialog. We have to check which one

'---CBWPARAM contains the ID of the timer that fired %WM_TIMER event
'---More than one timer can be active sumultaneously
Select Case CBWPARAM
Case %IDC_TIMER
'---Increment and set the test value...
TimerValue += 0.01
Control Set Text CBHNDL, %IDC_LABEL, Format$(TimerValue, "#0.00")
End Select
End Function

'------------------------------------------------------------------------------
' OnSize
'------------------------------------------------------------------------------
CallBack Function TimerDialog_OnSize() As Long
PrintL Timer, "Sizing", CBWPARAM, CBLPARAM
End Function

'------------------------------------------------------------------------------
' OnMove
'------------------------------------------------------------------------------
CallBack Function TimerDialog_OnMove() As Long
PrintL Timer, "Moving", CBWPARAM, CBLPARAM
End Function


Looking at the above example ....

Dialog New Name "TimerDialog", 0 , "Timer Example using CallBacks functions", -1, -1, 240, 40, %WS_OVERLAPPEDWINDOW To hDlg
Indicates that the dialog is names "TimerDialog", so automatic events callbacks are named TimerDialog followed by the handled event: TimerDialog_OnLoad(), TimerDialog_OnLoad(), ...
All callbacks, like all Window callbacks, will automatically receive the standard automatic pseudo variables like: CBHNDL, CBMSG, CBWPARAM, CBLPARAM, ...

So far I've developed the following automatic event functions:

Dialog Automatic Event Callback Function added: <DialogName>
Dialog Automatic Event Callback Function added: <DialogName>_OnCallBack
The above two functions are the standard callback function for the window and (if one is present) they are used to substitute the callback functions indicated in DIALOG SHOW ...
Dialog Automatic Event Callback Function added: <DialogName>_OnNotify
Dialog Automatic Event Callback Function added: <DialogName>_OnShow
Dialog Automatic Event Callback Function added: <DialogName>_OnSizing
Dialog Automatic Event Callback Function added: <DialogName>_OnMoving
Dialog Automatic Event Callback Function added: <DialogName>_OnActivate
Dialog Automatic Event Callback Function added: <DialogName>_OnDestroy
Dialog Automatic Event Callback Function added: <DialogName>_OnSysCommand
Dialog Automatic Event Callback Function added: <DialogName>_OnCallBack
Dialog Automatic Event Callback Function added: <DialogName>_OnClose
Dialog Automatic Event Callback Function added: <DialogName>_OnCommand
Dialog Automatic Event Callback Function added: <DialogName>_OnTimer
Dialog Automatic Event Callback Function added: <DialogName>_OnLoad
Dialog Automatic Event Callback Function added: <DialogName>_OnInit
Dialog Automatic Event Callback Function added: <DialogName>_OnMove
Dialog Automatic Event Callback Function added: <DialogName>_OnSize


The above methods can live face to face with the current one so programmer is free to choose if to create a big callback function full of SELECT CASE ... END SELECT messages or add a name to the dialolog and use automatic events handling.
If this new way will function as expected I will add more Windows events and start to add this new technique to controls too.

I've also started to change thinBasic tutorial example ( \thinBasic\Tutorial\ ) to adhere to the new way of events handling. So have a look at it too.


Known bugs:
among others (I hope not so many) I know there is a bug in this version when creating bundled exe. Some process can sometimes fail due to incorrect TOC inside Exe. I'm working on solving this problem asap.


Ciao.
Eros

Michael Hartlef
08-09-2013, 12:58
Thanks Eros for the update.

Could you please answer to my personal message I sent to you.

Take care
Michael

ReneMiner
08-09-2013, 13:08
Great. Thanks from here too.

I like the ability to get fast to a certain elements event/cb-function in codebrowser so this already improves speed a lot when typing - because one does not need additional bookmarks nor notes nor to browse long functions for the right position. This is a cool side-effect and makes using thinAir more fun than it already was.
You saved all users already countless hours - which they usually would need to find a certain place within a callback - because they're all too lazy to type additional bookmarks...
I love it to have some built-in overview :)

ErosOlmi
08-09-2013, 13:13
I'm happy about that. I too noticed about how this method could benefit in source reading if dialog names are well chosen.

I just added few of the main events a window can receive, so feel free to ask for more and I will add.

Ciao
Eros

ReneMiner
08-09-2013, 13:47
Some idea what to improve would be about this:



CallBack Function WinMain_OnSysCommand() As Long

If (CBWPARAM And &HFFF0) = %SC_CLOSE Then
'...

Those comparisons and bin-ops to read out what happened are things that "have no real name" so one does not find it and who does not know this "special treatement" would never come to the idea it has to be done this way...somehow I imagine easier alike:



CallBack Function WinMain_OnSysCommand() As Long

Select Case SysCommand
Case "CLOSE"
Case "MINIMIZE"

'...etc

which could eventually end up in:


CallBack Function WinMain_OnSysCommand_CLOSE() As Long

- anyway - more "important" would be the developement of control-names to me so a functions name can contain the control...

Petr Schreiber
09-09-2013, 07:59
First good news this week, great! I like this kind of surprises!


Petr

EDIT: The GUI tutorials have still displayed Date Modified: 2009.04.10 - could it be that new tutorial is not yet present? The version I have on my PC does not cover the new way of handling events, is that correct?

ErosOlmi
09-09-2013, 09:04
Oops sorry, yes it can be: I've a problem in my setup script. I'm getting tutorial from the wrong directory.

I will make a new update by this week.

thanks

Michael Hartlef
10-09-2013, 11:40
Hi Eros,

I tried to run TB 1.9.8.0 from a memory stick at my job and there the Symantec Ednpoint Protection classified thinbasic.exe as a threat and put it under carantine.
I can't post a more detailed message as I don't wanna take a chance that our IT department investigates on this.

Anything you could do around that?

Cheers
Michael

Petr Schreiber
10-09-2013, 12:10
Hi Michael,

the best is to write directly to Symantec - I did the same for ESET, AVG and Avast, and no issues since then.
In my experience, the report has higher priority if you are their user.


Petr

Michael Hartlef
10-09-2013, 16:58
My company uses it, not me. I was hoping that I could use TB from a memory stick, but it seems not be possible here at this setup :-/

I remember having having virus checkers acting up with TB back in the days :-) I think it was when you install it on a module or so.

ErosOlmi
10-09-2013, 19:21
Michael,

can you please send me some tech details from your AV software?

I will contact producer in order to explain what is thinBasic.
As Petr said, we did it in the past and for some AV producer it was just a matter of few days to release a new virus signature or anyway an update to free thinBasic from being intercepted as false positive.
Some AV software intercept UPX presence as false positive.

Ciao
Eros

Michael Hartlef
11-09-2013, 10:54
Hi Eros,

The product is Symantec Enduser Protection. And it classified thinbasic.exe like this:

http://securityresponse.symantec.com/security_response/writeup.jsp?docid=2010-090200-2232-99&vid=42293

ErosOlmi
12-09-2013, 08:15
Thanks Michael,

has I suspected AV software is not detecting a real virus but it uses the so called "euristic" method or like they call it "cloud.5"

I will apply to Symantec false positive program.

ciao
eros


Sent from my iPhone using Tapatalk

ReneMiner
30-09-2013, 11:36
This is about the named dialogs- somehow I have problem - the automatic call seems not to work - I don't know why... excuse if this already uses 1.9.9. as Minversion but I think it's more about a 1.9.8.-thing.

' in real I have this in 2 seperate code units - second unit just consists of TBMain-Function



#MINVERSION 1.9.9.0.

Uses "UI"

Begin ControlID
%dlg1_btn_Click

End ControlID

Type t_Dialog1
hWnd As DWord
' sName As String
X As Long
Y As Long
Width As Long
Height As Long

Init As Function

End Type


Function t_Dialog1.Init(Optional hParent As DWord) As DWord

Me.X = -1
Me.Y = -1

Me.Width = 320
Me.Height = 240


Dialog New Name "Dialog1", hParent, "Dialog-test", _
Me.X, Me.Y, _
Me.Width, Me.Height, _
%WS_DLGFRAME | _
%WS_CAPTION | _
%WS_SYSMENU | _
%WS_OVERLAPPEDWINDOW | _
%WS_CLIPCHILDREN | _
%WS_CLIPSIBLINGS | _
%DS_CENTER, 0 To Me.hWnd

Control Add Button Me.hWnd, %dlg1_btn_Click, "Click", 20, 20, 280, 200

Function = Me.hWnd


End Function

CallBack Function t_Dialog1_Callback() As Long

If CBMSG = %WM_COMMAND Then
If CBCTL = %dlg1_btn_Click Then
If CBCTLMSG = %BN_CLICKED Then
Control Set Text CBHNDL, CBCTL, "Yes"
Control Redraw CBHNDL, CBCTL
EndIf
EndIf
EndIf

End Function

' the automatic function - seems can not be found ???

CallBack Function Dialog1_OnCommand() As Long

If CBCTL = %dlg1_btn_Click Then
If CBCTLMSG = %BN_CLICKED Then
Control Set Text CBHNDL, CBCTL, "Yes"
Control Redraw CBHNDL, CBCTL
EndIf
EndIf

End Function

' ---- this is seperate code unit ----


Function TBMain()

Dim Dialog1 As t_Dialog1
' not working if commenting starting at "Call" below
Dialog Show Modal Dialog1.Init() Call t_Dialog1_Callback

End Function

other problem I see is the enumeration of ControlIDs - they should work using same window more than once - but if they are global const...

ReneMiner
04-10-2013, 20:48
@Eros, I just push this up because you might oversee a bug I've found before releasing 1.9.9.0 Beta - even if it means to wait another week ;) - chances are higher if I try to get attention here too. Check support (http://www.thinbasic.com/community/project.php?issueid=440#note2657).

ErosOlmi
04-10-2013, 21:39
Hi Rene,

it is ..._OnCallBack() and and not ..._CallBack() in order to be executed automagically.
Otherwise you have to indicate Callback function name at DIALOG SHOW ...


I know, I have to start to write documentation :oops:

Here example:

#MINVERSION 1.9.9.0.
Uses "UI"
Uses "Console"



Begin ControlID
%dlg1_btn_Click

End ControlID

Type t_Dialog1
hWnd As DWord
' sName As String
X As Long
Y As Long
Width As Long
Height As Long

Init As Function

End Type


Function t_Dialog1.Init(Optional hParent As DWord) As DWord

Me.X = -1
Me.Y = -1

Me.Width = 320
Me.Height = 240


Dialog New Name "Dialog1", hParent, "Dialog-test", _
Me.X, Me.Y, _
Me.Width, Me.Height, _
%WS_DLGFRAME | _
%WS_CAPTION | _
%WS_SYSMENU | _
%WS_OVERLAPPEDWINDOW | _
%WS_CLIPCHILDREN | _
%WS_CLIPSIBLINGS | _
%DS_CENTER, 0 To Me.hWnd

Control Add Button Me.hWnd, %dlg1_btn_Click, "Click", 20, 20, 280, 200

Function = Me.hWnd


End Function

CallBack Function Dialog1_OnCallback() As Long

PrintL CBMSG, CBCTL, %WM_COMMAND

Select Case CBMSG
Case %WM_COMMAND


Select Case CBCTL
Case %dlg1_btn_Click
Control Set Text CBHNDL, CBCTL, "Yes"
Control Redraw CBHNDL, CBCTL
End Select
End Select

End Function

' ---- this is seperate code unit ----


Function TBMain()

Dim Dialog1 As t_Dialog1
Dialog Show Modal Dialog1.Init()

End Function

ReneMiner
04-10-2013, 22:22
I used the t_Dialog1_Callback just as substitute for the not working Dialog1_OnCommand


Dialog Automatic Event Callback Function added: <DialogName>_OnCommand described in your post at previous page. So I thought ..._OnCommand would work like in example above -

and hope you have not overseen the post inbetween (check support (http://www.thinbasic.com/community/project.php?issueid=440#note2657)) :)