FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Code from .3 fails with .4

 
Post new topic   Reply to topic     Forum Index -> Juno
View previous topic :: View next topic  
Author Message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Thu Mar 19, 2009 11:05 pm    Post subject: Code from .3 fails with .4 Reply with quote

greetings.

I have this program that works with 3.0.
Code:

private import juno.com.core;
private import juno.com.client;
private import std.stdio;

void main ()
{
    char[] bodyOut = "Body out...";
    scope oApp = new DispatchObject("Outlook.Application");

    scope oMsg = new DispatchObject(oApp.get("CreateItem", 0));

    scope oMRe = new DispatchObject(oMsg.call("Recipients"));

    oMRe.call("Add","Eliane");

    oMsg.set("Subject", "Email subjectblah");

    oMsg.set("BodyFormat", 2);

    oMsg.set("HTMLBody", bodyOut);

    oMsg.call("Display");
}


but it fails with .40 with these errors:
Quote:

0:53:35.99>build -I..;c:\dmd\import -version=gui -version=Phobos email.d
email.d(10): template juno.com.client.DispatchObject.get(R = DispatchObject) does not match any template declaration
email.d(10): template juno.com.client.DispatchObject.get(R = DispatchObject) cannot deduce template function from argument types (char[10u],int)
email.d(10): constructor juno.com.client.DispatchObject.this (GUID ,ExecutionContext) does not match parameter types (int)
email.d(10): class juno.com.client.DispatchObject member this is not accessible
email.d(10): Error: cannot implicitly convert expression ((oApp.get(R = DispatchObject))("CreateItem",0)) of type int to VARIANT
email.d(10): Error: expected 2 arguments, not 1


I tried both get and call for the CreateItems and Recipients.

Any help would be greatly appreciated.

thanks,

jic
Back to top
View user's profile Send private message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Sun Mar 22, 2009 1:28 pm    Post subject: Reply with quote

Ok, so after many tries, Smile, I was able to figure it out. Here is the last code,
Code:

private import juno.com.core;
private import juno.com.client;
private import std.stdio;

void main ()
{
    char[] bodyOut = "Body out...";
    scope oApp = new DispatchObject("Outlook.Application");

    //scope oMsg = new DispatchObject(oApp.get("CreateItem", 0)); //old .30 code
    scope oMsg = oApp.call("CreateItem", 0);  // new .40 code

    //scope oMRe = new DispatchObject(oMsg.call("Recipients"));  //old .30 code
    scope oMRe = oMsg.call("Recipients");  // new .40 code

    oMRe.call("Add","Eliane");

    oMsg.set("Subject", "Email subjectblah");

    oMsg.set("BodyFormat", 2);

    oMsg.set("HTMLBody", bodyOut);

    oMsg.call("Display");
}

[quote]

It would be nice if there was a change log somewhere to know what some of the new changes are.  I know I should keet track of it it more often.  I really do appreciate your work, John. This is great.

thanks,

jose[/quote]
Back to top
View user's profile Send private message
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Mon Mar 23, 2009 12:23 pm    Post subject: Reply with quote

jicman wrote:
Ok, so after many tries, Smile, I was able to figure it out.
...

It would be nice if there was a change log somewhere to know what some of the new changes are. I know I should keet track of it it more often. I really do appreciate your work, John. This is great.

thanks,

jose


I'm glad you were able to get your project working with Juno 0.4. Did you have to change any of the Juno source to compile it? I'm also curious: which compiler did you use?

I'd find it useful if we had a list of changes, too. I think John made extensive changes from 0.30 to 0.40. Even though it appears he removed the folders as a SVN comit and then added the new source, I found that you can still use Trac to see changes if a file or path exists in the older and newer revision, such as this diff that I think shows most of the differences between Juno 0.40 and Juno 0.30.
Back to top
View user's profile Send private message AIM Address
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Mon Mar 23, 2009 1:00 pm    Post subject: Reply with quote

I can use all the way up to dmd 1.030. However, after this one, I get this error:

Quote:
21:48:56.40>build -I..;c:\dmd\import -version=gui -version=Phobos excel.d
C:\cygwin\home\us319318\source\d\juno\com\core.d(370): Error: argument IUnknown to typeof is not an expression
C:\cygwin\home\us319318\source\d\juno\com\core.d(370): Error: cannot implicitly convert expression (uuidofT!(IUnknown)) of type void to GUID
C:\cygwin\home\us319318\source\d\juno\com\core.d(2601): template instance juno.com.core.uuidof!(IUnknown) error instantiating


So, I went back to 1.030. So, my setup has dmd 1.030, dfl-0.98 and juno .40. Though, I have to go back to .30 since I can not seem to get,
Code:
scope wsSel = WS.call("Cells", r, c++);

to work. It compiles fine, but when I run it, I get just a plain "Error:" and no other option. I can get it to work with .30, though.

ihth,

jose
Back to top
View user's profile Send private message
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Mon Mar 23, 2009 1:56 pm    Post subject: Reply with quote

jicman wrote:
I can use all the way up to dmd 1.030. However, after this one, I get this error:

Quote:
21:48:56.40>build -I..;c:\dmd\import -version=gui -version=Phobos excel.d
C:\cygwin\home\us319318\source\d\juno\com\core.d(370): Error: argument IUnknown to typeof is not an expression
C:\cygwin\home\us319318\source\d\juno\com\core.d(370): Error: cannot implicitly convert expression (uuidofT!(IUnknown)) of type void to GUID
C:\cygwin\home\us319318\source\d\juno\com\core.d(2601): template instance juno.com.core.uuidof!(IUnknown) error instantiating


So, I went back to 1.030. So, my setup has dmd 1.030, dfl-0.98 and juno .40. Though, I have to go back to .30 since I can not seem to get,
Code:
scope wsSel = WS.call("Cells", r, c++);

to work. It compiles fine, but when I run it, I get just a plain "Error:" and no other option. I can get it to work with .30, though.

ihth,

jose
Thanks for sharing your story. I believe I've seen that same "(uuidofT!(IUnknown))" error message, but I wasn't able to figure out how to change the Juno source to get it to compile. (John uses some D programming techniques that are way over my head.)

I actually haven't been working on any Juno-related projects for at least several weeks, but a few months ago I ran into several problems. Eventually, I got things working using DMD 1.024, Juno SVN rev179 (with the patch from thread #3257). I don't remember exactly why I chose DMD 1.024 and rev179, but I think it was the first combination that I was able to move forward with.

My biggest remaining problem was that Juno (rev179) required a different form of import files than I had created before, but tlbimpd wouldn't create them for me (and I couldn't even recompile tlbimpd myself for debugging purposes). Instead, I used my own import file generator that worked well enough for me to get my examples working again.
Back to top
View user's profile Send private message AIM Address
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Mon Mar 23, 2009 4:27 pm    Post subject: Reply with quote

Quote:
(John uses some D programming techniques that are way over my head.)


Yeah, he is good. Smile I want to help him with some documentation, but I just don't have any time. With getting married, work, volleyball tournaments, etc., I find very little time to help. Sad

I was able to export some DLLs with .4, at the end of last year, but now it may be broken with .40. You will see it here soon. Smile

My problem is that this is production work, and with phobos, DFL, juno and DBI, right now, and so I have to keep 3 different compiling setups to be able to continue to debug and upgrade to the latest version of each. I gave up on dbi, since they move totally to mango, and that's far long on my todo.

Anyway, thanks for the response.

jose
Back to top
View user's profile Send private message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Wed Mar 25, 2009 5:09 pm    Post subject: Reply with quote

Ok, now to debug the last problem I have, and after that, I will be all juno .40'ed. Smile This code compiles and works great with .30 or .35, one of those:
Code:
private import juno.com.core;
private import juno.com.client;
private import std.stdio;

