See my post higher i have the same problem with PB 4.41 executing any kind of programmsrod wrote:Which code snippet generates the error Anthony?
COMatePLUS version 1.2
Re: COMatePLUS version 1.1
Re: COMatePLUS version 1.1
I may look like a mule, but I'm not a complete ass.
Re: COMatePLUS version 1.1
I am sorry SROD but the problem is not solved even if you start with a clean version of PB4.41. I have always the problem. It seems that your bug probelm was'nt record by fred
Re: COMatePLUS version 1.1
Kiki, this is a Purebasic bug which I have reported. Worry not, Fred will fix it.
Whilst I could easily work around this, I think it is better to wait for the bug to be fixed in Purebasic.
http://www.purebasic.fr/english/viewtop ... =4&t=40750
Whilst I could easily work around this, I think it is better to wait for the bug to be fixed in Purebasic.
http://www.purebasic.fr/english/viewtop ... =4&t=40750
I may look like a mule, but I'm not a complete ass.
Re: COMatePLUS version 1.1
srod, is it possible that you could pass along the work around while waiting on the bug fix in PB?
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
Re: COMatePLUS version 1.1
No, but you can do it yourself if you are in need.
Switch all instances of '+', '-' for their Ascii codes etc. That should fix it.
Switch all instances of '+', '-' for their Ascii codes etc. That should fix it.
I may look like a mule, but I'm not a complete ass.
Re: COMatePLUS version 1.1
well, thats what I meant. 
Thanks srod

Thanks srod

The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
Re: COMatePLUS version 1.1
Why is ExecuteJavaScript to a threaded window not working? Did I miss something
thx, chi

