Donations Welcome

I am currently saving toward a new version of Paint Shop Pro. If you wish to help me out, then please donate.

Larger versions of images can be seen by clicking on the image. Also, thank you for your kind and encouraging comments. I love reading the comments. If you use my any of freebies, I would be overjoyed with a comment containing a link to your item. I love seeing any of my freebies in use.

Saturday, September 5, 2009

Customizing Text in a Script


I've had this tutorial sitting on the back burner for over a month. I meant to write it up in July and then I got sick and busy with work. So, here it is before I forget again. In PSP 8, it was possible to customize text in a script because the text box would pop up. This changed in future versions of PSP. It is no longer possible to make the text box interactive. Even if the text box is set to interactive, it will not show up when the script is run. In order to allow a user to choose their own text, you need to add the following snippet of code before the command to write the text:
    Result = App.Do( Environment, 'GetString', {
        'DefaultText': 'Name',
        'DialogTitle': 'Name for Tag',
        'Prompt': 'Enter Name',
        'MaxLength': 25,
        'GeneralSettings': {
            'ExecutionMode': App.Constants.ExecutionMode.Interactive
            }
        })

    MyText = Result['EnteredText']
Customize the command by replacing all the text in bold italics with your own text. Next, you need to replace your original text with MyText. Your original Text command will have a line that looks like this:
            'Characters': u'Original Text',   
You need to replace everything with MyText. Your end result will look similar to the code snippet below.


As an example, I have included a nametag script which allows you to customize the name on the tag so that you can see how it is done. The script makes a tagger-size tag.


9 comments:

  1. Thank you so much for this Freebie. I want to let you know that I posted a link to your blog in Creative Busy Hands Scrapbook Freebies Search List, under the Page 3 post on Sep. 06, 2009. Thanks again.

    ReplyDelete
  2. Thank you so much. We have a link to this in our forum... CU Freebies Only Forum! Thanks again!

    LadyShannon
    CU Freebies Only Forum Admin

    ReplyDelete
  3. I tried running this script and it come back with error right after I put in my name.

    ReplyDelete
  4. That's entirely possible as I did not have this script tested by my script testers. If you want me to debug your error, please provide the error message.

    ReplyDelete
  5. this is the error i get when i run this script...
    Executing RunScript
    Executing EnableOptimizedScriptUndo
    Executing FileNew
    Executing SelectDocument
    Executing Fill
    Executing Text
    ------- Command Execution Failed -----------
    Command Name: Text
    Error Text: The requested object (document layer, or vector object) could not be found
    Traceback (most recent call last):
    File "C:\Users\Glenda\Documents\My PSP Files\Scripts-Restricted\HGG scripts\HGG_nametag.PspScript", line 2529, in Do
    App.Do( Environment, 'TextEx', {
    JascApp.ObjectNotFound: Object not found

    Script 'HGG_nametag' has completed with an error.

    ReplyDelete
  6. What version of Paint Shop Pro are you using?

    ReplyDelete
  7. PSP 9 is the version i'm using. I use your other scripts you offer and they work fine.

    ReplyDelete
  8. Your program is not automatically creating a vector layer upon the attempted creation of vector text. You can insert a New Vector Layer step before your text and that should fix the problem, but PSP9.01 automatically creates the vector layer. If you are using 9.0 instead of 9.01 then you should apply the patch. If you are using 9.01 you can attempt to reset your preferences to default. If your PSP still does not automatically create a vector layer when you write vector text on a raster layer, then you can consider re-installing the program. Or, you love your program as it is, then you can insert the Vector Layer creation step.

    ReplyDelete
  9. Thank you for your help. I do have psp 9.0. I tried inserting vector layer and didn't help so have to get the patch.

    ReplyDelete