PDA

View Full Version : Delphi code examples



ErosOlmi
19-12-2006, 19:17
Do you have some Turbo Delphi code you would like to test as thinBasic module?
Please send me via personal message or post here and I will se if I can use it as testing code.
Just simple or medium examples at first.

Thanks a lot
Eros

kryton9
20-12-2006, 03:30
Eros, I can write something. Do you want the turbo delphi code, or compiled dll? What sort of program would you like?

ErosOlmi
20-12-2006, 09:10
I need simple or complex source code Delphi functions to be developed as thinBasic Module.

So source code functions to be included in the Delphi experiment I'm doing and that I will redistribute as sources example for using Delphi for developing thinBasic modules.

Eros

kryton9
20-12-2006, 10:26
Hmmm, I tried to make a dll that when you called a function it was to launch a form, but it crashed although I got no errors in making the dll in Delphi. It was not anything useful just a test.

But if I understand correctly, you need a dll compiled in turbo delphi that adds some functions in thinBasic, sort of like Petr's examples in the delphi SDK.

I will work on something with a draw so maybe we can draw easier in thinbasic. Not sure how it will go, will try :)

ErosOlmi
20-12-2006, 12:47
No, Kryton9, I do not need anything compiled I just need some source code to test.
You cannot test yourself because I've not yet distributed new thinCore.dll than contains new features needed to interface with dll created using Delphi.

For example imagine you have a piece of sopurce code in Delphi that returns the reverse of a string. Send me and I will try to develop as thinBasic keyword but using Delphi as development environment.

An example I'm testing:

//----------------------------------------------------------------------------
// Returns the reverse of a specified string
// Syntax: s = Reverse(AnyStringExpression)
//----------------------------------------------------------------------------
function Exec_Reverse() : pChar; stdcall;
var MyString: String;

begin
thinBasic_CheckOpenParens;
thinBasic_ParseString_Delphi(MyString);
thinBasic_CheckCloseParens;

MyString := ReverseString(MyString);
Exec_Reverse := pChar(MyString);

end;

You will not be able to compile this code bacause I've not already distributed thinCore.dll with thinBasic_ParseString_Delphi" function interface able to pass dynamic strings from thinBasic to Delphy.

At the moment keywords returning string developed under Delphi are still limited to return a pointer to a NULL terminated buffer but I'm working on that.

Ciao
Eros

kryton9
21-12-2006, 03:22
Ok, wow am very please to get this figured out with the fine help offered here and to give back a neat simple example.
This dll example shows how you can use the Turbo Delphi IDE to design your form and then use it in your thinBasic program.

I will work on a more elaborate form example next, but this is to show how cool all of this is working with Turbo Delphi and ThinBasic.
Thanks for the great start by Petr and then Eros on all of this coding and examples!!

kryton9
21-12-2006, 06:35
Ok this one is neat in that the 3 controls are interconnected. That is change a value in one control and it reflects in the other 2 right away. The 3 controls are a trackbar, editbox and up/down spinner.

My problem and what I need with is figuring out how to get the value from the editbox back to thinbasic? Haven't gotten that far yet.
But am happy that a relatively control setup can be done so easilly in Delphi and used in thinBasic.

edited removed the nonwell working version and placed a better version below, this returns the value back fine to thinBasic.

ErosOlmi
21-12-2006, 08:48
See if this can help.
Functions returning a number should be defined as returning extended data type.

When using forms, they must be shown with .Show method. ShowModal will show the form but will keep the control till the form is closed. So if you want get back some info, you will not be able because controlling process never exit from the form. Using .Show, Delphi shows the form and process control immediately go further. In this way we can make a loop in thinBasic script checking some values or doing some other work like interfacing with TBGL or other stuff.

Of course we need to implement "Form_Control_GetValue" keyword to be more clever. Maybe passing a string indicating what control to return the value.

It is just a possible starting.
Eros

kryton9
21-12-2006, 09:37
Eros I took a nap and solved the problem before coming to check here. I thought you would have been asleep. Anyways I will download and look at your upload.

I figured out how to use a global variable from unit to unit, well actually found a place to read about it online. Anyways, got it working.
Back to sleep now, I will look at yours tomorrow when I am back home.

This is fun!!

I will delete the previous bad one to not waste space on the server here. This is the latest one with the 3 controls working together.

ErosOlmi
21-12-2006, 10:11
Hi kryton9 (somewhere in future I will get you first name :P ),

I checked you example but again the problem is that you are showing the form as modal so no way to interact with it until it get closed.
The trick is to define you form as global variable in Delphi, showing it as modeless. In this way the form is shown and process control pass immediately to the script engine.
At this point make a lopp until ... something so you can interact with your forms using some new keyword you have to develop in your module.

In any case, ther can be many different ways. It all depends by your need. Usually module are something general so best to be general and develop as many keyword functions are needed to interact with the form.

Up to you and have nice ... programming.

Eros

ErosOlmi
21-12-2006, 11:20
Here it is again same project but modified to get back more values.
Again just an example of how things can be done but this is just a possible way among many.
Eros

Petr Schreiber
21-12-2006, 11:47
Hi guys,

I have been out of world of thinBASIC for few days ( like a ten years :) ).
This dark and scary time is off and I am happy to see your Delphi experiments !

After downloading the new core I can confirm it works well even on my system.
I think the new SDK is ok, so no need for the old one to be still available. Can I delete it ?

Bye,
Petr

ErosOlmi
21-12-2006, 11:56
Hey Petr, I started to feel down without your presence around :D

Yes, of course, you can delete it.

Ciao
Eros

kryton9
22-12-2006, 01:19
@Eros. Nice example Eros, can learn a lot from it. THanks.

@Petr, hope your week of busy studies goes by nicely and see you back soon.

I am going to my Sister's for the holiday, will take my notebook and hopefully be on, if not see you guys in a few days.
Just in case I am not able to get on, Merry Christmas!!