Page 1 of 1

Uppercase in to In within for..loop

Posted: Wed Feb 07, 2018 12:10 pm
by clum09
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.

Re: Uppercase in to In within for..loop

Posted: Wed Feb 07, 2018 1:04 pm
by Alexander Riedel
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.

Re: Uppercase in to In within for..loop

Posted: Wed Feb 07, 2018 3:35 pm
by clum09
How can I remove Pester from the module cache? Can you show me how?

Re: Uppercase in to In within for..loop

Posted: Wed Feb 07, 2018 3:56 pm
by davidc
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.

Re: Uppercase in to In within for..loop

Posted: Thu Feb 08, 2018 9:53 am
by clum09
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.

Re: Uppercase in to In within for..loop

Posted: Thu Feb 08, 2018 10:25 am
by mxtrinidad
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.

Re: Uppercase in to In within for..loop

Posted: Thu Feb 08, 2018 11:52 am
by Alexander Riedel
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.

Re: Uppercase in to In within for..loop

Posted: Fri Feb 09, 2018 6:41 am
by clum09
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.

Re: Uppercase in to In within for..loop

Posted: Fri Feb 09, 2018 6:54 am
by Alexander Riedel
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