Knowing what arguments to pass into subs  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Knowing what arguments to pass into subs

Postby DannyC » Mon Dec 07, 2015 10:42 am

Hi,

When developing plugins, different events need different things passed into the subroutines on the AddHandler....AddressOf lines.
For example,
Code: Select all
AddHandler salesOrderForm.SalesOrder.Printing, AddressOf SOPrinting

requires
Code: Select all
Sub SOPrinting (sender As Object, e As System.eventargs, ByRef Report As JiwaApplication.PrintGroup.SalesOrderReports.SalesOrderReport)


Or say
Code: Select all
AddHandler salesOrderForm.SalesOrder.SalesOrderLines.Changed, AddressOf SOLine_Changed

requires
Code: Select all
Sub   SOLine_Changed(item As JiwaSales.SalesOrder.SalesOrderLine, e As System.ComponentModel.PropertyChangedEventArgs)


Is there documentation we can turn to which describes what needs to get passed into the subroutines for various events?

My current hurdle is to find what I need to pass into the sub for JobCostForm.Job.Read event
Code: Select all
    Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
      Dim jobCostForm As JiwaJobCostingUI.MainForm = DirectCast(JiwaForm, JiwaJobCostingUI.MainForm)            
      AddHandler jobCostForm.Job.Read, AddressOf JobRead
    End Sub


The ultimate goal of this plugin is to fully lock a Job Costing job when the status is "Closed". And maybe provide a button on the utilities menu to unlock it if really, absolutely necessary.
cheers

Danny
Last edited by DannyC on Mon Dec 07, 2015 4:48 pm, edited 1 time in total.
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Knowing what objects to pass into subs

Postby Mike.Sheen » Mon Dec 07, 2015 10:54 am

DannyC wrote:Is there documentation we can turn to which describes what needs to get passed into the subroutines for various events?


Does the intellisense/prompt in the plugin editor not provide a tooltip showing you the required signature?

In any event, there is always the reference documentation - it shows the signature the Read event for that class as no arguments:

Job_Read_Event_Reference.PNG
Reference for Job Read Event
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Knowing what objects to pass into subs

Postby DannyC » Mon Dec 07, 2015 11:24 am

Thanks Mike,

I was looking at the reference documentation, but it doesn't tell me what the arguments are I need to pass in. As an example to your screenshot, If I find another event which I know needs parameters, say for the sales order line changed, it doesn't show any arguments to pass in.

Does the intellisense/prompt in the plugin editor not provide a tooltip showing you the required signature?

Nope. Should it? When I hover the mouse over the AddHandler jobCostForm.Job.Read , it just shows Job.Read as ReadEventHandler.
If I hover the mouse over the AddressOf JobRead, it only shows the arguments which have already been coded in the sub. If you want to know the arguments beforehand and you haven't started writing the sub yet, it doesn't show anything.

Cheers

Danny
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Knowing what objects to pass into subs

Postby Mike.Sheen » Mon Dec 07, 2015 11:45 am

Well, that's all rather disappointing! I never noticed the intellisense not showing arguments for events (methods seem to be ok).

I'll see what we can do there to improve things.

I guess the short-term workaround is to open a visual studio project, reference the desired assemblies and get the arguments via visual studio's intellisense/prompt or via the object browser.

Mike
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Knowing what objects to pass into subs

Postby DannyC » Mon Dec 07, 2015 11:59 am

Alrightly, no probs.
I generally write my plugins directly into the plugin code window, but I guess I'll need to start using VS!

Cheers

Danny
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Knowing what arguments to pass into subs  Topic is solved

Postby marcosomizu » Wed Dec 09, 2015 1:11 pm

Hi DannyC,

One thing that helps me when I need to create a new event that I don't know the arguments is:

When you are creating the Handler, just put a "(" at the end of the method, and then the intellisense will come up and you'll see what are the arguments of this event.

For example, your handler is:

Code: Select all
AddHandler salesOrderForm.SalesOrder.CreateEnd, AddressOf SalesOrder_Created


In order to see which arguments the CreateEnd event needs, just type "(" next to the event delegate:

Code: Select all
AddHandler salesOrderForm.SalesOrder.CreateEnd(


The intellisense will appear with the following information:

Code: Select all
Sub CreateEndEventHandler.Invoke(ByVal sender As Object, ByVal e As EventArgs)


Hope this helps!

Cheers
marcosomizu
Occasional Contributor
Occasional Contributor
 
Posts: 23
Joined: Mon Sep 07, 2015 12:01 pm
Topics Solved: 1

Re: Knowing what arguments to pass into subs

Postby DannyC » Thu Dec 10, 2015 9:24 am

Nice tip! That works great.
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 1 guest