fbpx
Welcome, Guest
Username: Password: Remember me
Visual Objects

Please use this forum to post questions about Visual Objects and Vulcan.NET
  • Page:
  • 1

TOPIC:

How to prepare VO for using methods from another library? 03 May 2021 18:23 #18278

  • ic2's Avatar

  • ic2

  • Topic Author


  • Posts: 938
  • This is a bit a follow up of this post:

    www.xsharp.eu/forum/public-vo-vn/1853-qu...ed-per-library#13964
    In short:

    Most of our programs are a main program (often not more than a standard shell menu) and a few included libraries.

    We have 1 AEF/library in VO which is basically our e-mail program. In this AEF, there are a few methods in 1 MEF from classes from our main library.

    E.g.

    Method ShowMail(param1,param2) CLASS SomeWindow
    // Opens specific methods and windows from the email library

    This method is called from the main library as follows: Send(#Showmail,param1,param2). This we need to do because in the library itself method ShowMail is not available.

    This works fine in VO, but it does not when eventually we move to X#. .Net does not allow a method of class SomeWindow to reside in another prg than where the SomeWindow class is, otherwise you get external classes generated and everywhere error XS9016 .

    What would be a recommended way to solve this in VO to make a future move to X# easy?

    Dick

    Please Log in or Create an account to join the conversation.

    Last edit: by ic2.

    How to prepare VO for using methods from another library? 03 May 2021 19:21 #18279

  • Chris's Avatar

  • Chris


  • Posts: 2495
  • Hi Dick,

    Usually the best way is to use a subclass. In your main app, define a CLASS ChildWindow INHERIT SomeWindow and define the method as part of this class. Then, when you create this window object, instead of using SomeWindow{}, use ChildWindow{} and do not change anything else. This should work without changes in both VO and X#.
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    How to prepare VO for using methods from another library? 03 May 2021 21:17 #18282

  • ic2's Avatar

  • ic2

  • Topic Author


  • Posts: 938
  • Hello Chris,

    That won't work I'd say because I can't create that method in my main app, as it uses classes from within the e-mail library, the 2nd lib. So I can't define it in the main app, and when I define it in the e-mail app with a different class name than I do now (=the inherited ChildWindow) then X# would still complain that it doesn't know class ChildWindow, as this is defined in the main app.

    Even in VO this is not ideal. For example, I can't strong type a method email library when the class is defined in he main program. I don't see a real good solution for having some methods working on everything in library B when these methods belong to a class defined in library A. Probably the DELEGATE solution from your other reply is needed after all and in the end, even more elegant than the Send(# without any compiler checks and the necessity for non strong typed methods in the library B as required in VO.

    Dick

    Please Log in or Create an account to join the conversation.

    How to prepare VO for using methods from another library? 03 May 2021 22:56 #18287

  • robert's Avatar

  • robert


  • Posts: 2174
  • Dick,

    In .Net you would solve this with interfaces, which VO does not have. That is one of the BIG advantages of X# over VO.
    To solve this in VO you will have to use some kind of late binding.
    I suggest you create a subclass for the window and create the window in your main app with CreateInstance(#ClassName) . This #ClassName could be stored in a variable that you can override from the library.

    And then you call the methods on this object with Send, or you simply do not type the variable in which you store the window object and so the compiler will call the methods late bound.
    Inside the library everything can be early bound of course.

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    How to prepare VO for using methods from another library? 04 May 2021 12:38 #18294

  • ic2's Avatar

  • ic2

  • Topic Author


  • Posts: 938
  • Hello Robert,

    Thank you for your suggestion. Although, as you know, I find only few advantages of .Net & .Net languages above VO I recognize that this could be solved better in .Net.
    I try to prepare as much as possible in VO but for this I will have to do it differently in X#, with delegates or interfaces anyway, so I left the solution as it was (just a Send and not strong typing the called method).

    Dick

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1