COM/ActiveX

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
kdbell61520
New User
New User
Posts: 4
Joined: Wed Jun 04, 2003 8:26 pm
Location: Illinois, USA
Contact:

COM/ActiveX

Post by kdbell61520 »

Thanks Fred for the latest update! It is great! The only thing I would like to see in addition is COM access, so I can load stuff into Excel or do ADO. Since I am a moron, I don't know how hard it is to implement this kind of feature, so don't abuse me too badly if it would take a hundred people six months to implement. I don't need it that badly. It would be neat however to do something like

Code: Select all

def.o  objDic  ; object declare

objDic = objectopen("Scripting.Dictionary")

objDic.Add("Help Me","Spock")

if ( objDic.Exists("Help Me") )

    st.s = objDic.Item("Help Me")

endif

;; st.s now = "Spock"

objectclose(objDic)

Thanks again for a fine product!

KDB
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: COM/ActiveX

Post by ricardo »

Hi,

A few days ago i release a dll that let you do this and more.
You can run vbs/javascript/perl and Activex/COM from PB witheasy
very similar to the example you show

http://www.getafile.com/cgi-bin/merlot/ ... eX2Dll.zip

Its shareware ($15 for PB users)
ARGENTINA WORLD CHAMPION
kdbell61520
New User
New User
Posts: 4
Joined: Wed Jun 04, 2003 8:26 pm
Location: Illinois, USA
Contact:

Re: COM/ActiveX

Post by kdbell61520 »

ricardo wrote:Hi,

A few days ago i release a dll that let you do this and more.
You can run vbs/javascript/perl and Activex/COM from PB witheasy
very similar to the example you show

http://www.getafile.com/cgi-bin/merlot/ ... eX2Dll.zip

Its shareware ($15 for PB users)
Hello Ricardo!

I had a look at your examples and they seem nice. However, I was hoping to call COM from Pure Basic itself. I can shell out to WSH using vbscript, jscript or even pythonscript now. But heck, if I going to do that, I might has well write the whole project in WSH.

Thanks! KDB
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: COM/ActiveX

Post by ricardo »

kdbell61520 wrote:I had a look at your examples and they seem nice. However, I was hoping to call COM from Pure Basic itself.
Thanks! KDB
I wish too to have it as PB command set.
I can shell out to WSH using vbscript, jscript or even pythonscript now. But heck, if I going to do that, I might has well write the whole project in WSH.
But if you do it directly in WSH you don't have the advantage of PB, that why i develope the dll that let you call it FROM pb and INTERACT with the script.

Maybe not the best solution, but not far away.
ARGENTINA WORLD CHAMPION
Amiga5k
Enthusiast
Enthusiast
Posts: 329
Joined: Fri Apr 25, 2003 8:57 pm

Post by Amiga5k »

Don't feel bad, guys, it took PowerBasic (which is $199 - $99 for each upgrade) 7 versions to get Com support! Apparently, this is 'hard' to implement in a high level language :P )

Maybe we shuld rate our requests on a scale from 1 to 5, with 5 being an absolute MUST HAVE. I'd personally place com\activex in the area of 3 or 4. But that's me. :)

Hmm.. maybe a rating such as this could be part of this forum? That is, above this box that I'm typing in, there'd be a drop-down gadget with 1-5 and the author and all replyers would rate how much they 'need' this or that feature\command. That way, Fred could determine more easily which items should be on the front burner and which items can simmer on the back burner for a while.

Any ideas on this?

Russell
*** Diapers and politicians need to be changed...for the same reason! ***
*** Make every vote equal: Abolish the Electoral College ***
*** www.au.org ***
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

Ahem, cough, cough... another method is to trawl back through the forums. Some things have been requested for several years now. :)
Amiga5k
Enthusiast
Enthusiast
Posts: 329
Joined: Fri Apr 25, 2003 8:57 pm

Post by Amiga5k »

True, but requesting something and getting that something are not the same thing ;)

As soon as we get it, we'll stop asking for it :) Maybe :?

Russell
*** Diapers and politicians need to be changed...for the same reason! ***
*** Make every vote equal: Abolish the Electoral College ***
*** www.au.org ***
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

I agree but a recent spat proved how fruitless it is... if the man don't want to implement it... it won't get implemented. Case in point: I never envisaged myself having to code IEEE number schemes but one miserable afternoon a few weeks ago I needed *two* doubles for an opengl call. Could have waited until today but now glad I didn't :lol:

Here's the code, done in such a way that I could check the results. Sad considering the IEEE spec has to be maybe 40 or 50 years old and there exists many free maths libs that could be plugged in to PB with little effort.

Code: Select all

; ====================================================================
;
;The format for single precision numbers uses 32 bits divided in the following way, 
;
;  seeeeeeeefffffffffffffffffffffff
;
;  s = sign bit, 1 bit
;  e = exponent, 8 bits  (E_min=-126, E_max=127, bias=127)
;  f = fraction, 23 bits
;
;The format for double precision numbers uses 64 bits divided in the following way, 
;
;  seeeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffff
;
;  s = sign bit, 1 bit
;  e = exponent, 11 bits  (E_min=-1022, E_max=1023, bias=1023)
;  f = fraction, 52 bits
;

Structure d
  l.l
  h.f
EndStructure


