Author Topic: Conditional code replacements  (Read 4786 times)

Offline TiggerGTO

  • Member
  • **
  • Posts: 95
    • View Profile
Conditional code replacements
« on: May 19, 2009, 07:47:12 PM »
A while ago, I asked about an easy way to do code replacements on multiple fields.  Kirk suggested typing the jersey number in an unused field (I chose Edit Status) and then applying a stationery pad for the code replacement.  I set up a pad that has /c{editstatus}/ in the caption field and /k{editstatus}/ in the keyword field.  My code replacement delimiter is set to be /.  This works great except for one minor glitch.  If I happen to have a picture I didn't bother to identify, the stationery pad ends up putting /c/ and /k/ respectively in the caption and keyword fields.  It would be great if I could have some sort of condition on the code replacement so that if editstatus is empty, nothing gets applied to those fields.  Is there a way to define a code replacement to be a null string or a blank string?  Or, would it be possible to put some sort of conditional expression in the stationery pad to work in conjunction with the code replacement something like: {editstatus}?/c{editstatus}/:""

The simpler solution would be a code replacement that results in an empty or blank string, but the conditional expression could be quite useful.  Now that I've asked this question, I seem to remember a discussion about specifying a default code replacement that would get used if the start and end delimiters were found but the stuff in between didn't match any of the replacement definitions.  Did that ever happen?

Thanks,
Danny

Offline devenh

  • Sr. Member
  • ****
  • Posts: 435
    • View Profile
Re: Conditional code replacements
« Reply #1 on: May 19, 2009, 07:59:18 PM »
Have you tried using the new field code replacements introduced in 4.6?

It looks like you are using /c/ and /k/ to denote separate fields for a jersey number.  Instead, you can use field in 4.6.

Example, for jersey 24:

24 tab Joe Smith tab Forward

Then in the caption field place /{editstatus}/ and in the keywords field put /{editstatus}#2/.  Note, the caption field could also be /{editstatus}#1/.

4.6 also lets you set a "default replacement" in case the jersey number is not found.  This is set in the Code Replacement dialog box under Edit | Settings.

Deven

Offline TiggerGTO

  • Member
  • **
  • Posts: 95
    • View Profile
Re: Conditional code replacements
« Reply #2 on: May 20, 2009, 06:59:24 AM »
Yes, that is what I am doing... I'll have to give the new field code replacements a try.  It certainly would make maintaining my code replacements file much easier.