PDA

View Full Version : New ThinBasic SDK (VC2015)



xLeaves
15-07-2019, 21:02
The new SDK no longer needs thinC.dll and supports calling all the thinCore.dll export functions.

It can compile and work normally, but there are still some problems

I translated string to char*, which should be wrong, but thinCore.dll does use the string type instead of asciiz.

I guess this is the reason why the string related function is not available.

I hope everyone can improve it together.

Now it is released on a git service in China.

I don't have a github account, maybe I can create a fork on it.



Git:
https://gitee.com/xywhsoft/ThinBasic_Plugin_VC2015

xLeaves
15-07-2019, 21:05
Maybe ErosOlmi can tell me the memory format of the String data type in PowerBasic, I will try to use VC compatible with these functions without having to make some additional APIs.

ErosOlmi
15-07-2019, 22:08
Ciao

thinBasic dynamic strings bot internally or in scripts are OLE strings sometimes called BSTR
thinBasic uses the single byte string not the unicode version in any case the logic is similar
Allocation/deallocation is demanded to OLE engine sys* functions.

More info:
https://docs.microsoft.com/en-us/previous-versions/windows/desktop/automat/bstr
https://www.johndcook.com/blog/cplusplus_strings/
https://blogs.msdn.microsoft.com/ericlippert/2003/09/12/erics-complete-guide-to-bstr-semantics/
https://www.codeproject.com/Articles/4829/Guide-to-BSTR-and-C-String-Conversions
https://slideplayer.com/slide/17079314/

https://slideplayer.com/slide/17079314/98/images/9/BSTRs.jpg

xLeaves
16-07-2019, 09:38
Thank you, ErosOlmi, I will try to update the string passing, so that VC can write ThinBasic or add classes.;)

xLeaves
16-07-2019, 20:55
Hi ErosOlmi:



The problem with strings is solved, so writing code doesn't require managing and freeing memory:


char* sTemp = "\x04\0\0\0Test\0\0";
thinBasic_LoadSymbol(sTemp + 4, thinBasic_ReturnNumber, &TB_Test, thinBasic_ForceOverWrite);

I have a new problem :

ReDim oObject(1& To 1&) As iMsxml2_ServerXMLHTTP At pObject

What type of data is passed in to pObject, and what is the structure of its representation in memory?

It seems that when I can't implement such a function, even if the constructor has been called, the instance object of the class is still not recognized by ThinBasic.

So when I call the class member function after my new testcalss, I get an error like this:

Class (or class array element) not initialized using NEW keyword

ErosOlmi
16-07-2019, 21:41
Ciao

is this PowerBasic code?


ReDim oObject(1& To 1&) As iMsxml2_ServerXMLHTTP At pObject


I think you are referring to this code, right?
https://github.com/ThinBASIC/thinBasic_MSXML2/blob/master/thinBasic_MSXML2_Msxml2_ServerXMLHTTP.Inc

pObject is a pointer defined by thinBasic Core engine when the script declares a variable like

Dim oHTTP As new ServerXMLHTTPRequest
thinBasic internally creates a PowerBasic class that contain a pointer to iMsxml2_ServerXMLHTTP object.
pObject contains that internal pointer.

Every time in your script you will have something like

oHTTP.Open ...
oHTTP.setRequestHeader ....

thinBasic Core engine will call the Module Class passing that pointer
For example in script like \thinBasic\SampleScripts\MSXML2\HTTPS_Rest_Api.tbasic

xLeaves
18-07-2019, 05:29
Dear ErosOlmi:

Is that a pointer to a 4-byte pointer? The content of the pointer is determined by itself. The function of the redim statement is to write the object defined by itself to this pointer.

So what is the criterion for New success?

I am very eager to develop a more encapsulated extension library for ThinBasic via C/C++ or FreeBasic(Support Class).