I feel like I'm going about this the wrong way, so feel free to suggest a better approach...
I have a method on one form that I'd like to be able to call from a different form.
I know about $MethodName_EventType.Invoke() but that seems to be limited to a single form?
This approach probably has all sorts of variable scope issues...
Maybe what I really should do is create this as a function in another file and include it with command extension = true...
Thoughts?
Call a method from a different form
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Call a method from a different form
Functions in another form cannot be reached as the form is not available until it is displayed.
Use a project and add the functions to the "globals" file . Loading functions into a form from a file will only make the functions available in that form due to scoping restrictions.
You can also place functions in a module and load it as a referenced module from the module path.
Use a project and add the functions to the "globals" file . Loading functions into a form from a file will only make the functions available in that form due to scoping restrictions.
You can also place functions in a module and load it as a referenced module from the module path.
Re: Call a method from a different form
Apologies in advance...
Can you clarify for me the difference b/t globals.ps1 and "startup.pss" which are both created with a new project?
When is it appropriate to put things in one vs the other?
What order are they executed in?
Did I miss a key bit of documentation re: how the SAPIEN Powershell Studio framework is organized?
Can you clarify for me the difference b/t globals.ps1 and "startup.pss" which are both created with a new project?
When is it appropriate to put things in one vs the other?
What order are they executed in?
Did I miss a key bit of documentation re: how the SAPIEN Powershell Studio framework is organized?
Re: Call a method from a different form
Two suggestions will help with this:
1. Read the text in the two provided files.
2. Read the "Project" section of the product manual. It will give you detailed info on how t use a project.
1. Read the text in the two provided files.
2. Read the "Project" section of the product manual. It will give you detailed info on how t use a project.