Share via

SEQ Fields Not Working Within IF Statements

Anonymous
2014-09-27T23:46:06+00:00

I have a document in which I use SEQ fields to number exhibits (alphabetically).  Many of these are embedded within IF statements, the idea being if the condition is not true, the SEQ field does not get "called", and the numbering of subsequent exhibits that do get called remains accurate.

This worked in this document for a long time, but suddenly, it's not.  The Exhibits go from A, to B, then straight to M, then straight to UU.  I believe the intervening letters are "taken" by SEQ fields within IF statements where the condition is not true, but why should this all of the sudden stop working?

Thanks in advance for any help!

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2014-10-17T20:32:26+00:00

I'll do some experiments. If you can provide your document. it might be easier to spot the problem.

Do you see this behaviour through the entire section or just in a single { SET Exhibit { =Exhibit+1 } } field?

One thing you could try for now would be to use

{ SET Exhibit { ={ Exhibit }+1 } }

BTW, are you actually using 

{ SET Exhibit { =Exhibit+1 } }{ Exhibit } ? (slightly different bracketing).

You have probably noticed that when you use this approach, you always have to ensure that your Exhibit value is reset where necessary, e.g. at the beginning of the document, otherwise subseqeunce selet/update operations pick up the last value of Exhibit set and use that as the starting value.

Was this answer helpful?

0 comments No comments

13 additional answers

Sort by: Most helpful
  1. Anonymous
    2014-09-28T23:16:02+00:00

    Thanks -- I'll try this, although it's obviously cumbersome.  I very much appreciate your help.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2014-09-28T17:27:03+00:00

    Here, that sequence of fields always results in 1,2, then 5. Although I remember that the operation of the SEQ field changed at some point (a long time ago), I checked back (to Windows Word 2 :-) ) and it always seems to have worked this way. Maybe someone else can shed light on why things have changed.

    So I do not know what you were doing before that "made it work" so you (presumably) got 1,2,3.

    The only way I know that will avoid this - assuming that there is no better way that avoids SEQ fields - is to store and restore the value of the SEQ each time it is referenced. In effect, like thi:

    { SET M { SEQ a \c } }{ IF 1 = 1 "{ SEQ a }{ SET M { SEQ a \c } } Maybe you have some text" "text with no numbering" }{ SEQ a \r{ M } \h }

    { SET M { SEQ a \c } }{ IF 1 = 1 "{ SEQ a }{ SET M { SEQ a \c } } Maybe you have some text" "text with no numbering" }{ SEQ a \r{ M } \h }

    { SET M { SEQ a \c } }{ IF 0 = 1 "{ SEQ a }{ SET M { SEQ a \c } } Maybe you have some text" "text with no numbering" }{ SEQ a \r{ M } \h }

    { SET M { SEQ a \c } }{ IF 0 = 1 "{ SEQ a }{ SET M { SEQ a \c } } Maybe you have some text" "text with no numbering" }{ SEQ a \r{ M } \h }

    { SET M { SEQ a \c } }{ IF 1 = 1 "{ SEQ a }{ SET M { SEQ a \c } } Maybe you have some text" "text with no numbering" }{ SEQ a \r{ M } \h }

    (As usual,all the {} have to be the field brace pairs you can typically insert using cmd-F9 or fn-cmd-F9 )

    FWIW I have tried various other things in the past that try to manipulate the code of the SEQ field itself, so that in the case 1 = 1 you insert { SEQ a } whereas in the case 0 = 1 you insert { SEQ b \h }, e.g.

    { SEQ { IF 1 = 1 "a" "b \h" } }

    Unfortunately, it just does not seem to be possible to insert this type of switch code using a nested field (whereas it is possible to build up codes such as \Charformat using { SET S "Charformat" }{ REF X \{ S } } )

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2014-09-28T14:08:40+00:00

    Thanks for your reply, Peter.  My code is really quite simple, like this:

    {IF 1 = 1 "{SEQ a}" "text with no numbering"} -- result is 1

    {IF 1 = 1 "{SEQ a}" "text with no numbering"} -- result is 2

    {IF 0 = 1 "{SEQ a}" "text with no numbering"}

    {IF 0 = 1 "{SEQ a}" "text with no numbering"}

    {IF 1 = 1 "{SEQ a}" "text with no numbering"} -- result is 5

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2014-09-28T10:01:15+00:00

    I do not know what has changed, if anything.

    SEQ fields nested within IF fields have always been a bit tricky. For example, if you have

    { IF 1 = 1 { SEQ a } { SEQ a } }

    { IF 1 = 1 { SEQ a } { SEQ a } }

    { IF 1 = 1 { SEQ a } { SEQ a } }

    then the result in modern versions of Word would typically be 

    1

    3

    5

    In other words, either both branches of the IF are executed in that case, or something else causes the SEQ to increment twice.

    Can you either post the field code here for some sample IF fields, or post anonymised sample documents that show the current behaviour (and if possible, the expected behaviour) somewhere we can reach them.

    Was this answer helpful?

    0 comments No comments