primo
20-11-2016, 11:18
i had read somewhere that a linguistics professor was using thinbasic in his linguistic research, since thinbasic contains a big number of string functions in addition to other fancy functions.
suppose i want to post to a forum in which its audience don't know anything more than GWBASIC (if any at all). so posting a GUI windows complex programming is bad, it is ugly , even the word "Control Append Text" is scary, so the best approach is to isolate the What_is_important (the beautiful outside skin) from the under the skin bones, muscles,Gears, and other complex things.
here the Linguistics forum audience needs only to experiment with the first code "Research code" which will call the "UnderTheSkinMachinery.tbasic" to manage button, textBox affairs.
in fact a function like this MsgTXTBOX("to be or not to be") will be suitable more than the MsgBox or console Print, and any new call to MsgTXTBOX will add the text under the old text on the same MsgTXTBOX window.
i think the code will work for any human language installed and added to the English windows.
the purpose is to count words and character in some text:
Research code:
#INCLUDE "UnderTheSkinMachinery.tbasic"
Function what_is_important()
Dim TextMatrix() As String
Dim nLines,total,i As Long
Dim mytext As String
'myText = FILE_Load("someText.txt")
'nLines = Parse(myText, TextMatrix, Any ","+" ")
nLines = Parse("Thinbasic Is A Hot Programming Language", TextMatrix, " ")
Control Set Text hDlg, %lText, "" 'erase the TextBox
For i=1 To UBound(TextMatrix(1))
TextMatrix(i) = Remove$(TextMatrix(i), Any " "+$CRLF)
total + Len(TextMatrix(i))
'Control AppendToTop Text hDlg, %lText, TextMatrix(i) & $CRLF
Control Append Text hDlg, %lText, TextMatrix(i) & " " & Len(TextMatrix(i)) & $CRLF
Next
Control AppendToTop Text hDlg, %lText, "words count = " & Str$(UBound(TextMatrix(1))) & " " & "charecters count = " & Str$(total) & $CRLF
End Function
UnderTheSkinMachinery.tbasic :
Uses "UI" , "FILE"
Begin Const
%bRun
%lText
End Const
Dim hDlg As DWord
Function TBMain()
Dialog New Pixels,0, "counting words and characters", 1, 1, 700, 500, _
%WS_DLGFRAME Or %DS_CENTER Or %WS_CAPTION Or %WS_SYSMENU Or %WS_OVERLAPPEDWINDOW, _
0 To hDlg
Control Add Textbox , hDlg, %lText, "click the run button';", 5, 30, 500, 400, %WS_TABSTOP Or _
%ES_WANTRETURN Or _
%ES_MULTILINE Or _
%ES_AUTOHSCROLL Or _
%ES_AUTOVSCROLL Or _
%WS_VSCROLL Or _
%WS_HSCROLL
Control Add Button , hdlg, %bRun,"Run...",540,60,40,40,%WS_BORDER Or %WS_TABSTOP
Dialog Show Modal hDlg, Call dlgProc
End Function
CallBack Function dlgProc() As Long
Select Case CBMSG
Case %WM_COMMAND
Select Case CBCTL
Case %bRun
what_is_important() ' call the Reasearch actions
End Select
Case %WM_CLOSE
End Select
End Function
suppose i want to post to a forum in which its audience don't know anything more than GWBASIC (if any at all). so posting a GUI windows complex programming is bad, it is ugly , even the word "Control Append Text" is scary, so the best approach is to isolate the What_is_important (the beautiful outside skin) from the under the skin bones, muscles,Gears, and other complex things.
here the Linguistics forum audience needs only to experiment with the first code "Research code" which will call the "UnderTheSkinMachinery.tbasic" to manage button, textBox affairs.
in fact a function like this MsgTXTBOX("to be or not to be") will be suitable more than the MsgBox or console Print, and any new call to MsgTXTBOX will add the text under the old text on the same MsgTXTBOX window.
i think the code will work for any human language installed and added to the English windows.
the purpose is to count words and character in some text:
Research code:
#INCLUDE "UnderTheSkinMachinery.tbasic"
Function what_is_important()
Dim TextMatrix() As String
Dim nLines,total,i As Long
Dim mytext As String
'myText = FILE_Load("someText.txt")
'nLines = Parse(myText, TextMatrix, Any ","+" ")
nLines = Parse("Thinbasic Is A Hot Programming Language", TextMatrix, " ")
Control Set Text hDlg, %lText, "" 'erase the TextBox
For i=1 To UBound(TextMatrix(1))
TextMatrix(i) = Remove$(TextMatrix(i), Any " "+$CRLF)
total + Len(TextMatrix(i))
'Control AppendToTop Text hDlg, %lText, TextMatrix(i) & $CRLF
Control Append Text hDlg, %lText, TextMatrix(i) & " " & Len(TextMatrix(i)) & $CRLF
Next
Control AppendToTop Text hDlg, %lText, "words count = " & Str$(UBound(TextMatrix(1))) & " " & "charecters count = " & Str$(total) & $CRLF
End Function
UnderTheSkinMachinery.tbasic :
Uses "UI" , "FILE"
Begin Const
%bRun
%lText
End Const
Dim hDlg As DWord
Function TBMain()
Dialog New Pixels,0, "counting words and characters", 1, 1, 700, 500, _
%WS_DLGFRAME Or %DS_CENTER Or %WS_CAPTION Or %WS_SYSMENU Or %WS_OVERLAPPEDWINDOW, _
0 To hDlg
Control Add Textbox , hDlg, %lText, "click the run button';", 5, 30, 500, 400, %WS_TABSTOP Or _
%ES_WANTRETURN Or _
%ES_MULTILINE Or _
%ES_AUTOHSCROLL Or _
%ES_AUTOVSCROLL Or _
%WS_VSCROLL Or _
%WS_HSCROLL
Control Add Button , hdlg, %bRun,"Run...",540,60,40,40,%WS_BORDER Or %WS_TABSTOP
Dialog Show Modal hDlg, Call dlgProc
End Function
CallBack Function dlgProc() As Long
Select Case CBMSG
Case %WM_COMMAND
Select Case CBCTL
Case %bRun
what_is_important() ' call the Reasearch actions
End Select
Case %WM_CLOSE
End Select
End Function