Results 1 to 8 of 8

Thread: Field Code

  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts
    I'm having difficulty with a field code which I want to refer to previous numbers in a SEQ list.

    Each Point is numbered with ordinal text: First, Second, etc. Starting with the Second Point, there will be a reference to previous points.

    Second Point will make reference to the "First Point".

    Third Point will reference the "First and Second Points".

    Fourth Point will reference the "First through Third Points".

    And so on... the reference being First through one less than the current point.

    If x = the current point number, I need the following:

    if x = 2 then result = "First Point"
    elseif x 3 then result = "First and Second Points"
    else result = "First through x - 1 Points"

    I know I probably need to use Quote and Set as well as an If construct; I'm not sure how these should be nested.

    Any help will be appreciated.

    Richard

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='richardbarrett' post='775433' date='16-May-2009 12:18']I'm having difficulty with a field code which I want to refer to previous numbers in a SEQ list.

    Each Point is numbered with ordinal text: First, Second, etc. Starting with the Second Point, there will be a reference to previous points.

    Second Point will make reference to the "First Point".
    Third Point will reference the "First and Second Points".
    Fourth Point will reference the "First through Third Points".
    And so on... the reference being First through one less than the current point.
    ...
    I know I probably need to use Quote and Set as well as an If construct; I'm not sure how these should be nested.
    Any help will be appreciated.

    Richard[/quote]
    Hi Richard,

    Try a field coded along the lines of:
    {QUOTE{SET Val {SEQ Num}}"First"{=Val-2 \# " through ;; and "}{IF{Val}> 1 {Val \* OrdText \* FirstCap}}{=Val-2 \# " Points; Point"}}

    Pay careful attention to the character spacing.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts
    [quote name='macropod' post='775463' date='16-May-2009 08:09']Hi Richard,

    Try a field coded along the lines of:
    {QUOTE{SET Val {SEQ Num}}"First"{=Val-2 \# " through ;; and "}{IF{Val}> 1 {Val \* OrdText \* FirstCap}}{=Val-2 \# " Points; Point"}}

    Pay careful attention to the character spacing.[/quote]

    Hi Paul,

    Thank you. This has moved me along further than I got on my own. I still am having a bit of trouble. Would you have a look at my document and see if you can spot where I am going wrong? Apparently the complex field code is causing the SEQ counter in the Point headings to increment. As you can see, the point headings are First, Third, Fifth, etc. Similarly, the complex field codes increment incorrectly. I see what the issue is, but I don't know how to correct it.

    The condition for "and" and "through" works well, as does "Point" / "Points". Because of the problem with incrementing, "First Point" is not the result for the complex code under Second Point.

    Thanks for your help.

    By the way, I forgot I had a tip to pass along to you. You mentioned in a post a while back that you were using VBA code to write XML for dynamic menus for the 07 Ribbon. I have found that to be a real pain, not least because it's impossible to valide the XML code. I write the RibbonX code in the Custom UI Editor, which allows me to validate it. I then copy the snippet of XML to a text file. A VBA function reads the text file and builds the XML string. I frequently use a dynamic menu composed of items that are specific to the attached template of the active document. NYPleading.dotm has a corresponding NYPleading.txt, easily realized with the Replace function. I begin my XML string with the standard XML code, and concatenate menu items by reading the text files. In addition to the template-specific items, I might add menu items that are shared by a group of templates or that depend on conditions in the document (e.g. Switch Letter to A4, Switch A4 to Letter). Rather than have separate text files, I've also put all of the ribbon XML snippets in one single text file, which I parse based on comments. I find this helpful for myself, and it's particularly helpful when a client wants to be able to maintain templates but doesn't have the ability or patience to fuss with XML code written via VBA.

    Thanks again.
    Richard
    Attached Files Attached Files

  4. #4
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts
    [quote name='macropod' post='775463' date='16-May-2009 08:09']Hi Richard,

    Try a field coded along the lines of:
    {QUOTE{SET Val {SEQ Num}}"First"{=Val-2 \# " through ;; and "}{IF{Val}> 1 {Val \* OrdText \* FirstCap}}{=Val-2 \# " Points; Point"}}

    Pay careful attention to the character spacing.[/quote]

    Hi Paul,

    With a bit of persistence, I've done much better. I'm quite close to what I want, as you can see in the attached document.

    Apparently the value of Val is +1 what it should be. I've used: (SET Val (SEQ Num /c} in order not to increment the SEQ value. But what I really need is that value minus 1. Under the Second Point, Val = 2, and I want it = 1, in order to give the result "First Point".

    Can you help? I just don't know where the "-1" should be placed; I either get a bookmark error, or I see no effect at all.

    Thanks very much.
    Attached Files Attached Files

  5. #5
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='richardbarrett' post='775483' date='17-May-2009 02:20']Hi Paul,

    With a bit of persistence, I've done much better. I'm quite close to what I want, as you can see in the attached document.

    Apparently the value of Val is +1 what it should be. I've used: (SET Val (SEQ Num /c} in order not to increment the SEQ value. But what I really need is that value minus 1. Under the Second Point, Val = 2, and I want it = 1, in order to give the result "First Point".

    Can you help? I just don't know where the "-1" should be placed; I either get a bookmark error, or I see no effect at all.

    Thanks very much.[/quote]
    Hi Richard,

    Having looked at your document, I think the code you need is:
    {IF{SEQ Point \c}> 1 {={SEQ Point \c}-3 \# "First through '{={SEQ Point \c}-1 \* OrdText \* FirstCap}' Points;First Point;First and Second Points"}}

    See attached.
    Attached Files Attached Files
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  6. #6
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts
    [quote name='macropod' post='775544' date='17-May-2009 01:48']Hi Richard,

    Having looked at your document, I think the code you need is:
    {IF{SEQ Point \c}> 1 {={SEQ Point \c}-3 \# "First through '{={SEQ Point \c}-1 \* OrdText \* FirstCap}' Points;First Point;First and Second Points"}}

    See attached.[/quote]

    Thanks very much, Paul.

    There seems to be a restriction on the number of characters that can follow the 2nd semicolon. "First and Second Points" was always shortened to "First and Second Point". If I changed the text, there was always a maximum of 22 characters. For example "The First and the Second Points" was truncated to "The First and the Seco". No matter... I pulled the word Points out of this field and added a second field for Point or Points.

    Is there, in fact, a limitation on the number of characters? It seems to hold only for text in the 3rd position; if I changed "First Point" to "The First and Only Point", the text was not truncated.

    Can you explain how this field -- with the possible results separated by semicolons -- differs from the typical If x, y, z ?

    Thanks again for your good help.
    Richard

  7. #7
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='richardbarrett' post='775572' date='18-May-2009 00:51']Thanks very much, Paul.

    There seems to be a restriction on the number of characters that can follow the 2nd semicolon. "First and Second Points" was always shortened to "First and Second Point". If I changed the text, there was always a maximum of 22 characters. For example "The First and the Second Points" was truncated to "The First and the Seco". No matter... I pulled the word Points out of this field and added a second field for Point or Points.

    Is there, in fact, a limitation on the number of characters? It seems to hold only for text in the 3rd position; if I changed "First Point" to "The First and Only Point", the text was not truncated.

    Can you explain how this field -- with the possible results separated by semicolons -- differs from the typical If x, y, z ?

    Thanks again for your good help.
    Richard[/quote]
    Hi Richard,

    OK, here's a slight change to the field coding:
    {IF{SEQ Point \c}> 1 "First {={SEQ Point \c}-3 \# "through '{={SEQ Point \c}-1 \* OrdText \* Caps}' Points;Point;and Second Points"}"

    If you're getting truncation with the 'Second Points' part of the expression, that's because you're not using the field coding quite as I gave it to you. With numeric picture switches (which is what I'm using), there's a limit of 63 characters in the switch - the embedded field counts as 1 character. This you can get even more 'free' text into the field with:
    {IF{SEQ Point \c}> 1 "First {={SEQ Point \c}-3 \# "through '{={SEQ Point \c}-1 \* OrdText \* Caps}' Points;and Only Point;and '{={SEQ Point \c}-1 \* OrdText \* Caps}' Points"}"}

    The IF test is only used to suppress the output if there's only one 'point' and works along the lines of 'IF X = True, Y, else nul.

    The display for 'point' values greater than one is controlled entirely by a numeric picture switch. These have three states, each separated by a semi colon: +ve;-ve;0. Those states control how the corresponding values are displayed, and can have text as well as (or instead of) numbers.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  8. #8
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts
    [quote name='macropod' post='775629' date='17-May-2009 18:39']Hi Richard,

    OK, here's a slight change to the field coding:
    {IF{SEQ Point \c}> 1 "First {={SEQ Point \c}-3 \# "through '{={SEQ Point \c}-1 \* OrdText \* Caps}' Points;Point;and Second Points"}"

    If you're getting truncation with the 'Second Points' part of the expression, that's because you're not using the field coding quite as I gave it to you. With numeric picture switches (which is what I'm using), there's a limit of 63 characters in the switch - the embedded field counts as 1 character. This you can get even more 'free' text into the field with:
    {IF{SEQ Point \c}> 1 "First {={SEQ Point \c}-3 \# "through '{={SEQ Point \c}-1 \* OrdText \* Caps}' Points;and Only Point;and '{={SEQ Point \c}-1 \* OrdText \* Caps}' Points"}"}

    The IF test is only used to suppress the output if there's only one 'point' and works along the lines of 'IF X = True, Y, else nul.

    The display for 'point' values greater than one is controlled entirely by a numeric picture switch. These have three states, each separated by a semi colon: +ve;-ve;0. Those states control how the corresponding values are displayed, and can have text as well as (or instead of) numbers.[/quote]

    Thank, Paul. This does exactly what I require. I'm beginning to understand this a bit better. I rarely have need for codes like this; I should spend a bit of time becoming more fluent with them. Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •