Using Pause Script Demo with X9

Moderator: Kathy_9

Post Reply
KevinKing
Posts: 5
Joined: Thu Nov 24, 2016 12:46 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Dell Inc. 0GDG8Y A00
processor: 3.00 gigahertz Intel Core i5-2320
ram: 8GB
Video Card: NVIDIA GeForce GT 530
sound_card: NVIDIA High Definition Audio 4x
Hard_Drive_Capacity: 484.16 GB
Monitor/Display Make & Model: Samsung SyncMaster 21.7"vis
Corel programs: PaintShop Pro version 19.1

Using Pause Script Demo with X9

Post by KevinKing »

I am having trouble using Gary Barton's 'Pause Script Demo' with a new installation of X9.

Whenever I attempt to run it, whether using a new blank vector graphic or one previously created with a single existing piece of text, step 1 executes OK. I am asked for the text, then select the text tool and set font, size, etc.: but step 2 then fails. I get the following output:

Code: Select all

Executing RunScript
Executing ImageInfo

Script 'Pause Script Demo' has completed successfully.

Executing RunScript
Traceback (most recent call last):
  File "<string>", line 85, in Do
  File "<string>", line 149, in DoNextStep
  File "<string>", line 1, in <module>
  File "<string>", line 45, in DoStep2
TypeError: 'NoneType' object has no attribute '__getitem__'

Script 'Pause Script Demo' has completed with an error.
Failure occurs in this block of code:

Code: Select all

44    info = GetToolInfo(Environment, 'Text')
45    segment = info['Segments'][0]
Further investigation (by including print statements in the GetToolInfo routine) reveal the following:
info['Library'] is set to: ToolText
info['LocalName'] is set to: Text
return value is set to: {'Matrix': None, 'Segments': None, 'SavedText': None, 'FinalApply': False, 'CreateAs': 0, 'GeneralSettings': {'AutoActionMode': 0, 'PreviewVisible': True, 'ScreenControl': 1, 'ExecutionMode': 0, 'Version': ((19, 0, 0), 1), 'PreviewMode': 1, 'AutoProof': False}, 'RememberText': False}

So it appears that the failure is due to 'Segments' being defaulted to None; though I've yet to find out what 'Segments' actually are. But, looking at the full list of return values from the call to GetCommandInfo (too long to reproduce here), I notice that the value of the 'Deprecated Command' attribute is set to 1. Does this mean that this is a deprecated command? If not, what can I do to prevent calls to GetToolInfo from bombing out?
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: Using Pause Script Demo with X9

Post by LeviFiction »

Gary's Pause Script was written for a much older version of PSP. Some things have changed since its original creation. Luckily you only have to change one line of code. Set segment = to an empty dictionary.

Explanation:

Segments are literally segments of text. You can have multiple font sizes, colors, and fonts in a single text object in PSP. Each segment is a set of letters with a specific font setting. Now, I don't know why this would have worked in an older version as it only gets the last used settings not any actual text. But maybe there is something about older versions that I'm unaware of. It definitely won't return any actual segments in x9.

Now at one point PSP moved from Text to TextEx. They both still work, but there are some differences between them. For example "Segments" from "Text" is "Strings" in "TextEx" Also Strings returns None so again in X9 this won't work. Also The GetCommandInfo command won't work with TextEx because of a quirk in the information returned by GetCommandInfo.

The solution to this is to not use an existing segment, but to create a blank one.

Luckily this is easy. Just set segment equal to an empty dictionary.

Replace line 45

Code: Select all

segment = info['Segments'][0]
with

Code: Select all

segment = {}
Also, because it's trying to center the text you might consider adding the key 'SetText" to the dictionary with a value of 2 for "center"

Code: Select all

segment = {}
segment['SetText'] = 2
https://levifiction.wordpress.com/
KevinKing
Posts: 5
Joined: Thu Nov 24, 2016 12:46 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Dell Inc. 0GDG8Y A00
processor: 3.00 gigahertz Intel Core i5-2320
ram: 8GB
Video Card: NVIDIA GeForce GT 530
sound_card: NVIDIA High Definition Audio 4x
Hard_Drive_Capacity: 484.16 GB
Monitor/Display Make & Model: Samsung SyncMaster 21.7"vis
Corel programs: PaintShop Pro version 19.1

Re: Using Pause Script Demo with X9

Post by KevinKing »

Thanks for the advice and useful information.

Unfortunately, when I tried this out on an existing picture with a single transparent vector layer and one simple text object, for which I had defined font, size and colour, the script ran OK, except that instead of displaying the new text in the font I had just specified, it printed the new text using the same settings as the original text object.

