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)
KDB
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)
Hello Ricardo!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)
I wish too to have it as PB command set.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
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.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.
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)
PowerBasic 7 dosen't really offer COM, at least not in a usefull way.Amiga5k wrote:Don't feel bad, guys, it took PowerBasic (which is $199 - $99 for each upgrade) 7 versions to get Com support!
I guess you are right, that why i finally decide to make my own way to call COM from PureBasic.Apparently, this is 'hard' to implement in a high level language)