View Full Version : thinBasic as script
Guys, since the goal, from some of the posts I read about thinBasic, is to be a powerful scripting language. That is to augment other programs and not be the one and only be all language to make professional applications. Do you see it as being like python then?
The reason I ask is, maybe you should look at the best third party libraries out there, like you did with Bass for sound and make thinBasic commands to work with these libraries and engines as the scripting language. The thought came to mind tonight as I read on coding monkeys the post by Mike about openAL.
It would be neat if thinBasic tied in seamlessly with the best out there in engines like these: OGRE, physx, openAL etc as TBGL ties into openGL and of course the existing commands for BASS.
OGRE and ODE seem to work together, I have not used either. I don't know what is a good input library or engine. But maybe there could be a thread to take a poll on coding monkeys for such a wish list. I would say there rather than here to get an idea from the wider programming audience and possible ways to bring more users to thinBasic.
What do you guys think? If you like the idea Eros or Roberto should start it as you guys are thinBasic and it would show interest in this direction and maybe get the eyes of other programmers.
Petr Schreiber
04-12-2006, 12:34
Hi kryton9,
interesting ! In my opinion, I think the way to communicate with such a third parties would be better by set of headers ( include files ) rather than making it into the modules.
I like thinBASIC is still in acceptable size for download. thinBASIC is developing very fast, and I want to have every latest version ;D. But idea that I will download 50MB ( including all thirdparties ) package every few weeks is scary for me. So my suggestion is to create some "includes" repository, where everybody could upload his version of headers. Maybe on http://scripts.thinbasic.com/ ?
I think it would be massacre to want Eros and Roberto make all this extra work - they are making excellent job, but I am afraid it already bites out big piece of their personal life.
But I am all for the poll, I could help with headers when needed.
Bye,
Petr
ErosOlmi
04-12-2006, 13:15
Yes, I agree with Petr.
When you think you have an idea to create an interface for external libs, in thinBasic there are 2 ways:
create text .inc file with all the necessary DECLARE and include it in your script
make a thinBasic module compiled using Power Basic or C or possibly Delphi when I will solve string passing
The preferred one is an interface file with all the DECLAREs. Very easy to maintain/share and no need to include in thinBasic all the libraries (sometimes bigger than thinBasic itself).
Why I made some modules instead of file? It depends library from library. For example C++ libraries are not easy to interface because they use objects (pointers to objects). Some other libs are not free so I need to pass a key I cannot share with thinBasic users. And other reasons.
So, Kryton9, if you want to start an interface file for some of the libraries you mentioned, I will try to help. Consider I'm looking at Delphi string problem so, when solved, you will be able to use Delphi to create thinBasic modules.
At the moment we do not have enough time to dedicate to external 3rd party libraries even if we would like and it would be very interesting. We nned to concentrate our time on Core module stability and functionalities because if this will not work fine, all will fail.
Let me know.
Ciao
Eros
Petr and Eros, thanks for clearing up a bit more for me how all of this works. I didn't know it could be done with just headers, although I am not sure how headers work and are made.
That makes perfect sense your explanations about download size and of course keeping up with updates, this way of making headers sounds like the best solution and really the way it should be.
Can one of you guys write a short example of how a header is made. Where would I get the information from the third party library, how would I convert it to a header for thinBasic?
Now about making modules, can you provide an example in C for a dll to be compiled to a DLL, so I can try it out with the various C/C++ languages I have to see if I can get it to work. Would C# work also?
Thanks, I guess understanding all of these will help me better plan my thinBasic work flow.
ErosOlmi
05-12-2006, 01:08
Kryton9,
you can get some include file examples under \thinBasic\Inc directory.
I made include file for ODBC, Petr made include files for GL and GLU. RMChart.inc is another.
How to create an include file? First thing is to know how the function you want to use is declared in your libray documentation. Than write an include file following parameter types. Very important is the passing by mode. By default thinBasic pass all paramaters to external function BYREF unless something different specified. Most of the time external libs (like Windows API) pass parameters BYVAL, so important to specify BYVAL just in front the parameter.
Regarding C/C++ examples, please have a look at \thinBasic\SDK\ directory. There is a .zip file you can expand in order to get relevant interface and few examples.
C#? We didn't produce any interface for .Net languages mainly due to missing time :)
Roberto is a .Net guru so if you are really interested we can spend some time to create a thinBasic/.Net interface.
Anyhow, we are here to help you.
Ciao
Eros
Thanks for all the info, a pleasure to ask a question and get such very nice answers back so quickly. I will look through all the SDK stuff that is included with thinBasic and if I can get one of those working that will be great. If not, will ask about maybe c# version, but not needed at the moment. I just wasn't sure if the c/c++ stuff would work with c#, I didn't think it would, but thought I would ask to make sure.
I was playing with Turbo Delphi and the problem in the example that is causing the problem is the line pchar = 0. I noticed Turbo Delphi says it converts the 0 to NIL. Apparently Delphi 6 allowed this to pass 0 and never converted to NIL. I don't know if that will help troubleshoot the Delphi SDK code. Also I noticed my DLL from Turbo Delphi is twice the size of Petr's DLL made from Delphi 6. That really surprised me. Any of you guys have an idea of why that would be?
ErosOlmi
05-12-2006, 02:13
Regarding Delphi dll size, see if there is an option to leave debug information in there. In this case the size will even double or more.
Onestly I didn't have time to see the problem regarding string parameter passing. I have a document to look at kindly posted by Mike Stefanik in PB (http://www.powerbasic.com/support/forums/Forum8/HTML/003663.html) forum: http://www.codexterity.com/memmgr.htm
I will have a look ASAP.
Ciao
Eros
ErosOlmi
05-12-2006, 02:25
Kryton9,
forgot to say that thinBasic syntax to write external declares files is very, very close to Power Basic syntax and also very close to Free Basic syntax.
So if you are looking for a library ath is also present in Free Basic distribution, you can get Free Basic .inc files (if not copyrighted) and see what happen. You should be able to use them quite stright away.
Eros
Thanks Eros, never used powerbasic or free basic, but glad to know to study I can look at their stuff. Thanks!!
I jump into the water before knowing how to swim, but I seem to learn faster that way. I can't figure out how to compile the dll's so far, other than the one in Delphi. I will keep tracking down the errors to figure out what I am doing wrong. I will give myself till late tonight, which will be late in the morning by the time I get to sleep. If I make no progress I will ask for help with maybe better questions on where I am stuck.
I will get this figured out one or another and I am sure of that with your guys great help!!
Not to change the subject, but it also does tie into the subject. When you read about scripting languages 2 stand out. For games Lua and for games & general purpose Python.
1. What made you guys take on this monumental task to write a scripting language when 2 very good and popular ones exist and seem to do everything? I have not used either because have wanted to settle in on a compiled language, but playing with thinBasic I do see the benfits of having an interpreted language as a tool to work along with a compiled language.
2. With the knowledge obviously Eros and Roberto have, I was wondering what you saw you didn't like in those languages or what you thought could be different in what thinBasic could do or offer?
ErosOlmi
06-12-2006, 03:23
Project started as a way add scripting functionalities to an application. Original name was BINT32 (Basic Interpreter 32) and you can still find sources in thinBasic download area under Power Basic sources. Later the code was so good and fast that I decided to go on and add those functionalities typical of a structured language. Roberto joined the project at a later stage. He is a C/C++/C#/ASM guru but he get some passion for this project and now it is responsible of some aspects of thinBasic. Like many other projects around the world all started with a little problem to solve and evolved.
There are not only 2 very good and popular scripting engine around. There are many. But everyone has its own features and capacity. Many are well supported, many went down, many are still alive but very few supported.
We hope to give our little contribution in IT world. The main original target of thinBasic was to automate some of the many tasks IT people like us had to face every day when managing complex HW and SW structures. We have used thinBasic in some of those activities like moving data from servers, synchronizing data via FTP, sending automatic mails, extracting data from DBMS, converting data from one format to the other, analysing text log files to summarize results, and many other little or much complex tasks.
And just recently with the great help of Petr who developed TBGL module (OpenGL wrapper for thinBasic) we pushed thinBasic in a new dimension: we introduced user interface module and started to create user interaction. Before it was mainly automation task activities. And as you can see possibilities are many and just started.
Now, back to your questions:
none of the mentioned languages are BASIC like. I (we) like Basic syntax. Simplicity doesn’t mean lack of power or functionality. It just means simplicity. Both languages are strong but we have now our way to solve things.
not enough expert on those languages to be realistic and credible in my reply, sorry. I can only talk about thinBasic here.
I do not think we are already in the position to be able to compete with those languages strongly supported and used all around. What I can for sure say is that here we do our best to improve the language, to fix bugs as fast as possible, to improve stability and speed execution, to release new features as soon as they are available with intermediate pre-release, to be open to user suggestions, to support every one asking for help as fast as we can. thinBasic will not be the best solution for whatever problem and will not the best language around. But for sure it has its peculiarities.
If you were searching for secure stones where to place your feet, I'm pretty sure I didn't reply in that sense. I cannot give you strong assurances.
thinBasic is under construction, sometimes it is improving fast, sometimes it is improving slowly but it improving.
Ciao
Eros
RobertoBianchi
06-12-2006, 10:27
Wow, we are already to the history ;D
Roberto
Thanks Eros for the response. It is very interesting to read, thanks for sharing it. Before you started BINT32, did you look at those and didn't like the syntax and said, well I love the BASIC syntax and it would be neat to write our own Basic like scripting language? That is sort of what I thought maybe when reading your history.
Anyways, thinBasic is really great. I am really excited by it and have a feeling some day soon it will be very very popular as python. Like you said it is not even finished and already is is very useful and functional.
I know you guys are a 2 man team, but since it is interpreted maybe the engine core could be compiled to run on different platforms? That would make it like python then and really be a good competitor. The reason I am sort of asking this is it will be neat to use thinBasic on handheld devices, cell phone programming, pda's, hand held game units, my imagination and the though makes me drool in anticipation if it were possible.
Can you imagine being able to run your programs written in thinBasic on these and to work on project while at the park or airport or store on a PDA, wow cool.
I will put the idea in your heads, and hopefully you can make the magic happen sometime in the near future :)
Thanks for the nice history, I can see the story in my mind's eye as I read it. Very nice!!
How can thinBasic be used with other languages as the scripting language? I was trying to figure this out, but am stumped.
Here is the scenarios I imagine and maybe a quick way instead of writing long paragraphs trying to tell the story will use examples:
Compiled Main Program, let's say a game. I will call this 'main' from now on. Then our script in thinbasic I will just call script.
Scenario 1:
Main is running, while it is running it calls thinBasic and passes a parameter the script, thinBasic executes and when finished passes control back to main and shuts itself down.
Scenario 2:
Main uses script throught the life of the main program for tasks that it writes on the fly based on the users use of main, it generates code that needs to be executed without being recompiled, it calls the script and when it needs it, maybe the script could be getting the next level ready or transition ready as the player is near the end of a current level.
Scenario 3: thinBasic is packaged with the game allowing the users at home to write scripts that can create files that game engine of main can use. Main does not use script at all during execution but is a tool to allow users to add levels or do mods that main can later use.
Is this sort of what you meant as a scripting language for other applications? Would love to know how all this could be done and if that was the aim besides being a stand alone language?
ErosOlmi
17-12-2006, 10:51
In short consider the idea of thinBasic as script engine line VBA is for Office applications.
You have your main application that you can automate using scripts.
How to do this? Creating new keywords in thinBasic core on the fly. Every new keyword is linked to your main application internal functions that will do the job to interface with you application execution.
Anyhow, we will give more details in Jan2007
Ciao
Eros
Hmmm, I don't understand how that can be, but Jan 2007 is not far away, I guess will understand then. Sounds fascinating from what you mentioned, incredible in fact. Dynamic keyword creation, WOW!!!
edited: I just read the reply you made in the other script thread about how it will work. I got a better grasp of how this magic will be done, but still it sounds really amazing!!
Michael Hartlef
18-12-2006, 10:30
I am also looking forward to this. I'm working on version 2 of IndeED (http://www.michaelhartlef.de), my own programming editor. I'm in the need of a nice scripting engine, that can easily be interfaced with the host application, means I can call script functions from the host app and host functions form the script. That would be awesome. IndeED itself is developed with Delphi6.
Michael
RobertoBianchi
18-12-2006, 11:08
Hi Michael,
I just download and used your IndeED programming editor version 1.21c, amazing! It looks very good.
Why you don’t add the ThinBASIC file type to the IndeED supported ‘friend’ list for colored syntax and the ability to run TB script?
Please let us know if you need any info.
Thank you very much and best regards,
Roberto
Michael Hartlef
18-12-2006, 12:45
Hi Roberto,
thank you for your kind words. With version 2 of IndeED the user will be able to do it on its own. I try not to add to IndeED1 anymore as I wanna get IndeED2 out of the door. People are waiting for it for so long now, I allways got sidetracked.
But hey, maybe it will be a fast and easy task to do. I need these info..
1) Files types and their extensions
2) How to run a script (parameters)
3) Where can I extract the commands and their parameters from.
Anyway, Thinair looks great too.
Michael
ErosOlmi
18-12-2006, 13:19
Mike,
on keywords list you can use the attached script in order to create an output files with all equates and keywords. You can change it quite easily to follow your needs, other wise let us know the format and we will try to make a specific script.
On file types, main one are just two: .tBasic (for GUI scripts), .tBasicc (for pure console scripts)
On commands parameters, unfortunately we have nothing other than help file. I've thought on how to create them automatically but no way at the moment. I will think at it again.
Ciao and thanks
Eros
ErosOlmi
18-12-2006, 13:38
Forgot to say ...
to shell thinBasic use the following command line:
thinBasic.exe <thinBasic_Script_Name> [optional script command]
Script commands can be retrieved using keywords os_getcommands, os_getcommand(Count), ...
Please see \SampleScripts\OS\OS_SampleCommandLine.tbasic example on how to use command line parameters.
Any question? We are here.
Ciao
Eros
Michael Hartlef
18-12-2006, 14:37
Eros,
thanks. I will look into this. Are these script commands, parameters that a script can read and act to it?
ErosOlmi
18-12-2006, 14:45
Yes they are.
OS_GetCommands (http://www.thinbasic.com/public/products/thinBasic/help/html/os_getcommands.htm) will give you the number of commands specified in command line
OS_GetCommand(index) (http://www.thinbasic.com/public/products/thinBasic/help/html/os_getcommand.htm) will let you retrieve each single command option. Attention: index=0 or index=1 are special. See help.
We use space(s) to separate commands. If you need to use space(s) inside a single command, include it into double quoted string.
Eros
Michael Hartlef
18-12-2006, 14:52
That is great. I really can see the use of thinBasic for IndeED now, as some of the functionality that was hard coded can be done in scripts. These are mainly functions that modify source files.
Thanks again for the info.