Bookmark and REF

  • Thread starter ODog Trying NewTricks
  • Start date
O

ODog Trying NewTricks

I inserted an ask statement with a switch to default to blank if no answer is
given, then I used the REF and again used a switch to default to blank if no
source is found. I thought this would work, but it doesn't. The program still
returns !Error. Reference Source Not Found. Does anyone have a suggestion on
how I can reference a blank (instead of the previous response) if no response
is given?

code: {ask created "Enter Date Created." \d ""}{ref created \d ""}
{ask approved "Enter Date Approved." \d ""}{ref approved
\d "")

results: Created on: April 4, 2007
Approved on: Error! Reference source not found.
 
J

Jay Freedman

ODog said:
I inserted an ask statement with a switch to default to blank if no
answer is given, then I used the REF and again used a switch to
default to blank if no source is found. I thought this would work,
but it doesn't. The program still returns !Error. Reference Source
Not Found. Does anyone have a suggestion on how I can reference a
blank (instead of the previous response) if no response is given?

code: {ask created "Enter Date Created." \d ""}{ref
created \d ""} {ask approved "Enter Date
Approved." \d ""}{ref approved \d "")

results: Created on: April 4, 2007
Approved on: Error! Reference source not found.

If you can live with a single space for the value of the ref field when the
ask field isn't answered, you can put a space character between the quotes
in the \d switch of the ask field. (You can then remove the \d switch from
the ref field, because it'll never have any effect.)

If you need to eliminate the space (maybe to make other things on the same
line stay put), it's possible but more complicated. You have to replace the
ref field with this:

{if "{ref created}" = "Error! Reference source not found." "" {ref created}}

and similarly for the ref approved field. This compares the result of the
ref field to the possible error message; if they're equal, the result of the
if field is an empty string, otherwise it's the value of the ref field.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
O

ODog Trying NewTricks

Fabulous! Thank you much.

Jay Freedman said:
If you can live with a single space for the value of the ref field when the
ask field isn't answered, you can put a space character between the quotes
in the \d switch of the ask field. (You can then remove the \d switch from
the ref field, because it'll never have any effect.)

If you need to eliminate the space (maybe to make other things on the same
line stay put), it's possible but more complicated. You have to replace the
ref field with this:

{if "{ref created}" = "Error! Reference source not found." "" {ref created}}

and similarly for the ref approved field. This compares the result of the
ref field to the possible error message; if they're equal, the result of the
if field is an empty string, otherwise it's the value of the ref field.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
Z

Zadok @ Port of Seattle

Jay
This is oh so close to what I'm looking for. I am doing a StyleRef in the
footer of my document, showing the user where they are in a huge numbered
list. Some of the later pages don't have any of the 'Numbered List" style in
use and so the formula just returns the last known instance of that style,
even if it was pages ago. Is it possible to get a blank if there is no use of
that style on my certain page?

Zadok
 
J

Jay Freedman

It doesn't appear that you can do that. The Help topic on the StyleRef field
lists all the switches that control where it locates the style and what
results it shows. There isn't any switch that shows what page the style
appears on, which is what you'd need in order to suppress the field result.

Possibly you could put an empty paragraph of the Numbered List style, marked
to skip numbering, on the page after the most recent "real" numbered
paragraph. That would be very fragile and hard to maintain, though, and it
might mess up the numbering order.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
Z

Zadok @ Port of Seattle

Jay,
That works great, now I have a '0' in the reference; can I switch that off?
 
J

Jay Freedman

I don't understand where you're getting a '0' from. If I have an empty
paragraph of the referenced style (the numbering is turned off, and nothing
appears but the ¶ symbol when nonprinting characters are shown), then the
StyleRef field in the footer doesn't show anything.

Still, there is a technique to work around the '0' if you can't get rid of
it, similar to the one that started this thread. You need nested fields (use
Ctrl+F9 to insert each pair of field braces):

{ If {StyleRef MyStyle} = "0" "" {StyleRef MyStyle} }

This says if the result of the StyleRef field is the character "0", then
display nothing; otherwise display the result of the StyleRef field.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
S

Stefan Blom

A zero result indicates that the STYLEREF field is trying to reference
the (non-existing) number of an un-numbered paragraph.

--
Stefan Blom
Microsoft Word MVP


in message
 
Z

Zadok @ Port of Seattle

Jay,
Many thanks for the help with this, my doc is nearly perfect. This is my
first IF statement in a Reference. One last tweak, is it possible to return
"" if there is no reference to MyStyle? I get this error otherwise:

Error! No text of specified style in document.

Zadok
 
J

Jay Freedman

I'll refer you again to the technique in the post at the very bottom
of this thread... Write an IF field that compares the value of the
StyleRef field to the error message you quoted, and displays an empty
string if they're equal, or the value of the StyleRef otherwise. Embed
that entire IF field within the IF field of my most recent reply, in
place of the second {StyleRef MyStyle} field.

It gets long and complicated, but it works.
 
G

Graham Mayor

You don't even need the full error message

{ IF{ STYLEREF "MyStyle" } <> "Error!*" "{ STYLEREF "MyStyle" }" }

will do the trick


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Z

Zadok @ Port of Seattle

Graham,
Wow that is pretty tight. Is there any way to do an OR statement? I'd like
to supress the STYLEREF if there is an Error or a "0" value.
 
G

Graham Mayor

{ IF{ STYLEREF "MyStyle" } <> "Error!*" " { IF{ STYLEREF "MyStyle" } <> 0
"{ STYLEREF "MyStyle" }" }" }

should do the trick
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
S

shila

ODog Trying NewTricks said:
I inserted an ask statement with a switch to default to blank if no answer is
given, then I used the REF and again used a switch to default to blank if no
source is found. I thought this would work, but it doesn't. The program still
returns !Error. Reference Source Not Found. Does anyone have a suggestion on
how I can reference a blank (instead of the previous response) if no response
is given?

code: {ask created "Enter Date Created." \d ""}{ref created \d ""}
{ask approved "Enter Date Approved." \d ""}{ref approved
\d "")

results: Created on: April 4, 2007
Approved on: Error! Reference source not found.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top