Results 1 to 10 of 12

Thread: It works for me.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    thinBasic MVPs danbaron's Avatar
    Join Date
    Jan 2010
    Location
    California
    Posts
    1,378
    Rep Power
    152

    It works for me.

    I tried Free Pascal (FPC Version: 2.4.2).

    It is a compiler.

    It can make DLLs.

    I guess that means, theoretically, it could be called by thinBasic.

    -----------------------------------------------------------------------------------------------

    (I didn't see there was a forum for it at thinBasic, until I looked to upload this post.)

    I haven't the vaguest notion about SDKs.

    I definitely need to have a serious run with it and see if I can make a thinBasic SDK for Free Pascal in order to be able to develop thinBasic module under Free Pascal.
    http://www.thinbasic.com/community/showthread.php?8349-Free-Pascal-2.2.0-released

    If it happens, it would be nice.
    I think if I knew how to make a DLL and call it from thinBasic, I would be incentivized.
    For me, I don't want PowerBasic, and, I don't want C.
    I would like Fortran or Free Pascal - if I knew how to make an SDK, and it was easy, I would try to do one or both myself.

    -----------------------------------------------------------------------------------------------

    website:

    http://www.freepascal.org/

    documentation:
    There are 7 documents in PDF files.
    (The Run-Time Library (RTL) units reference manual, is 1739 pages.)

    http://www.freepascal.org/docs.var

    IDE = Lazurus

    http://www.lazarus.freepascal.org/

    Free Pascal + Lazurus --> installer (76.2 MB)

    http://sourceforge.net/projects/lazarus/files/

    Test:
    (compiled to RAM, and run from IDE)

    ' code ----------------------------------------------------------------------------------------------------------------------
    
    program test;
    
    uses sysutils,dateutils;
    
    const
    // n equals one billion
    n=1000000000;
    
    var
    i:longint;
    f:extended;
    t1,t2: tdatetime;
    
    begin
    t1:=now;
    
    // Calculate the square roots.
    for i:=1 to n do
    begin
    f:=sqrt(i);
    end;
    
    // Write the statistics.
    t2:=now;
    f:= millisecondsbetween(t2,t1)/1000;
    writeln('time to calculate the square roots of 1 to ',n,':');
    writeln('elapsed seconds = ',f);
    writeln;
    
    // Write some square root values.
    for i:=1 to 9 do
    begin
    writeln(i,' ',sqrt(i));
    end;
    
    readln;
    end.
    
    ' output --------------------------------------------------------------------------------------------------------------------
    
    time to calculate the square roots of 1 to 1000000000:
    elapsed seconds =  2.1450000000000000E+0001
    
    1  1.0000000000000000E+0000
    2  1.4142135623730950E+0000
    3  1.7320508075688773E+0000
    4  2.0000000000000000E+0000
    5  2.2360679774997897E+0000
    6  2.4494897427831781E+0000
    7  2.6457513110645906E+0000
    8  2.8284271247461901E+0000
    9  3.0000000000000000E+0000
    
    Last edited by danbaron; 20-11-2011 at 10:04.
    "You can't cheat an honest man. Never give a sucker an even break, or smarten up a chump." - W.C.Fields

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    If you want to have an insode about thinBasic modules ...
    in thinBasic Journal issue number 2 at page 32 I started to explain what is a thinBasic module and how it works

    Than go into your thinBasic installation directory and check under directory \thinBasic\SDK\
    You will find SDK.ZIP file where there are examples on how to create a thinBasic module but unfortunately not for Pascal. We had for Delphi in the past.
    If there will be real interest I can have a look and revamp it in some way.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    Dan
    there's an example on how to make a dll in the demo\win32 folder.
    but it won't compile as is, the compiler does not like the string function length by itself so you need to assign it to a variable, writing it out probably would work also, here's the modified testdll.pas
    the change is in the procedure p1
    {
      Copyright (c) 1998 by Pierre Muller
      Win32 DLL usage example. It needs dlltest.pp
    }
    library testdll;
    function GetModuleFileName(hModule:longint;lpszPath:pchar;cchPath:longint):longint;
      stdcall; external 'kernel32' name 'GetModuleFileNameA';
    procedure beep(ID:longint);
      stdcall; external 'user32' name 'MessageBeep';
    var
      teststr : string;
    procedure P1(var s:string);export;
    var
      p:array[0..255] of char;
      l:integer;
    begin
      l:=length(s);
      getmodulefilename(Hinstance,@p,255);
      writeln('DLL: Hello, I''m DLL ',pchar(@p));
    end;
    procedure P2(x:longint);export;
    begin
      writeln('DLL: Argument X=',x);
      writeln('DLL: New teststr="',teststr,'"');
    end;
    procedure P3(var t);export;
    var
      p : pointer;
    begin
      p:=Addr(T);
      p:=p;
    end;
    procedure P4(x1:pointer);export;
    begin
      Inc(x1);
    end;
    procedure NewExit;
    begin
      beep(0);
      writeln('DLL: Exit from testdll');
    end;
    exports
     P1 index 1,
     P2 name 'Proc2',
     P3,
     P4 resident,
     teststr name 'FPC_string';
    begin
      writeln('DLL: HInstance ',Hinstance,'  PrevInst ',Hprevinst,'  DLLReason ',DLLreason,'  DLLParam ',DLLparam);
      teststr:='DLL init done';
      exitproc:=@newExit;
    end.
    
    Last edited by jack; 20-11-2011 at 17:32.

  4. #4
    thinBasic MVPs danbaron's Avatar
    Join Date
    Jan 2010
    Location
    California
    Posts
    1,378
    Rep Power
    152
    Thanks Johan.

    I found it.

    I think I see the change,

    "l:=length(s);".

    ----------------------------------------------

    So far, making a thinBasic module looks complicated to me.

    Under the example for PowerBasic, I see 6 files called, "UserDefinedLib", with different extensions.

    As of now, from my viewpoint, it looks like magic.

    But many modules exist, so, apparently, people do it.

    Dan
    Last edited by danbaron; 20-11-2011 at 21:57.
    "You can't cheat an honest man. Never give a sucker an even break, or smarten up a chump." - W.C.Fields

  5. #5
    Im still not sure what is thinBasic modul...
    Is this some kind of static lib?

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Quote Originally Posted by danbaron View Post
    So far, making a thinBasic module looks complicated to me.
    Under the example for PowerBasic, I see 6 files called, "UserDefinedLib", with different extensions.
    As of now, from my viewpoint, it looks like magic.
    But many modules exist, so, apparently, people do it.
    The only two important files are:
    1. thinCore.inc
      Consider it as a C header file. Is the interface exposed by thinBasic Core engine to all modules. It contains all the functions avaibale in thinCore.dll (thinBasic Core engine) and thanls to those interfaces your module functions will be able to be executed by a running script.
    2. UserDefinedLib.bas
      Is the example module created to show how to create a thinbasic module.
      Just copy it into another one and personalize it

    Quote Originally Posted by Aurel View Post
    Im still not sure what is thinBasic modul...
    Is this some kind of static lib?
    This is one of those case reading something about is important.
    I strongly suggest to read from page 32 of thinBasic Journal issue number 2.

    In any case nothing strange. A thinBasic module is a standard 32bit DLL that implements 2 important functions: LoadLocalSymbols and possibly, but not mandatory, UnLoadLocalSymbols
    The rest is done by the continuous interaction between Core engine (thinCore.dll) and developed module functions during script execution.

    If you are interested, please give me a very easy function (described with its syntax you would like to have in thinbasic) you would like to have in an hypotetical module and I will write it for you explaining all the steps.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  7. #7
    thinBasic MVPs danbaron's Avatar
    Join Date
    Jan 2010
    Location
    California
    Posts
    1,378
    Rep Power
    152
    Very good.

    I was hoping to receive such a reply from you.

    I'm slowly working on things which are compiled.

    This gives me hope that they will be able to be used with thinBasic.

    And therefore, my motivation is increased.

    I will bookmark this thread.

    Thank you.
    Dan.


    "You can't cheat an honest man. Never give a sucker an even break, or smarten up a chump." - W.C.Fields

Similar Threads

  1. ThinBASIC works also under Linux
    By martin in forum General
    Replies: 7
    Last Post: 12-03-2013, 08:26
  2. fantasia: how souls works
    By zak in forum Shout Box Area
    Replies: 1
    Last Post: 11-11-2011, 12:38

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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