void main ()
{
  scope xl = new DispatchObject("Excel.Application");
  //var xl = WScript.CreateObject("Excel.Application");

  xl.set("Visible", false);
  //xl.Visible = false;
  char[] nf = r"c:\text.xls";

  if (std.file.exists(nf))
    std.file.remove(nf);

  int r, c;
  r = 1;
  c = 1;
  int wsheet = 1;

  writefln("0.");
  scope wb = new DispatchObject(xl.get("WorkBooks"));
  writefln("1.");
  wb.call("Add");
  writefln("2.");
  //xl.WorkBooks.Add;
  xl.set("Visible", true);
  writefln("3.");
  //Worksheets("Sheet1").Cells(5, 3).Value = "data";

  scope xlWS = new DispatchObject(xl.get("WorkSheets", wsheet)); // juno .30
  writefln("4.");
  scope cell = new DispatchObject(xlWS.get("Cells", r, c++)); // juno .30
  writefln("5.");
  cell.set("Value", "data");
  writefln("6.");

  scope col = new DispatchObject(xl.get("Columns", 1));  // juno .30
  writefln("7.");
  col.set("ColumnWidth", 50);
  writefln("8.");

  wb.call("Close");
  xl.call("Quit");
 
}


the programs works as desired. The same program does not compile with .40:
Quote:
18:55:43.74>build -I..;c:\dmd\import excel3.d
excel3.d(23): constructor juno.com.client.DispatchObject.this (GUID,ExecutionContext) does not match parameter types (DispatchObject)
excel3.d(23): class juno.com.client.DispatchObject member this is not accessible

excel3.d(23): Error: cannot implicitly convert expression (xl.get("WorkBooks"))
of type juno.com.client.DispatchObject to VARIANT
excel3.d(23): Error: expected 2 arguments, not 1


So, I tried fixing it as the example for the CDO.message that you provided: and here is the code changes:
Code:
private import juno.com.core;
private import juno.com.client;
private import std.stdio;

void main ()
{
  scope xl = new DispatchObject("Excel.Application");
  //var xl = WScript.CreateObject("Excel.Application");

  xl.set("Visible", false);
  //xl.Visible = false;
  char[] nf = r"c:\text.xls";

  if (std.file.exists(nf))
    std.file.remove(nf);

  int r, c;
  r = 1;
  c = 1;
  int wsheet = 1;

  writefln("0.");
  //scope wb = new DispatchObject(xl.get("WorkBooks"));  Juno .30 works
  scope wb = xl.get("WorkBooks");
  writefln("1.");
  wb.call("Add");
  writefln("2.");
  //xl.WorkBooks.Add;
  xl.set("Visible", true);
  writefln("3.");
  //Worksheets("Sheet1").Cells(5, 3).Value = "data";

  //scope xlWS = new DispatchObject(xl.get("WorkSheets", wsheet)); // juno .30
  scope xlWS = xl.call("WorkSheets", wsheet);
  writefln("4.");
  //scope cell = new DispatchObject(xlWS.get("Cells", r, c++)); // juno .30
  scope cell = xlWS.call("Cells", r, c++);
  writefln("5.");
  cell.set("Value", "data");
  writefln("6.");

  //scope col = new DispatchObject(xl.get("Columns", 1));  // juno .30
  scope col = xl.call("Columns", 1);
  writefln("7.");
  col.set("ColumnWidth", 50);
  writefln("8.");

  wb.call("Close");
  xl.call("Quit");
 
}


Here is the compilation and run of the above:
Quote:
19:03:21.33>build -I..;c:\dmd\import excel3b.d

19:03:37.58>excel3b
0.
1.
2.
3.
Error:

19:03:47.31>


I have spent days, trying to get this to work, but I just don't understand COM as i thought.

thanks for the help.

jose
Back to top
View user's profile Send private message
John



Joined: 17 Jan 2006
Posts: 75

PostPosted: Fri Apr 10, 2009 2:39 am    Post subject: Reply with quote

Sorry for the pain, chaps! I'll release 0.4.1 in a few days, which I hope will address these issues.

John.
Back to top
View user's profile Send private message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Fri Apr 10, 2009 7:06 am    Post subject: Reply with quote

No problem. I am just glad you're alive. Smile I thought you were taken by pirates, or something. Ja ja ja ja...

jose
Back to top
View user's profile Send private message
John



Joined: 17 Jan 2006
Posts: 75

PostPosted: Fri Apr 10, 2009 4:47 pm    Post subject: Reply with quote

