Export to Clipboard causes errors

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 3 years and 2 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
owinsloe
Posts: 161
Last visit: Tue Apr 16, 2024 8:36 pm
Been upvoted: 1 time

Export to Clipboard causes errors

Post by owinsloe »

Product: PowerShell Studio 2021 (64 Bit)
Build: v5.8.183
OS: Windows 10 Pro (64 Bit)
Build: v10.0.19042.0

I have source that I packagae as both UI and commandline and have separate code for support of both. If I export to clipboard and save the content to a ps1 file (clipboard.ps1) then I would expect it to run up as a UI and behave the same as if I had run from PSS. When run from PSS (mainform.psf) , it works without any error. When run from the exported clipboard.ps1 it errors with the below error. I suspect that it is losing (or adding) something at the time of the export

At C:\cardinal\clipboard.ps1:881 char:16
+ Log "Complete"
+ ~
The string is missing the terminator: ".
At C:\cardinal\clipboard.ps1:875 char:41
+ ($Email -split ',') | ForEach-Object {
+ ~
Missing closing '}' in statement block or type definition.
At C:\cardinal\clipboard.ps1:870 char:3
+ {
+ ~
Missing closing '}' in statement block or type definition.
At C:\cardinal\clipboard.ps1:29 char:28
+ function Show-mainform_psf {
+ ~
Missing closing '}' in statement block or type definition.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
Attachments
cnwtelnet.zip
(40.92 KiB) Downloaded 78 times
User avatar
owinsloe
Posts: 161
Last visit: Tue Apr 16, 2024 8:36 pm
Been upvoted: 1 time

Re: Export to Clipboard causes errors

Post by owinsloe »

I also exported to a file and when I run this as a ps1 it works fine so the problem is definitely with export to clipboard. After performing a file compare between the export-to-file & export-to-clipboard, I can see that the Send-MailMessage has had some †inserts that it should not (-from email modified)

Send-MailMessage –From "xxxxx@jxxxxx.com" –To $To –Subject "$Subject" -Body "$Body" -SmtpServer $GLBVAR.smtp -port $GLBVAR.SmtpPort
Send-MailMessage –From "xxxxx@jxxxxx.com" –To $To –Subject "$Subject" -Body "$Body" -SmtpServer $GLBVAR.smtp -port $GLBVAR.SmtpPort
Send-MailMessage –From "xxxxx@jxxxxx.com" –To $To –Subject "$Subject" -Body "$Body" -SmtpServer $GLBVAR.smtp -port $GLBVAR.SmtpPort
User avatar
brittneyr
Site Admin
Posts: 1672
Last visit: Wed Apr 17, 2024 1:24 pm
Answers: 39
Been upvoted: 31 times

Re: Export to Clipboard causes errors

Post by brittneyr »

After some investigating, I noticed that your clipboard script file encoding is UTF-8. After changing this to UTF-8-BOM, clipboard.ps1 ran fine for me. Please try updating this from the status bar with this file open and let me know if it runs:
SPS_StatusBarEncoding.png
SPS_StatusBarEncoding.png (17.76 KiB) Viewed 3196 times
Brittney
SAPIEN Technologies, Inc.
User avatar
brittneyr
Site Admin
Posts: 1672
Last visit: Wed Apr 17, 2024 1:24 pm
Answers: 39
Been upvoted: 31 times

Re: Export to Clipboard causes errors

Post by brittneyr »

I also was able to get the script to run after formatting script (Home->Edit):
SPS_RibbonFormatScript.png
SPS_RibbonFormatScript.png (24.83 KiB) Viewed 3193 times
Brittney
SAPIEN Technologies, Inc.
User avatar
owinsloe
Posts: 161
Last visit: Tue Apr 16, 2024 8:36 pm
Been upvoted: 1 time

Re: Export to Clipboard causes errors

Post by owinsloe »

That's interesting. Changing the encoding did correct this but I have used "copy to clipboard" previously (perhaps not in this version of PSS) and have never had this issue? Thanks tho
This topic is 3 years and 2 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.