Format script issue?

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 1 year and 6 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
Lembasts
Posts: 405
Last visit: Thu Mar 14, 2024 10:47 pm
Has voted: 1 time
Been upvoted: 1 time

Format script issue?

Post by Lembasts »

Product, version and build: PS 207
Operating system: win 10
PowerShell version(s): 5.1

Hi,
I had a piece of code that has been running successfully every day for years that started to fail last week.
The line was:
$etime = "{ 0:g }" -f $elapsedtime
The problem was that there was a space after the opening brace and one before the closing brace.
This bit of code has not been edited for years. The only possible reason I can think of is that I often press 'format script' after making changes.
Might the 'Format Script' logic put spaces in something like the above?
Thanks
David
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: Format script issue?

Post by brittneyr »

Generally, the contents of strings are not formatted.

Having said that, the latest build (5.8.209) did address a bug in the formatter. While I was not able to get the line to add spaces, it could be related.

Please try build 5.8.209 and let me know.
Brittney
SAPIEN Technologies, Inc.
User avatar
Lembasts
Posts: 405
Last visit: Thu Mar 14, 2024 10:47 pm
Has voted: 1 time
Been upvoted: 1 time

Re: Format script issue?

Post by Lembasts »

I installed 209 and did a format script and the "{0:g}" string didnt change.
Thanks
David
User avatar
Lembasts
Posts: 405
Last visit: Thu Mar 14, 2024 10:47 pm
Has voted: 1 time
Been upvoted: 1 time

Re: Format script issue?

Post by Lembasts »

I have another one re: format script.
This line stopped working a little while ago. It has been running for years and has never been modified since first created - except by format script.
(this may have been fixed by 209 but given the two issues I have had I am too scared to run format script any more in case it breaks more stuff)

Code: Select all

	DSACLS.EXE "\\$($global:pstoolObject.ActiveSiteDC)\$GroupDN" /G "$($global:pstoolObject.DomainNetbios)\$($ManagerSAM):WP; member" | out-null
The problem is that a space was insert after the semicolon before the string member which caused the command to fail.
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: Format script issue?

Post by brittneyr »

I'm slightly confused by your statement. Are you running build 209 currently? Are you saying this happened from the previous build?

I'm currently testing with build 209 and have been unable to reproduce this behavior. What are your Formatting settings in options:
SPS_OptionsFormatting.png
SPS_OptionsFormatting.png (30.74 KiB) Viewed 1975 times
Brittney
SAPIEN Technologies, Inc.
User avatar
Lembasts
Posts: 405
Last visit: Thu Mar 14, 2024 10:47 pm
Has voted: 1 time
Been upvoted: 1 time

Re: Format script issue?

Post by Lembasts »

I have the same options except I have automatically indent new lines and align hash table equal signs checked. Parameter line spacing is also set to 0.
I have a habit of pressing 'Format Script' before I save any file.
I can honestly say with hand on heart that the two examples I have given are lines that I have not modified for years. No-one else edits my code.
The only possible explanation I can see is that the format script option changed the code.
Im not exactly sure when the problem occurred but it would have been in the last few months.
So I may have been running 206,207 or 208.
I tend to upgrade a day or two after the new updated has been released.
Thanks
David
User avatar
Lembasts
Posts: 405
Last visit: Thu Mar 14, 2024 10:47 pm
Has voted: 1 time
Been upvoted: 1 time

Re: Format script issue?

Post by Lembasts »

Let's say you do find some 'irregularities' that were introduced into the 'format script' routine.
I would very much appreciate if you could publish the 'pseudo logic' that caused the above problems so that I can check all my code for any other issues.
Thanks
David
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: Format script issue?

Post by brittneyr »

The only verified issue found in the formatter with the current build (5.8.209) was the following:
viewtopic.php?p=83132#p83132

I have not been able to reproduce the behavior described with the information provided. Was the line provided part of a longer script? If so, it could be an earlier line that causes this issue. Can you upload the script here to help us reproduce this?
https://www.sapien.com/support/upload
Brittney
SAPIEN Technologies, Inc.
User avatar
Lembasts
Posts: 405
Last visit: Thu Mar 14, 2024 10:47 pm
Has voted: 1 time
Been upvoted: 1 time

Re: Format script issue?

Post by Lembasts »

I work for a govt department that does not allow this sort of stuff to be sent outside of the organisation.
I do fail to understand how an 'earlier line' could possibly influence the 'format script' routine.
That suggests to me that the format script routine introduces random spaces within quotes based on some earlier code?
Remember that this problem could have been caused by 206, 207 or 208. As it is impossible to say when exactly the problem occurred and when I installed those versions. All I can narrow it down to is some time in the last few months.
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: Format script issue?

Post by brittneyr »

The file is parsed before it is formatted. If a line in a script is parsed incorrectly, then it can cause issues with the remaining script being parsed. This can lead to errors with syntax coloring and code formatting. As I previously stated, strings are not generally formatted and with the information you have provided, I can not reproduce any such behavior as you are describing. There was a bug found in build 208 that was related to formatting hash tables and specifically the option to align the equal signs in hash tables. This issue, as far as I know, was resolved in build 209.

Please provide a script demonstrating the behavior you have described so we can get this fixed for you:
https://www.sapien.com/support/upload
Brittney
SAPIEN Technologies, Inc.
This topic is 1 year and 6 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.