Hi
i have found a dll special for script languages, the author said:
O2H is a Just-In-Time compiler assembler, deployed in a single DLL that takes source code strings and returns executable binary. the author said that he managed it to be a general dll. i am trying to use it in perl, you can download it from here:
http://community.thinbasic.com/index.php?topic=2517.0 just download the file : thinBasic_Oxygen.zip
to give you some idea first:
in perl to sum the numbers from 1 to 100000000 (one hundred million) such as:
my $a; for( $a=1; $a<100000001; $a=$a+1 ) { $t = $t + $a; } print $t;
it takes about 65 seconds to give the result 5.00000005e+015 = 5000000050000000
while in vb6 calling this dll it is less than 2 seconds to give the result 5000000050000000
i have tried it with visual basic 6 as follows:
the full vb6 source with the dll here:
http://sites.google.com/site/zak31415/Home/vb6_oxygen2.rar first: i have declared its functions in a vb6 Module:
Declare Sub o2_asmo Lib "thinbasic_oxygen.dll" (ByVal s As String) Declare Sub o2_basic Lib "thinbasic_oxygen.dll" (ByVal s As String) Declare Function o2_buf Lib "thinbasic_oxygen.dll" (ByVal n As Long) A +s Long Declare Function o2_error Lib "thinbasic_oxygen.dll" () As String Declare Function o2_exec Lib "thinbasic_oxygen.dll" (Optional ByVal p +As Long) As Long Declare Function o2_get Lib "thinbasic_oxygen.dll" Alias "o2_buf" () A +s String Declare Function o2_len Lib "thinbasic_oxygen.dll" () As Long Declare Function o2_prep Lib "thinbasic_oxygen.dll" (ByVal srcBSTR As +String) As String Declare Sub o2_put Lib "thinbasic_oxygen.dll" Alias "o2_buf" (ByVal c +As String) Declare Function o2_view Lib "thinbasic_oxygen.dll" (ByVal srcBSTR As +String) As String
second: i have write in a form the following code:
Private Sub Command1_Click() Dim src As String src = " dim a as quad : dim i as long: for i=1 to 100000000: a=a+i : n +ext i: Print str a: mov eax,a :terminate " o2_basic src o2_exec End Sub
just compile the code first and run the compiled code
now in perl: i have great difficulties with api
#! perl -slw use Win32::API; my $o2basic = new Win32::API( "thinBasic_Oxygen.dll","o2_basic", [P], +P ); my $o2exec = new Win32::API( "thinBasic_Oxygen.dll","o2_exec", [P] ); my $src = " dim a as quad : dim i as long: for i=1 to 100000000: a=a+i + : next i: Print str a: mov eax,a :terminate "; $o2basic->Call( $src ); #gives an error here #what should i do here with o2exec ??: #$o2exec->??;
to execute the function o2basic it gives an error, try it please. ps.. the instruction mov eax,a are not used here but it is to make it possible to pass the result to vb6 variable such as v = o2exec thanks

In reply to new DLL compile code inside script languages by orange

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.