Results 1 to 9 of 9
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    fieldcodes if else... (Word 2002 XP SR3)

    I want to expand my fieldcode to add a condition...heres what I would like to include in the condition

    print the filename
    else if file doesnt exist display error message

    Ive been trying to get the the 2nd part to generate my error message without much success.


    heres my fieldcode...
    the first part is

    { PRINT p page (MEL_LTR_PS) run * MERGEFORMAT}

    the 2nd part is if file doesnt exist then display message...
    (MEL_LTS_PS filename is not loaded)

    any ideas on how I can do this?

    many thanks

    diana

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: fieldcodes if else... (Word 2002 XP SR3)

    I don't fully understand the question, because I have no idea what the text MEL_LTR_PS stands for, or how you are getting the filename.
    The syntax for IFa Then b Else c is

    { If a b c }
    for example you can test to see if a bookmark exists in the document using
    { IF { ref TEMP }<>"Error! Reference source not found." "TEMP exists" "TEMP not in document" }

    StuartR

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: fieldcodes if else... (Word 2002 XP SR3)

    Hi Macropod

    MEL_LTR_PS yes is standard postscript code.

    Our existing print field code has the following code...

    { PRINT p page "%ūginResource: file Lexmark_Overlay /GetOvr{/Demo ed/overlay ed/MacroSave save def/showpage{}bd Demo 1 eq {statusdict begin false setfilenameextend end}if/htest false def overlay{pop /htest true def}=string filenameforall htest{overlay run}{100 100 moveto /Helvetica findfont 20 scalefont setfont overlay show( is not loaded.)show showpage stop}ifelse Demo 1 eq{statusdict begin true setfilenameextend end}if MacroSave restore} bd %%EndResource (MEL_LTR_PS) 0 GetOvr" * MERGEFORMAT }

    ive been using this fieldcode as an example and trying to decifer the fieldcode...

    From what I can gather the following line reads if the file is not found, print an error message...

    100 100 moveto /Helvetica findfont 20 scalefont setfont overlay show( is not loaded.)show showpage stop

    resulting in...

    (<filename> is not loaded)

    example...

    (MEL_LTR_PS is not loaded)

    Printing to a different printer driver the postscript commands are different. When the file is not found the default postscript error is printed ie

    ERROR: undefinedfilename
    OFFENDING COMMAND: run

    I wanted to add error handling code in my field code and if filename not found then print a meaning ful error message

    diana

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: fieldcodes if else... (Word 2002 XP SR3)

    If the question requires knowledge of a specific printer's internal interface language, it's going to be difficult to find an answer here...

  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

    Re: fieldcodes if else... (Word 2002 XP SR3)

    Hi Diana,

    I don't think the PRINT field supports postscript error trapping; otherwise I'd expect you to already be getting an error message if the run command failed.

    A possible way around this, assuming your MEL_LTR_PS is just standard postscript code, might be load the file into the PRINT field via an INCLUDETEXT field instead of using the prostscript run command. For example:
    { PRINT p page "{INCLUDETEXT X:/PrinterPath/MEL_LTR_PS}"}
    If that works, then the absence of the file should generate the standard INCLUDETEXT field message "Error! Not a valid filename.", which you could change via an IF test like:
    { PRINT p page "{IF{INCLUDETEXT X:/PrinterPath/MEL_LTR_PS}= "Error*" "File MEL_LTR_PS is missing" {INCLUDETEXT X:/PrinterPath/MEL_LTR_PS}}"}

    For what its worth, this approach also obviates the need to have the postscript file pre-loaded onto the printer - it could be stored anywhere you like.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  6. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: fieldcodes if else... (Word 2002 XP SR3)

    Hi Diana,

    Try something like this:
    {PRINT p page "{IF{INCLUDETEXT "X:/PrinterPath/MEL_LTR_PS"}="Error*" "/ErrTxt ({FILENAME}: File MEL_LTR_PS is missing) def /Helvetica findfont 20 scalefont setfont wp$x wp$right sub wp$left add 2 div ErrTxt stringwidth pop 2 div sub wp$y wp$top sub wp$bottom add 2 div moveto erasepage ErrTxt show showpage currentfile flushfile" {INCLUDETEXT "X:/PrinterPath/MEL_LTR_PS"}}"}
    where 'X:/PrinterPath/' is the path to your MEL_LTR_PS file. If it's not found, you should get an one-page error message with the source filename followed by ': File MEL_LTR_PS is missing' in 20pt Helvetica centered on the page as the last page of the print job (any subsequent pages are flushed). If everything is OK, the postscript commands in the MEL_LTR_PS file should be executed.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  7. #7
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: fieldcodes if else... (Word 2002 XP SR3)

    Hi Macropod

    The file is located on the actual printer hard disk. therefore I couldnt get the "INCLUDETEXT..." field to work...I'll try some more variations, and keep plugging away at it.

    I'll also try my luck and check out some postscript forums...

    cheers diana

  8. #8
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: fieldcodes if else... (Word 2002 XP SR3)

    Hi Diana,

    Yes, for the field coding I posted to work, you need to be able to specify the path to the postscript file, be that in a printer or on a PC or network. The advantage of using the INCLUDETEXT field approach is that it means you don't have to copy the postscript file to the printer beforehand (you've already got it on disk somewhere anyway!) and it frees you up from the vagaries of the postscript calls needed for each printer you're using (I understand the problem has come about because you're changing from Lexmark to HP printers). Plus, you can output to PDF, which you can't do with the current implementation.

    If you're set on keeping the current process, you'll have to modify the postscript code. For example, the string:
    'ed/overlay ed/MacroSave save def/showpage{}bd'
    calls two macro procedures - 'ed' and 'bd' - that aren't defined in your PRINT field. Unless you define these before they're called, you're likely to get a postscript 'undefined: ed' or 'undefined: bd' error. For 'ed', you should use '/ed {exch def}bind def'. For 'bd' you should use '/bd bind def'.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  9. #9
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: fieldcodes if else... (Word 2002 XP SR3)

    Hi Macropod

    ...so I've been plugging away at this

    thank you for your suggestion. the line you supplied....

    '/ed {exch def}bind def'

    was required in the fieldcode. it was just a matter of inserting into the correct location

    I did a websearch and discovered the following...

    The Lexmark driver used is based on Microsoft's NT4 (kernel mode) driver software (you can tell from the "NTPSOct95" dictionary name). And that driver emits a PostScript prolog which defines

    /ed {exch def}bind def

    This definition is missing in the driver DLL used for the HP printer (which is the user mode driver Pscript 5.x).

    Therefore for the HP printer(s), I need to edit the PostScript code and insert the definition in the correct location.

    see top screen capture for the working fieldcode solution.

    This fieldcode calls the correct overlay file stored on the printers hard disk.

    Also the fieldcode contains error handling code which was what I after as well. Instead of displaying the standard postscript error message ie...

    ERROR:
    OFFENDING COMMAND:

    I wanted a meaningful error message printed/displayed.

    If for some reason, the overlay does not exist on the printer hard disk, (eg. sys admins may have accidentally forgotten to download the file) I wanted to display/ print a meaningful message to assist Helpdesk and Technology in troubleshooting.

    This now occurs. see bottom screen shot. A page prints with the error message "<the file name> is not loaded."

    thanks again Macropod <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    diana
    Attached Images Attached Images

Posting Permissions

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