Cross-File Class Support

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
JDruhan
Posts: 10
Last visit: Thu Nov 23, 2017 8:00 am

Cross-File Class Support

Post by JDruhan »

PowerShell Studio 2017 v5.4.145

I noticed in the 5.4.144 changes that there was a note about cross-file class support however I'm not able to get it working. The additional class enhancements are awesome but I need to be able to reference classes from other files with PrimalSense compatibility.

Am I missing something on how to tell my script files that it uses classes from external files?

For example ...

exampleClass.PSM1

Code: Select all

class myClass
{
 # .... CODE HERE.
}
App.PS1

Code: Select all

Using Module "exampleClass.PSM1";

$testObj = [myClass]::new();

$testObj.<PRIMALSENSE>  #Doesn't work.
cody m

Re: Cross-File Class Support

Post by cody m »

[TOPIC MOVED TO THE POWERSHELL STUDIO FORUM BY MODERATOR]
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Cross-File Class Support

Post by davidc »

Modify your using statement as follows:

Code: Select all

Using Module ".\exampleClass.PSM1"
David
SAPIEN Technologies, Inc.
User avatar
JDruhan
Posts: 10
Last visit: Thu Nov 23, 2017 8:00 am

Re: Cross-File Class Support

Post by JDruhan »

That fixed it thanks. But it looks like you guys haven't figured out recursive/nested classes in imported files that import other classes.
This topic is 6 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.