Procedure.s f2bs(f.f, n.l)
  bs_i.s  ; Binary String - Integer Part
  bs_f.s  ; Binary String - Fraction

  bs_s.s  ; Binary String - Sign
  bs_e.s  ; Binary String - Exponent
  bs_m.s  ; Binary String - Mantissa
  
  Select n
    Case 8
      fbce = 3
      fbcm = 4
    Case 32
      fbce = 8
      fbcm = 23
    Case 64
      fbce = 11
      fbcm = 52
    Default
      Debug "Unsupported FP: "+Str(n)
  EndSelect
  bias = Pow(2,fbce-1)-1
    
  ; Sign
  ;
  If f<0
    bs_s = "1"
  Else
    bs_s = "0"
  EndIf
  f2.f = Abs(f)
  
  ; Integral Part
  ;
  ip.l = Int(f2)
  
  ; Fractional Part
  ;
  fp.f = f2-ip
  bs_f = ""
  For n=1 To fbcm+2
    tf.f = fp * 2
    ti = Int(tf)
    fp = tf-ti
    bs_f = bs_f + Str(ti)
  Next
  
  e = 0  
  If ip=0
    If bs_f <> Left("000000000000", fbcm)
      While Left(bs_f,1)="0"
        bs_f = Right(bs_f, Len(bs_f)-1)+"0"
        e-1
      Wend
      bs_f = Right(bs_f, Len(bs_f)-1)+"0"
      e-1
    EndIf      
  Else
    bs_i = Bin(ip)
    bs_f = Right(bs_i, Len(bs_i)-1) + bs_f
    e  = Len(bs_i)-1
  EndIf
  bs_m = Left(bs_f, fbcm)
  If Len(bs_m)<fbcm: bs_m = bs_m + Left("000000000000", fbcm-Len(bs_m)): EndIf
  
  eb = e + bias  ; add bias for 8 bit float
  bs_e = Right(Bin(eb), fbce)
  If Len(bs_e)<fbce: bs_e = Left("000000000000", fbce-Len(bs_e)) + bs_e: EndIf

;  Debug StrF(f) + " = " + bs_s + ":" + bs_e + "." + bs_m; + " eb:" + Str(eb)

  ProcedureReturn bs_s + bs_e + bs_m
EndProcedure


Procedure.s bs2d(bs.s, da.l) ; Length must be 64 bits = 8 bytes = 2 longs
  bn=0

  For bn=7 To 0 Step -1
    n.s = Left(bs,8)
    bs = Right(bs, Len(bs)-8)
    
    t.b = 0
    If Mid(n,1,1)="1": t=t+128: EndIf
    If Mid(n,2,1)="1": t=t+ 64: EndIf
    If Mid(n,3,1)="1": t=t+ 32: EndIf
    If Mid(n,4,1)="1": t=t+ 16: EndIf
    If Mid(n,5,1)="1": t=t+  8: EndIf
    If Mid(n,6,1)="1": t=t+  4: EndIf
    If Mid(n,7,1)="1": t=t+  2: EndIf
    If Mid(n,8,1)="1": t=t+  1: EndIf
;Debug t & $FF
    PokeB(da+bn, t & $FF)
;Debug StrU(PeekB(da+bn),#byte)
  Next
EndProcedure


Procedure f2d(f.f, da.l)
  bs2d(f2bs(f, 64), da)
EndProcedure

;==========================================================================

Procedure.s bs2h(bs.s) ; Length must be multiple of 4
  h.s = ""
  
  While bs<>""
    n.s = Left(bs,4)
    bs = Right(bs, Len(bs)-4)
    
    t = 0
    If Mid(n,1,1)="1": t=t+8: EndIf
    If Mid(n,2,1)="1": t=t+4: EndIf
    If Mid(n,3,1)="1": t=t+2: EndIf
    If Mid(n,4,1)="1": t=t+1: EndIf
    h = h + Hex(t)

  Wend
  
  ProcedureReturn h
EndProcedure

Procedure.s HexBU(ba)
  hb.s = Hex(Val(StrU(PeekB(ba),#byte)))
  If Len(hb)=1: hb="0"+hb: EndIf
  ProcedureReturn hb
EndProcedure

;==========================================================================

;d2f(2.625, 8)
;d2f(-4.75, 8)
;d2f(0.40625, 8)
;d2f(-12, 8)
;d2f(1.7, 8)
;d2f(-113.3125, 32)

;bs1.s = f2bs(  0.25, 64)
;bs2.s = f2bs(256.0,  64)

;Debug bs2h(bs1)
;Debug bs2h(bs2)

;bs2d(bs1, @d.d)

f2d(0.25, @d.d)

Debug HexBU(@d+7)+HexBU(@d+6)+HexBU(@d+5)+HexBU(@d+4)+HexBU(@d+3)+HexBU(@d+2)+HexBU(@d+1)+HexBU(@d)
Amiga5k
Enthusiast
Enthusiast
Posts: 329
Joined: Fri Apr 25, 2003 8:57 pm

Post by Amiga5k »

Thanks for the code. :)

Can you see my point, though? A rating system, similar to the one I mentioned before, along with a feedback-from-Fred biweekly or monthly could go a long way towards reducing repetition and letting us have some sort of feeling as to when or if our request will be granted.

It shouldn't take too long to set up the forum software to do this, right?

Russell
*** Diapers and politicians need to be changed...for the same reason! ***
*** Make every vote equal: Abolish the Electoral College ***
*** www.au.org ***
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

Amiga5k wrote:Don't feel bad, guys, it took PowerBasic (which is $199 - $99 for each upgrade) 7 versions to get Com support!
PowerBasic 7 dosen't really offer COM, at least not in a usefull way.
Apparently, this is 'hard' to implement in a high level language :P )
I guess you are right, that why i finally decide to make my own way to call COM from PureBasic.

Now i develope some application thats uses COM in a 125 k executable with no runtimes needed just my dll bundled (thats why 125 k) !!!

Some of my dreams comes true!
ARGENTINA WORLD CHAMPION
Post Reply