Uppercase in to In within for..loop

Support for all customers who have purchased a PrimalScript product license. This forum does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE 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.
User avatar
clum09
Posts: 146
Joined: Thu Apr 24, 2008 9:11 am

Uppercase in to In within for..loop

Post by clum09 » Wed Feb 07, 2018 12:10 pm

Product, version and build: 7.4.110_020518
32 or 64 bit version of product: 64-bit
Operating system: Windows 10 Enterprise
32 or 64 bit OS: 64-bit

Hello, I posted a message a while back to request for a fix to the Upper casing of the in to In within the for...loop in PrimalScript Script editor.
The last response I got back from the support technician was it would be fixed in the next build release. I just installed the latest version of PrimalScript on my computer and test the keyword in within for...loop, and the in will become In as soon as I move the cursor away from the n character after the i character.

I simply launched a blank page PrimalScript editor screen I try to type foreach ($obj in $test) { $obj }, and the in within the for loop is upper cased to In.
I have attached screen shot with this post. Please fix this annoying casing issue so that it will stop doing that.

Somehow PrimalScript still senses the in keyword as a parameter input See the attached screen shot.
Attachments
UpperCaseI.JPG
UpperCaseI.JPG (26.21 KiB) Viewed 1311 times

User avatar
Alexander Riedel
Posts: 6710
Joined: Tue May 29, 2007 4:43 pm

Re: Uppercase in to In within for..loop

Post by Alexander Riedel » Wed Feb 07, 2018 1:04 pm

PrimalScript recognizes the 'In' keyword as a function because it is defined as such in Pester

[Command]
Function|In|

A convenience function that executes a script from a specified path.
[Syntax]
__AllParameterSets|In [[-path] <Object>] [[-execute] <scriptblock>]
[Parameters]
path|System.Object|
execute|System.Management.Automation.ScriptBlock|

Removing Pester from your module cache via the Cache Editor will resolve the problem.
Unfortunately we cannot force anyone to NOT use PowerShell keywords as functions names, which you should never do.

We'll investigate if we can block functions that use keywords altogether.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
clum09
Posts: 146
Joined: Thu Apr 24, 2008 9:11 am

Re: Uppercase in to In within for..loop

Post by clum09 » Wed Feb 07, 2018 3:35 pm

How can I remove Pester from the module cache? Can you show me how?

User avatar
davidc
Posts: 5543
Joined: Thu Aug 18, 2011 4:56 am

Re: Uppercase in to In within for..loop

Post by davidc » Wed Feb 07, 2018 3:56 pm

This video will show you how to add and remove modules using the Cache Editor:

https://www.sapien.com/blog/2018/01/02/ ... he-editor/

The video shows PowerShell Studio but also applies to PrimalScript.
David
SAPIEN Technologies, Inc.

User avatar
clum09
Posts: 146
Joined: Thu Apr 24, 2008 9:11 am

Re: Uppercase in to In within for..loop

Post by clum09 » Thu Feb 08, 2018 9:53 am

I removed Pester from the module cache and rebuilt the cache, but it does not have any effect on the upper casing problem. The "in" will become "In" as I move the cursor away from the n character in the for..loop.

User avatar
mxtrinidad
Site Admin
Posts: 232
Joined: Sun Mar 03, 2013 12:42 pm

Re: Uppercase in to In within for..loop

Post by mxtrinidad » Thu Feb 08, 2018 10:25 am

Remember, remove Pester from both 64 and 32 cache: "PowerShell64v5" and "Powershell32v5", then execute the "Build Cache" . Finally, restart PrimalScript.

The behavior should be corrected.

User avatar
Alexander Riedel
Posts: 6710
Joined: Tue May 29, 2007 4:43 pm

Re: Uppercase in to In within for..loop

Post by Alexander Riedel » Thu Feb 08, 2018 11:52 am

The next service build will specifically prevent PrimalSense and case correction on *ALL* PowerShell reserved words as listed here: https://docs.microsoft.com/en-us/powers ... wershell-6

I am quite certain some folks will complain, but our position is that you should never use reserved words as identifiers in your code. Any other programming language would indeed flag something like that as a syntax error.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
clum09
Posts: 146
Joined: Thu Apr 24, 2008 9:11 am

Re: Uppercase in to In within for..loop

Post by clum09 » Fri Feb 09, 2018 6:41 am

I removed Pester for both 64-bit and 32-bit from the Cache Editor, rebuilt cache and restarted PrimalScript, but it is still no effect on the casing - the "in" within the for..loop will become "In" after the cursor is moved away from the n character after the i character.

PrimalScript editor decides to sense "in" as a real function or a parameter of a cmdlet within the script, and it mistakenly autocompletes "in" as "In" within the script.

User avatar
Alexander Riedel
Posts: 6710
Joined: Tue May 29, 2007 4:43 pm

Re: Uppercase in to In within for..loop

Post by Alexander Riedel » Fri Feb 09, 2018 6:54 am

If you uncheck Pester within the Cache Editor and click "Build Cache" in the Cache Editor the cache will be saved with the selected modules, in your case without Pester.
If you then refresh the cache you are undoing your change and rebuilding it with what is on your system.
So using the Cache Editor has the desired effect, you are just undoing it by then again rebuilding the cache.

Cache Editor = Include and Exclude the modules precisely as you want
Rebuild cache = Include all modules found on your system in the cache
Alexander Riedel
SAPIEN Technologies, Inc.