Code does not work correctly with PrimalScript

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 17 years and 4 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
JasonWMcB
Posts: 8
Last visit: Thu Mar 14, 2024 9:54 am

Code does not work correctly with PrimalScript

Post by JasonWMcB »

When I run the following vbs code from the 'Run Code' button within primal script I do not get a dialog box. The PrimalScript window loses application focus as if the window has opened, but the window is not there. If I run the code with the 'Debug Script', it does work correctly. I have also tested the code with WScript and CScript outside of PrimalScript and both run fine.



Const WINDOW_HANDLE = 0Const OPTIONS = 0Const MY_COMPUTER = &H11&
Set objShell = CreateObject("Shell.Application")Set objFolder = objShell.BrowseForFolder(WINDOW_HANDLE, "Select a folder:", OPTIONS, MY_COMPUTER)
If objFolder Is Nothing Then Wscript.QuitEnd If
Set objFolderItem = objFolder.SelfobjPath = objFolderItem.Path
Wscript.Echo objPath
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Code does not work correctly with PrimalScript

Post by Alexander Riedel »

You probably have VBScript set to run with CScript and capture output.
Click on the downbutton right next to the "Run Script" toolbar button on the Script toolbar and select
"Run Script and do not capture output"

or, alternatively, set you general VBScript settings accordingly.

Alex
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
JasonWMcB
Posts: 8
Last visit: Thu Mar 14, 2024 9:54 am

Code does not work correctly with PrimalScript

Post by JasonWMcB »

Thanks. That works. Can you give any more explanation on this? Where else may this scenario be the answer?
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Code does not work correctly with PrimalScript

Post by Alexander Riedel »

When you set "Capture output" the script is run by a hidden instance of WScript or CScript as configured.
If you use UI elements in your script the Windows Script Host does not make the Window visible and it will just hang.

So if you primarily use things like that you should change your overall settings.

Alex
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 17 years and 4 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.