Posted: Tue Jan 13, 2009 8:18 pm
Event sinks have been a part of COMate for a long time now.
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
Dim fso As Object
Dim fld As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set fld = fso.getfolder("d:\test\")
MsgBox fld.Size
nicolaus wrote:How i can make the follow code working with COMate?
Code: Select all
Define fso.COMateObject
Define fld.COMateObject
fso = COMate_CreateObject("Scripting.FileSystemObject")
fld = fso\getobjectproperty("getfolder('d:\test\')")
MessageRequester("", Str(fld\getintegerproperty("Size")))
fld\Release()
fso\Release()
Code: Select all
IncludePath "..\"
XIncludeFile "COMate.pbi"
Define.COMateObject Functions, LogonControl, R3Connection, func, iTABLE_NAME, eNUMBER_OF_ENTRIES, tENTRIES
LogonControl = COMate_CreateObject("SAP.LogonControl.1")
If LogonControl
Functions = COMate_CreateObject("SAP.Functions")
If Functions
R3Connection = Functions\GetObjectProperty("Connection")
If R3Connection
R3Connection\SetProperty("User = 'XXXXX'")
R3Connection\SetProperty("Client = '011'")
R3Connection\SetProperty("Password = 'XXXXX'")
R3Connection\SetProperty("System = 'LP1'")
R3Connection\SetProperty("ApplicationServer = 'SAPLP1'")
R3Connection\SetProperty("SystemNumber = '20'")
R3Connection\SetProperty("TraceLevel = '0'")
R3Connection\SetProperty("Language = 'DE'")
retcd = R3Connection\GetIntegerProperty("Logon(0, #True)")
func = Functions\GetObjectProperty("Add('RFC_GET_TABLE_ENTRIES')")
If func
eNUMBER_OF_ENTRIES = func\GetObjectProperty("Imports('NUMBER_OF_ENTRIES')")
iTABLE_NAME = func\GetObjectProperty("Exports('TABLE_NAME')")
tENTRIES = func\GetObjectProperty("Tables('ENTRIES')")
If iTABLE_NAME
iTABLE_NAME\SetProperty("Value = 'TCURR'")
func\Invoke("Call")
result=eNUMBER_OF_ENTRIES\GetIntegerProperty("Value")
For x=1 To result
Debug tENTRIES\GetStringProperty("Value("+Str(x)+",1)")
Next
iTABLE_NAME\Release()
EndIf
tENTRIES\Release()
iTABLE_NAME\Release()
eNUMBER_OF_ENTRIES\Release()
func\Release()
EndIf
R3Connection\Release()
EndIf
Functions\Release()
EndIf
LogonControl\Release()
EndIf
Code: Select all
retcd = R3Connection\Invoke("Logon(0, #True)") ;Does this need to be retcd = R3Connection\GetIntegerProperty("Logon(0, #True)") ???
func = Functions\GetObjectProperty("Add('RFC_LOGON_INFO')")
If func
; eNUMBER_OF_ENTRIES = func\GetIntegerProperty("NUMBER_OF_ENTRIES")
; If eNUMBER_OF_ENTRIES
e1 = func\Invoke("Call")
z2.s = func\GetStringProperty("Imports\RFC_LOGIN_COMPLETE")
Debug "RFC_LOGIN_COMPLETE = " + z2.s
;Debug e1\GetStringProperty("RFC_LOGIN_COMPLETE")
;iTABLE_NAME = func\GetObjectProperty("Exports('TABLE_NAME')")
If iTABLE_NAME
; tENTRIES = func\GetObjectProperty("Tables('ENTRIES')")
; If tENTRIES
iTABLE_NAME\SetProperty("Value = 'TCURR')")
func\Invoke("Call")
;Debug "Number of entries = " + Str(eNumber_OF_ENTRIES\GetIntegerProperty("Value"))
Debug COMate_GetLastErrorDescription()
;eMAXIMAL_RESOURCES = func\GetIntegerProperty("NUMBER_OF_ENTRIES")
Debug Str(eNUMBER_OF_ENTRIES\GetIntegerProperty("NUMBER_OF_ENTRIES") )
Debug Str(eNumber_OF_ENTRIES\GetIntegerProperty("Value"))
; eNUMBER_OF_ENTRIES = func\GetObjectProperty("Imports('NUMBER_OF_ENTRIES')")
; Debug Str(eNUMBER_OF_ENTRIES\GetIntegerProperty("NUMBER_OF_ENTRIES") )
; Debug Str(eNumber_OF_ENTRIES\GetIntegerProperty("Value"))
Debug eNumber_OF_ENTRIES\GetStringProperty("Value")
Debug eNumber_OF_ENTRIES\GetStringProperty("NUMBER_OF_ENTRIES")
Debug eNUMBER_OF_ENTRIES\GetIntegerProperty("Value")
Debug COMate_GetLastErrorDescription()
Debug func\GetIntegerProperty("NUMBER_OF_ENTRIES")
;Debug PeekL(eNumber_OF_ENTRIES)
; tENTRIES\Release()
; EndIf
iTABLE_NAME\Release()
EndIf
; eNUMBER_OF_ENTRIES\Release()
; EndIf
func\Release()
EndIf
R3Connection\Release()
EndIf
Functions\Release()
EndIf
LogonCOntrol\Release()
EndIf
Code: Select all
IncludePath "..\"
XIncludeFile "COMate.pbi"
Define.COMateObject myMODI , myLAYOUT
; Define.COMateObject e1 , e2, e3, e4, e5, e6, e99
;
; Define.l Result,*ResultR.VARIANT,*ResultG.VARIANT,*ResultB.VARIANT
;myLAYOUT = COMate_CreateObject("MODI.Layout")
;Debug COMate_GetLastErrorDescription()
myMODI = COMate_CreateObject("MODI.Document")
Debug COMate_GetLastErrorDescription()
;Debug COMate_GetLastErrorDescription()
img.s = "C:\z.tif"
;myMODI\SetProperty("FileName = '"+img.s+"'")
;Debug COMate_GetLastErrorDescription()
;z.s = myMODI\GetStringProperty("FileName")
;Debug z.s
cmd$ = "Create('" + img.s +"')"
myMODI\Invoke(cmd$)
;myMODI\Invoke("Create('c:\test.bmp')")
Define miLANG_ENGLISH$ = "9"
Debug COMate_GetLastErrorDescription()
Debug subrc
;subrc = myMODI\Invoke(z$)
;Debug COMate_GetLastErrorDescription()
Debug subrc
saveAs$ = "SaveAs('" + "C:\doc.mdi" + "', '4')"
myMODI\Invoke(saveAs$)
Debug COMate_GetLastErrorDescription()
zz = myMODI\GetIntegerProperty("Images\Count")
Debug z
Debug COMate_GetLastErrorDescription()
zOCR$ = "Ocr('"+miLANG_ENGLISH$+"', #True, #False)"
myMODI\Invoke(zOCR$)
Debug z$
Debug COMate_GetLastErrorDescription()
myLAYOUT = myMODI\GetObjectProperty("Images(0)\Layout")
Debug COMate_GetLastErrorDescription()
t$ = myLAYOUT\GetStringProperty("Text")
Debug "text = " + t$
t$ = myLAYOUT\GetStringProperty("Language")
Debug "language = " + t$
nb = myLAYOUT\GetIntegerProperty("NumWords")
Debug "nb Words = " + Str(nb)
Debug COMate_GetLastErrorDescription()
t$ = myLAYOUT\GetStringProperty("Words(0)\Text")
Debug "1st Word = " + t$
Debug COMate_GetLastErrorDescription()
Code: Select all
iTABLE_NAME\SetProperty("Value = 'TCURR')")
Code: Select all
Define.l Result,*ResultR.VARIANT
TableFactory = COMate_CreateObject("Sap.TableFactory.1")
; Debug TableFactory
If TableFactory
myObj = TableFactory\GetObjectProperty("NewTable")
Debug COMate_GetLastErrorDescription()
Debug myObj
; TAB512 = name of STRUCTURE to read
cmd$ = "CreateFromhandle(" + Str(R3Connection) + " As COMateObject, " + Str(iTable_NAME) + ", 'TAB512', 'Data')"
myObj\Invoke(cmd$)
Debug COMate_GetLastErrorDescription()
z2.l = myObj\GetIntegerProperty("ColumnCount")
Debug z2
For i = 1 To z2
;ColumnCount
Debug myObj\GetStringProperty("ColumnName("+Str(i)+")")
Next i
;Debug iTable_NAME\wa
nbRows = iTable_NAME\GetIntegerProperty("Rows")
Debug nbRows
EndIf
Code: Select all
Define.COMateObject etable
etable = func\GetObjectProperty("Tables('OPTIONS')") ;ok
etable\Invoke("AppendRow") ;ok
z2.l = etable\GetIntegerProperty("RowCount") ;ok
Debug z2.l ; ok
Debug COMate_GetLastErrorDescription() ;ok
Debug COMate_GetLastErrorDescription()
cmd$ = "Columns('TEXT')\Value(0) = 'WERKS' = 'F101'"
etable\SetProperty(cmd$)
Debug COMate_GetLastErrorDescription()
Code: Select all
cmd$ = "Columns('TEXT')\Value(0) = 'WERKS = F101'"
Code: Select all
cmd$ = "Columns('TEXT')\Value(0) = 'WERKS = $0027F101$0027'"
Code: Select all
cmd$ = "Columns('TEXT')\Value(1) = 'WERKS = F101'"
Code: Select all
Private Sub Form_Load()
'activer la reference Microsoft HTML Objects Library
'activer la refenrce Microsoft Internet Controls
Dim i As Integer
Dim IE As InternetExplorer
Dim maPageHtml As HTMLDocument
Dim Helem As IHTMLElementCollection
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "http://www.google.fr/"
Do Until IE.readyState = READYSTATE_COMPLETE
DoEvents
Loop 'attendre la fin du chargement
Set maPageHtml = IE.document
Set Helem = maPageHtml.getElementsByTagName("input")
'
'quand tu connais l'index des objets tu peux utiliser le code comme ci dessous
'pour remplir le champ
Helem.Item(1).innerText = "developpez.com"
'simule le clic sur le bouton "Recherche Google"
'Helem(2).Click
End Sub
Code: Select all
IncludePath "..\"
XIncludeFile "COMate.pbi"
FileName$ = GetTemporaryDirectory() + "test.html"
HTTPObject.COMateObject
HTTPObject = COMate_CreateObject("InternetExplorer.Application")
If HTTPObject
HTTPObject\Invoke("Visible= 1")
HTTPObject\invoke("Navigate 'http://www.google.fr/'")
; HTTPObject\Invoke("Open('GET', 'http://www.purebasic.fr/english/', #False)") ;A Boolean type is the default for a #False parameter.
; HTTPObject\Invoke("Send")
; status$ = HTTPObject\GetStringProperty("StatusText")
If status$ = "OK"
; response$ = HTTPObject\GetStringProperty("ResponseText")
; File = CreateFile(#PB_Any, FileName$)
; If File
; WriteString(File, response$)
; CloseFile(File)
; RunProgram(FileName$)
; EndIf
EndIf
HTTPObject\Release()
EndIf