Uppercase in to In within for..loop

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 1 month 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
clum09
Posts: 150
Last visit: Sun Jan 21, 2024 5:07 pm

Uppercase in to In within for..loop

Post 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.
Attachments
UpperCaseI.JPG
UpperCaseI.JPG (26.21 KiB) Viewed 5109 times
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Uppercase in to In within for..loop

Post 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.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
clum09
Posts: 150
Last visit: Sun Jan 21, 2024 5:07 pm

Re: Uppercase in to In within for..loop

Post by clum09 »

How can I remove Pester from the module cache? Can you show me how?
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Uppercase in to In within for..loop

Post 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.
David
SAPIEN Technologies, Inc.
User avatar
clum09
Posts: 150
Last visit: Sun Jan 21, 2024 5:07 pm

Re: Uppercase in to In within for..loop

Post 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.
User avatar
mxtrinidad
Posts: 399
Last visit: Tue May 16, 2023 6:52 am

Re: Uppercase in to In within for..loop

Post 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.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Uppercase in to In within for..loop

Post 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.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
clum09
Posts: 150
Last visit: Sun Jan 21, 2024 5:07 pm

Re: Uppercase in to In within for..loop

Post 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.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Uppercase in to In within for..loop

Post 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
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 6 years and 1 month 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.