Using smart templates to insert parameterized blocks

Using smart templates to insert parameterized blocks

4

    Mar 02, 2012#1

    I've started using UE for all of my Oracle development tasks. One thing that MS Sql offered was a "parameter" replace feature when creating new objects. The way that it worked was to search a script and find specially formatted text and ask you what the replacement term should be. I've included a sample of what I'm trying to describe below. In any case, it would find the distinct set of parms (in this example, <<Name>>, <<Description>> and <<Date>>) and it would ask you what the replacement value should be. You'll notice that <<Name>> appears twice, but it would only ask for the replacement value once, and then it would go about replacing all of the placeholder values with the newly captured values.

    CREATE OR REPLACE VIEW <<Name>>
    /* ************************************
    ** Name: <<Name>>
    ** Desc: <<Description>>
    ** Date: <<Date>>
    ** *********************************** */
    ...Script goes here...

    Assuming <<Name>> = Foo and <<Description>> = Bar and <<Date>> is today's date, the output would get turned into:
    CREATE OR REPLACE VIEW Foo
    /* ************************************
    ** Name: Foo
    ** Desc: Bar
    ** Date: 2012/01/01
    ** *********************************** */
    ...Script goes here...

    Any ideas how to accomplish this in UE?

    2362
    MasterMaster
    2362

      Mar 03, 2012#2

      If you are inserting the same format of text every time, and only the name, description, and date changes, then this is quite easily done with UE 18.

      Set up a Smart Template. When typing out the content of the template, use the following to replace what you had:

      Code: Select all

      CREATE OR REPLACE VIEW [+Name+]
      /* ************************************
      ** Name: [+Name+]
      ** Desc: [+Description+]
      ** Date: [DATE_USER]yyyy/d/M[DATE_USER_END]
      ** *********************************** */
      ^
      Now when you insert the template into your file, it will prompt you once for name and once for description. It will replace name and description everywhere you used it in that template. The date will be automatically filled in. For more on date in Templates, see the "Display/Modify Templates Command" in the UE 18 Help file that comes with UE. The "^" simply indicates the position of the cursor after you insert the template.

      In UE 18, there is no limit to how many templates that you can create.

      If this is an existing document that you need to work with, then a simple search and replace will suffice, but I don't think that's what you were asking exactly. If you aren't using UE 18 yet, I'd recommend you pick it up, as it does exactly what you are needing to do. If you recently purchased UE (in the last 12 months), then you should qualify for a free upgrade to it.

      If your documents are created using a different program that "generates" them with specific tags that need replacing, then a script can be written that would do a regex search for the pattern, then prompt for the replacement text, replace all of that exact term, then repeat until no further searches return a match. That's the great thing about UE, you can extend it to do nearly everything you would need to do for a text file.

      4

        Mar 03, 2012#3

        That seems to be exactly what I was looking for. Thanks!