I then tried it on a brand new image with a single transparent vector layer and nothing else. The effect was even more bizarre... I selected the text tool, and clicked the 'Font' dropdown list on the tool bar. But as soon as I moved the mouse over the list it began to flicker incessantly between 'Arial' and 'Arial Black' and the program hung. Every time now, whenever I start up PSP X9, and regardless of what script I have selected in the toolbar, if I create a new vector image, select the text tool, click the 'Font' dropdown and move the mouse over the list, the same happens. But if I instead create a new vector image, select the text tool, and then click anywhere in the image area, the last text I entered (even if in a previous session) is entered, and I can then click the 'Font' dropdown and change the font without it hanging.

I never saw it behave like this before I tried these changes. The irony is, I was just trying to get the hang of using the Pause Script before writing my own scripts, and you had indicated that my problem was specific to the text feature, which I don't actually need at present. But as you had been so kind as to make these suggestions I thought I had better confirm that the changes worked before reporting back.

Any suggestions as to how I can get my system working normally again? :oops:
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: Using Pause Script Demo with X9

Post by LeviFiction »

Yeah, it's actually a known issue that transparent images/layers mess with scripting and adding text. Though I have no idea why.

Try resetting your workspace. Close PSP. When opening it again Hold the SHIFT key. It'll ask if you want to reset the program to factory defaults. Say yes.
https://levifiction.wordpress.com/
KevinKing
Posts: 5
Joined: Thu Nov 24, 2016 12:46 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Dell Inc. 0GDG8Y A00
processor: 3.00 gigahertz Intel Core i5-2320
ram: 8GB
Video Card: NVIDIA GeForce GT 530
sound_card: NVIDIA High Definition Audio 4x
Hard_Drive_Capacity: 484.16 GB
Monitor/Display Make & Model: Samsung SyncMaster 21.7"vis
Corel programs: PaintShop Pro version 19.1

Re: Using Pause Script Demo with X9

Post by KevinKing »

Even after resetting the workspace, the problem persists. And even immediately after shutting down and resetting, if I open a new vector drawing (which does not allow me the option of specifying a non-transparent background) and click the Text tool before attempting to set the font, it immediately inserts the last text I inserted before doing the shutdown and reset, complete with my old font, size and colour options!

Will I have to reinstall? :cry:
KevinKing
Posts: 5
Joined: Thu Nov 24, 2016 12:46 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Dell Inc. 0GDG8Y A00
processor: 3.00 gigahertz Intel Core i5-2320
ram: 8GB
Video Card: NVIDIA GeForce GT 530
sound_card: NVIDIA High Definition Audio 4x
Hard_Drive_Capacity: 484.16 GB
Monitor/Display Make & Model: Samsung SyncMaster 21.7"vis
Corel programs: PaintShop Pro version 19.1

Re: Using Pause Script Demo with X9

Post by KevinKing »

Alas, it was the only way! Even after resetting to factory defaults AND resetting the database the problem still persisted. So I did a full de-install, ran the x9 cleanup utility (http://forum.corel.com/EN/download/file.php?id=8815), rebooted and reinstalled. It's now working normally again: but I don't think I'll run the Pause Script Demo or experiment with scripts involving the text tool and transparent images again in a hurry. :roll:

However, I did learn enough from the experience to adapt the demo to create Pause Scripts for my own purposes: so thanks very much for your help! :)
KevinKing
Posts: 5
Joined: Thu Nov 24, 2016 12:46 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Dell Inc. 0GDG8Y A00
processor: 3.00 gigahertz Intel Core i5-2320
ram: 8GB
Video Card: NVIDIA GeForce GT 530
sound_card: NVIDIA High Definition Audio 4x
Hard_Drive_Capacity: 484.16 GB
Monitor/Display Make & Model: Samsung SyncMaster 21.7"vis
Corel programs: PaintShop Pro version 19.1

Re: Using Pause Script Demo with X9

Post by KevinKing »

One other point that may be of use to anyone else investigating this issue. When I was examining the GetToolInfo procedure, I tried issuing a 'print info' command just before the return. The result was an output line of such incredible length that after more than half a minute scrolling through it I got bored and skipped to the end - only to find that it had been truncated. Much of the string appeared to be a succession of groups of zero values. Either there are meant to be a vast number of empty elements, or else something had got into a loop, causing a buffer overflow. If something like this had been saved somewhere (maybe in the registry?) that may well explain the system hang when attempting to access it.
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: Using Pause Script Demo with X9

Post by LeviFiction »

Those values are the parameter description. You have the name, the actual description of the parameter, and then a bunch of extra values.

Parameter Type
Default Integer
Default Minimum
Default Maximum
Default Red
Default Green
Default Blue
Default X
Default Y
Default Real
Minimum Real
Maximum Real
Default Left
Default Top
Default Bottom
Default Right
Is None
Is Script
Uses None
Is Optional

For every parameter the command can take. And Text can take quite a few parameters. As for it cutting off, the Script Output Window has a maximum line length and will auto-wrap the result to the next line if it gets that far. Are you sure it isn't just put on two lines instead of being cut off?

As for whether or not you'll have to reinstall. I honestly don't know. What you're describing is a lot weirder than I'm used to from the text issues in PSPx9.
https://levifiction.wordpress.com/
Post Reply