Here's a temporary fix until 0.4.1 comes along. I messed up 0.4. Sorry.

Open juno.com.client and overwrite DispatchObject with the code below, then recompile. I've also included an Excel example that worked for me (remember to use "call" for functions, "get/set" for properties, otherwise they'll fail).

Code:
class DispatchObject {

  private IDispatch target_;
  private VARIANT result_;

  this(GUID clsid, ExecutionContext context = ExecutionContext.InProcessServer | ExecutionContext.LocalServer) {
    target_ = coCreate!(IDispatch)(clsid, context);
    if (target_ is null)
      throw new InvalidOperationException;
  }

  this(GUID clsid, string server, ExecutionContext context = ExecutionContext.InProcessServer | ExecutionContext.RemoteServer) {
    target_ = coCreateEx!(IDispatch)(clsid, server, context);
    if (target_ is null)
      throw new InvalidOperationException;
  }

  this(string progId, ExecutionContext context = ExecutionContext.InProcessServer | ExecutionContext.LocalServer) {
    target_ = coCreate!(IDispatch)(progId, context);
    if (target_ is null)
      throw new InvalidOperationException;
  }

  this(string progId, string server, ExecutionContext context = ExecutionContext.InProcessServer | ExecutionContext.RemoteServer) {
    target_ = coCreateEx!(IDispatch)(progId, server, context);
    if (target_ is null)
      throw new InvalidOperationException;
  }

  this(IDispatch target) {
    if (target is null)
      throw new ArgumentNullException("target");

    target.AddRef();
    target_ = target;
  }

  this(VARIANT target) {
    if (auto target = com_cast!(IDispatch)(result)) {
      target_ = target;
    }
  }

  private this(VARIANT result, uint ignore) {
    if (auto target = com_cast!(IDispatch)(result)) {
      target_ = target;
    }
    result_ = result;
  }

  ~this() {
    release();
  }

  final void release() {
    result_.clear();

    if (target_ !is null) {
      tryRelease(target_);
      target_ = null;
    }
  }

  R call(R = DispatchObject)(string name, ...) {
    static if (is(R == DispatchObject))
      return new DispatchObject(invokeMethod(target_, name, _arguments, _argptr), 0);
    else {
      R ret = invokeMethod!(R)(target_, name, _arguments, _argptr);
      result_ = ret;
      return ret;
    }
  }

  R get(R = DispatchObject)(string name, ...) {
    static if (is(R == DispatchObject))
      return new DispatchObject(getProperty(target_, name, _arguments, _argptr), 0);
    else {
      R ret = getProperty!(R)(target_, name, _arguments, _argptr);
      result_ = ret;
      return ret;
    }
  }

  void set(string name, ...) {
    setProperty(target_, name, _arguments, _argptr);
  }

  final IDispatch target() {
    return target_;
  }

  final VARIANT result() {
    return result_;
  }

}


Example:

Code:
scope excel = new DispatchObject("Excel.Application");
excel.set("Visible", true);

scope workbooks = excel.get("Workbooks");
scope workbook = workbooks.call("Add");

scope worksheet = excel.get("Worksheets", 1);
worksheet.set("Cells", 5, 3, "data");
 
scope column = excel.get("Columns", 1);
column.set("ColumnWidth", 50);
Back to top
View user's profile Send private message
John



Joined: 17 Jan 2006
Posts: 75

PostPosted: Sat Apr 11, 2009 2:39 am    Post subject: Reply with quote

Quote:
I believe I've seen that same "(uuidofT!(IUnknown))" error message, but I wasn't able to figure out how to change the Juno source to get it to compile.


Open juno.com.core, and comment out lines 369-371. It used to work...

Quote:
I was able to export some DLLs with .4, at the end of last year, but now it may be broken with .40. You will see it here soon


Can you supply a list of DLLs that tlbimpd chokes on?

John.
Back to top
View user's profile Send private message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Thu Apr 16, 2009 10:17 pm    Post subject: Reply with quote

Thanks, John. I tested this fix and it works with .40 after making the changes.

thanks so much.

jic
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Juno All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group