Code: Select all
IncludePath "..\"
XIncludeFile "COMatePLUS.pbi"
Enumeration
#Win1
#Web1
#B1
EndEnumeration
#URL = "javascript:document.write("+Chr(34) +"<script type='text/javascript'> function Test(v) { alert(v); return v; } </script><body><input type='button' value=' test ' onclick='window.Test(3);'></body>" +Chr(34)+");document.close()"
Define.COMateObject WebObject
Procedure.i ExecuteJavaScript(Gadget, command$)
Protected browser.COMateObject, documentDispatch.COMateObject, script.COMateObject
Protected result
browser = COMate_WrapCOMObject(GetWindowLong_(GadgetID(gadget), #GWL_USERDATA))
If browser
documentDispatch = browser\GetObjectProperty("Document")
If documentDispatch
script = documentDispatch\GetObjectProperty("script")
If script
result = script\Invoke("eval('" + command$ + "')")
script\release()
EndIf
documentDispatch\Release()
EndIf
browser\Release()
EndIf
ProcedureReturn result
EndProcedure
Procedure OpenWin1(param)
If OpenWindow(#Win1, #PB_Ignore, #PB_Ignore, 440, 280, "win1", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
WebGadget(#Web1, 0, 0, 440, 250, #URL)
While WindowEvent():Wend
ButtonGadget(#B1, 5, 255, 95, 20, "test")
EndIf
Repeat
event=WaitWindowEvent()
Select event
Case #PB_Event_Gadget
Select EventGadget()
Case #B1
ExecuteJavaScript(#Web1,"window.Test(1);")
EndSelect
EndSelect
Until event=#PB_Event_CloseWindow
EndProcedure
thread=CreateThread(@OpenWin1(),0)
WaitThread(thread,3000)
Debug ExecuteJavaScript(#Web1,"window.Test(1);")
Repeat
WaitWindowEvent(16)
x+1
Until x=180
End
Et cetera is my worst enemy
Re: COMatePLUS version 1.1
The problem is that the COM object is being created in your thread and you are attempting to access it in your main process with the line :
This breaks the single threaded apartment model which Purebasic initialises. In this model you cannot pass COM objects between threads etc. This has been discussed before and Freak pointed out that Purebasic cannot use a multi-threaded apartment model because, amongst other things, OLE is not strictly threadsafe and OLE is required for things like drag-and-drop etc.
Comment the offending line out and everything works fine.
There are ways around this, in that there are COM functions designed to allow us to circumvent this limitation and to marshall an object created in one thread for use in another thread etc. This is not something I wish to implement, however, because it will only complicate matters and so few people would ever need this.
The point is that you will need to keep each object you create for exclusive use within the thread which created the object etc. I'm sure you'll find a way!
Code: Select all
Debug ExecuteJavaScript(#Web1,"window.Test(1);")
Comment the offending line out and everything works fine.
There are ways around this, in that there are COM functions designed to allow us to circumvent this limitation and to marshall an object created in one thread for use in another thread etc. This is not something I wish to implement, however, because it will only complicate matters and so few people would ever need this.
The point is that you will need to keep each object you create for exclusive use within the thread which created the object etc. I'm sure you'll find a way!

I may look like a mule, but I'm not a complete ass.
Re: COMatePLUS version 1.1
Thank you for pointing this out, srod!
Guess i´ll have to stick with the idea to use get/setwindowtitle... a little bit odd but good enough for now
Or any better ideas? Anyway, thx again...
chi
edit: btw. it´s for a .dll
Guess i´ll have to stick with the idea to use get/setwindowtitle... a little bit odd but good enough for now

Or any better ideas? Anyway, thx again...
chi
edit: btw. it´s for a .dll
Et cetera is my worst enemy
Re: COMatePLUS version 1.1
Simplest way is to send a message to the thread (via a global variable or registering your own window message etc.) instructing the thread to perform some task or other with the COM object. This way, when the main process requires access to the COM object, rather than do it directly (and cause an access error) get the thread to do it.
I may look like a mule, but I'm not a complete ass.
Re: COMatePLUS version 1.2
Update - 9th July 2010.
Version 1.2 (Purebasic 4.5 edition).
A bug in COMatePLUS' error reporting has been fixed in the Purebasic 4.5 edition of COMatePLUS. Other editions were not affected by this bug because I inadvertently created COMatePLUS for PB 4.5 from an out of date version of COMatePLUS... doh!!! How the hell I did that is beyond me?
See the nxSoftware site for the download.
Version 1.2 (Purebasic 4.5 edition).
A bug in COMatePLUS' error reporting has been fixed in the Purebasic 4.5 edition of COMatePLUS. Other editions were not affected by this bug because I inadvertently created COMatePLUS for PB 4.5 from an out of date version of COMatePLUS... doh!!! How the hell I did that is beyond me?

See the nxSoftware site for the download.
I may look like a mule, but I'm not a complete ass.
Re: COMatePLUS version 1.2
thanks a lot!srod wrote:A bug in COMatePLUS' error reporting has been fixed in the Purebasic 4.5 edition of COMatePLUS.

Greetings ... Kiffi
Hygge
Re: COMatePLUS version 1.2
Thank you for this release
Sincerely... GeBonet

Sincerely... GeBonet
Sorry for my english
! (Windows Xp, Vista and Windows 7, Windows 10)

- captain_skank
- Enthusiast
- Posts: 639
- Joined: Fri Oct 06, 2006 3:57 pm
- Location: England
Re: COMatePLUS version 1.2
First a little background.
Having had to use crytsal reports I needed a way to run the report from my PB app - so kludged up a command line client in vb6 as a quick n dirty way of acheiving my aim.
This works ok but is very klinky and slow so i've been wondering if i can use the crystal report conrol via pb and then I came accross comateplus.
I've had a good read or the help and a look at the examples but I'm just not getting it so before I waste to much time I thought i'd ask the expert(s) if it's actually possible to do.
Soooo, how can i convert the following simple 2 form vb app ( form1 has a button, Command1, and the code below calls form2 which has the cr viewer control on )
Private Sub Command1_Click()
Dim crApp As CRAXDRT.Application
Dim Report As CRAXDRT.Report
Dim strSelectionfrm As String
Set crApp = New CRAXDRT.Application
Set Report = crApp.OpenReport("C:\xyz\spec_master.rpt")
Form2.CrystalActiveXReportViewer1.ReportSource = Report
Form2.CrystalActiveXReportViewer1.ViewReport
Form2.Show
End Sub
the two libraries are referenced in the project Crystal ActiveX Report Viewer Library 11.5, Crystal Reports ActiveX Designer Run Time Library 11.5
I'd be really gratefull for any and all help as this will improve my app no end and make life a whole ot easier.
Thanks
captain_s
Having had to use crytsal reports I needed a way to run the report from my PB app - so kludged up a command line client in vb6 as a quick n dirty way of acheiving my aim.
This works ok but is very klinky and slow so i've been wondering if i can use the crystal report conrol via pb and then I came accross comateplus.
I've had a good read or the help and a look at the examples but I'm just not getting it so before I waste to much time I thought i'd ask the expert(s) if it's actually possible to do.
Soooo, how can i convert the following simple 2 form vb app ( form1 has a button, Command1, and the code below calls form2 which has the cr viewer control on )
Private Sub Command1_Click()
Dim crApp As CRAXDRT.Application
Dim Report As CRAXDRT.Report
Dim strSelectionfrm As String
Set crApp = New CRAXDRT.Application
Set Report = crApp.OpenReport("C:\xyz\spec_master.rpt")
Form2.CrystalActiveXReportViewer1.ReportSource = Report
Form2.CrystalActiveXReportViewer1.ViewReport
Form2.Show
End Sub
the two libraries are referenced in the project Crystal ActiveX Report Viewer Library 11.5, Crystal Reports ActiveX Designer Run Time Library 11.5
I'd be really gratefull for any and all help as this will improve my app no end and make life a whole ot easier.
Thanks
captain_s