Format Script Breaks Code

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 10 months and 3 days 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
gareth.jacobs
Posts: 34
Last visit: Wed Jan 24, 2024 7:43 pm

Format Script Breaks Code

Post by gareth.jacobs »

Product: PowerShell Studio 2023 (64 Bit)
Build: v5.8.221
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.19045.0

The following code block will generate a syntax error if 'format script' is used.
The 'elseif...' line gets pulled up 1 line and becomes a comment, breaking the code.
  1. if($a -eq 1)
  2. {
  3.     $y = 0
  4. }
  5. # this comment will cause a syntax error if 'format script' is used
  6. elseif ($a -eq 2)
  7. {
  8.     $y = 1
  9. }
Here is the resulting code after 'format script'
  1. if ($a -eq 1) {
  2.     $y = 0
  3. }
  4. # this comment will cause a syntax error if 'format script' is used elseif ($a -eq 2) {
  5. $y = 1
  6. }
The generated error is: At line:6 char:1 Unexpected token '}' in expression or statement.

The original error occurred in the middle of a 1,600 line script and was difficult to diagnose and is not the code listed above, but errors just the same.

Editor Settings:
EditorFormatSettings.jpg
EditorFormatSettings.jpg (72.28 KiB) Viewed 1812 times
User avatar
Olga_B
Site Admin
Posts: 196
Last visit: Thu Mar 28, 2024 8:34 am

Re: Format Script Breaks Code

Post by Olga_B »

Thanks for reporting the issue. We have been able to reproduce this and have filed a bug report with the development team.
When a fix is issued with a service build, it will be listed in the change log.
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 1:00 pm
Answers: 39
Been upvoted: 30 times

Re: Format Script Breaks Code

Post by brittneyr »

Please try service build 5.8.222 and let me know if you are still experiencing this issue.
Brittney
SAPIEN Technologies, Inc.
This topic is 10 months and 3 days 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.