Donate Now Goal amount for this month: 100 USD, Received: 0 USD (0%)
Donate to support this site and ThinBASIC project development

Results 1 to 9 of 9

Thread: thinBasic interface under Microsoft Visual C++ .NET compiler

  1. #1

    thinBasic interface under Microsoft Visual C++ .NET compiler

    thinBasic allows C/C++ programmers to develop their own thinBasic modules. Modules are special dll that are loaded dynamically by thinBasic engine during scripts execution. Modules can be used to implement new thinBasic functionalities adding new keywords to the language or interfacing external programs.
    We provide static thinC.lib so MS Visual C/C++ programmers could choose to use external interface .DLL or embed it into their own thinBasic Modules.

    Plase find here attached interface file with a simple module example, for Microsoft C++ .NET compiler.
    Project files are for .NET 2002 and .NET 2005 Express.

    Feel free to ask here in case of any question on module development.

    Regards
    Roberto
    Attached Files Attached Files
    http://www.thinbasic.com

  2. #2
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Clearwater, Florida, USA
    Posts
    3,802
    Rep Power
    388

    Re: thinBasic interface under Microsoft Visual C++ .NET compiler

    Thanks Roberto, this one works great. I also downloaded from the older post the other download and it worked too, but it needed the thinC.dll. This one doesn't.

    Thanks for such a quick response and working example!!

  3. #3

    Re: thinBasic interface under Microsoft Visual C++ .NET compiler

    I notice that there's a lot more functions defined for PowerBasic than in the C/C++ headers. Any plans to bring the C++ SDK current with the PowerBasic version? I gather that thinC.lib is a shim that's being used because your core API was written in PowerBasic, and so it passes around PB strings (rather than C's null terminated strings)?

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    47
    Posts
    7,618
    Blog Entries
    2
    Rep Power
    10

    Re: thinBasic interface under Microsoft Visual C++ .NET compiler

    Hi Mike,

    yes, thinBasic SDK for C interface is a little subset of the many interfaces we have developed for PowerBasic.
    The reason is just related to the fact that our time is limited and we canno do all in one go. We usually propose some technologies, see user reaction or interest and based on that we go on development or not.

    If there will be interest we will be very happy to expand C SDK.

    Regarding passing in/out strings between main thinBasic Core (developed in PowerBasic) and modules developed in C we have defined our way of passing them in order to bypass the concept on null termination. Maybe we can go in details if there will be interest.

    Ciao
    Eros

    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  5. #5

    Re: thinBasic interface under Microsoft Visual C++ .NET compiler

    I'm primarily a C++/C# developer, and have been thinking about developing a module that encapsulates the functionality in our SocketTools API. It'd just be a personal side-project of mine, but I thought it would be fun to do.

    By the way, I'm using thinBasic as a test harness for our API, and it works really well. The fact that it has similar function declarations to PowerBasic makes it easy to build and test with. So along with the previous questions, I'd like to say thanks, and well done.

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    47
    Posts
    7,618
    Blog Entries
    2
    Rep Power
    10

    Re: thinBasic interface under Microsoft Visual C++ .NET compiler

    Well,

    thanks a lot Mike.
    Knowing your high level of expertise your compliments are for us a big adrenaline infusion for going on with thinBasic project.

    There will be some improvements in next thinBasic version (out in few weeks) on external function calling and declarations.
    Pointers to structures will be handled directly without the need to have a BYVAL ... AS DWORD and pass a VARPTR of the structure.
    ASCIIZ strings pointers will also be handled directly again without the need to pass its pointer. Just pass the string (whatever) or the string expression.
    I'm also working on ... AS ANY parameters.

    Regarding C interface I will talk with Roberto, in charge of SDK for C/C++
    Maybe starting from September/October we can schedule some works on this area.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  7. #7

    Re: thinBasic interface under Microsoft Visual C++ .NET compiler

    I'm using the curent version and haven't run into any problems with ASCIIZ strings or structures. Here's an example of a simple test program I put together which connects to an SSH server using our SocketTools FTP API and lists the files in the user's home directory. I'm using strings, and FTPFILESTATUS is a structure; it works just fine.

    [code=thinbasic]
    Uses "Console"
    #Include "CSTOOLS6.INC"

    ' Display an error message that includes the error code and a
    ' description of the error
    Function ShowError()
    Dim dwError As DWORD
    Dim szError As ASCIIZ * 128

    dwError = FtpGetLastError()

    If dwError > 0 Then
    FtpGetErrorString(dwError, szError, 12
    Console_WriteLine("Error " + Hex$(dwError) + ": " + szError)
    Console_Write("Press any key to continue...")
    Console_WaitKey()
    End If
    End Function

    ' Main
    Dim hClient As LONG
    Dim szPathName As ASCIIZ * %FTP_MAXFILENAMELEN
    Dim fileInfo As FTPFILESTATUS
    Dim bResult As LONG

    Console_ShowWindow(%Console_SW_SHOWNORMAL)

    ' Initialize the SocketTools FTP API
    If FtpInitialize($CSTOOLS6_LICENSE_KEY, %NULL) = 0 Then
    Console_WriteLine("Unable to initialize SocketTools library")
    End
    End If

    ' Establish a secure connection to the server using SSH
    hClient = FtpConnect("test.server.com", _
    %FTP_PORT_SSH, _
    "username", _
    "secret", _
    %FTP_TIMEOUT, _
    %FTP_OPTION_DEFAULT, _
    %NULL)

    If hClient = %INVALID_CLIENT Then
    ShowError()
    Stop
    End If

    ' Get the current working directory for the user
    If FtpGetDirectory(hClient, szPathName, %FTP_MAXFILENAMELEN) = %FTP_ERROR Then
    ShowError()
    Stop
    End If

    Console_WriteLine("The current directory is " + szPathName)

    ' Open the current working directory
    If FtpOpenDirectory(hClient, szPathName) = %FTP_ERROR Then
    ShowError()
    Stop
    End If

    ' Return information about the first file in the directory
    bResult = FtpGetFirstFile(hClient, fileInfo)

    While IsTrue(bResult)
    If Not IsTrue(fileInfo.bIsDirectory) Then
    ' If the file is not a directory, then display its name and size
    Console_WriteLine(fileInfo.szFileName + "," + Str$(fileInfo.dwFileSize) + " bytes")
    End If

    ' Return information about the next file in the directory
    bResult = FtpGetNextFile(hClient, fileInfo)
    Wend

    ' Close the directory listing
    FtpCloseDirectory(hClient)

    ' Disconnect from the server
    FtpDisconnect(hClient)

    Console_Write("Press any key...")
    Console_WaitKey()
    [/code]

  8. #8
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    47
    Posts
    7,618
    Blog Entries
    2
    Rep Power
    10

    Re: thinBasic interface under Microsoft Visual C++ .NET compiler

    Well,

    I should have a look inside "CSTOOLS6.INC" to check how you defined FtpGetFirstFile function.

    In any case I was referring to this problem posted some time ago by Michael: http://community.thinbasic.com/index.php?topic=1867.0
    plus: some cases whet a parameter is defined as: BYVAL xxx AS ASCIIZ PTR
    plus: BYVAL xxx AS ANY

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  9. #9

    Re: thinBasic interface under Microsoft Visual C++ .NET compiler

    The structure is declared as:

    [code=thinbasic]
    %FTP_MAXFILENAMELEN = 512
    %FTP_MAXOWNERNAMELEN = 64
    %FTP_MAXGROUPNAMELEN = 64

    TYPE FTPFILESTATUS
    szFileName AS ASCIIZ * %FTP_MAXFILENAMELEN
    szFileOwner AS ASCIIZ * %FTP_MAXOWNERNAMELEN
    szFileGroup AS ASCIIZ * %FTP_MAXGROUPNAMELEN
    bIsDirectory AS LONG
    dwFileSize AS DWORD
    dwFileLinks AS DWORD
    dwFileVersion AS DWORD
    dwFilePerms AS DWORD
    stFileDate AS SYSTEMTIME
    END TYPE
    [/code]

    And the function is declared as:

    [code=thinbasic]
    DECLARE FUNCTION FtpGetFirstFile LIB "csftpav6.dll" ALIAS "FtpGetFirstFileA" ( _
    BYVAL hClient AS LONG, _
    BYREF lpFileStatus AS FTPFILESTATUS _
    ) AS LONG
    [/code]

    This is basically the same as how it's declared for PowerBASIC.

    Edit: Ah, I see what he's talking about. He's declaring it as BYVAL ... AS STRUCTNAME PTR rather than as BYREF ... STRUCTNAME. I suppose for completeness supporting the PTR syntax would be useful, but I do think it's counter-intuitive for a BASIC language implementation. Using BYREF just makes more sense to me.

Similar Threads

  1. thinBasic interface under Microsoft visual C/C++ language
    By RobertoBianchi in forum MSVC++ 6.0
    Replies: 26
    Last Post: 05-03-2010, 17:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •