Strange modification of comportment between Studio v3.11 and upper versions With Powshell v 3.0

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 11 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
eric.morsa@isl.be
Posts: 9
Last visit: Fri Jul 23, 2021 2:41 am

Strange modification of comportment between Studio v3.11 and upper versions With Powshell v 3.0

Post by eric.morsa@isl.be »

I have some 'Forms Projects Script' that are working correctly with Studio 2012 V 3.11 if i specifies that i use MS-PS V2

When i specifies that i use MS-PS V3, it seems that some globals variables ( created in global.ps1) are no more global.

Ok, i thinking : it is very strange but it may be it a consequence the change to MS-PS V3.

But When i make the upgrade from studio 2012 version V 3.11 to versions (3.12 - 3.14), i got the same problem whatever way i use MS-PS V2 or V3.

I don't undertand what's going on there.

Have Some Explanation ?

Best Regards
Eric
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Strange modification of comportment between Studio v3.11 and upper versions With Powshell v 3.0

Post by davidc »

When you say 'no longer global' do you mean when you run the script or the PrimalSense is not displaying the variables?

David
David
SAPIEN Technologies, Inc.
User avatar
eric.morsa@isl.be
Posts: 9
Last visit: Fri Jul 23, 2021 2:41 am

Strange modification of comportment between Studio v3.11 and upper versions With Powshell v 3.0

Post by eric.morsa@isl.be »

I got an error message.
It is like the variable was recreated with an empty value.

Eric
ERROR: Propriété « Tables » introuvable dans cet objet. Assurez-vous qu’elle existe.
ERROR: + CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
ERROR: + FullyQualifiedErrorId : PropertyNotFoundStrict
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Strange modification of comportment between Studio v3.11 and upper versions With Powshell v 3.0

Post by davidc »

Please zip and email your project to support@sapien.com and we will see if we can recreate the problem.

Just in case, make sure you are running the Project (Ctrl + F4) and not the single file (Ctrl + F5).

David
David
SAPIEN Technologies, Inc.
User avatar
eric.morsa@isl.be
Posts: 9
Last visit: Fri Jul 23, 2021 2:41 am

Strange modification of comportment between Studio v3.11 and upper versions With Powshell v 3.0

Post by eric.morsa@isl.be »

Thanks for your Help.
I attach a file with a sample of code.

I use a personnal function that open a database (centralized functions).
The function is created in "Global.ps1".
I used this function in "startup.psf".
I load a Combobox in "OnLoadFormEvent" in the "MainForm.pff".
In "button1_Click", i use the data of the combobox.

This code runs rigth in Studio 2012 V3.11 with MS-PS V2.
It gives a error in Studio 2012 V3.11 when i used with MS-PS V3.
It gives a error with Sudio 2012 V(3.12-3.14) with MS-PS V2 and MS-PS V3.

Best regards.

Attached files /FileUpload/13/d1e23c2865e286d0149a0799e25318.rar (4.9 KB)
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Strange modification of comportment between Studio v3.11 and upper versions With Powshell v 3.0

Post by davidc »

This is caused by PowerShell's scoping rules.

Try using the script scope otherwise the ObjConnectionReader may not be accessable in events:

$script:ObjConnectionReader = Sgbd_OpenConnectionToIdm

David
David
SAPIEN Technologies, Inc.
This topic is 11 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.