Author Topic: Using variables to define code replacement rules  (Read 131 times)

Offline Claude Diderich

  • Member
  • **
  • Posts: 50
  • Claude Diderich
    • View Profile
    • Claude Diderich Sports Pictures
Using variables to define code replacement rules
« on: June 15, 2025, 02:42:41 AM »
I have a code replacement file with three columns of all players in an event that looks as follows:
Code: [Select]
01 Player A Country A
02 Player B Country A
03 Player C Country C
04 Player D Country D
05 Player E Country D
06 Player F Country E
..
This allows me to insert the player name using e.g. /01/. If I want to insert the player name combined with the country, I enter /01/ of team /01#2/. Now I would like to define additional code replacements as follows:
Code: [Select]
+01 /01/ of team /01#2/
+02 /04/ of team /02#2/
+03 /04/ of team /03#2/
+04 /04/ of team /04#2/
...

Especially if the list of players is long and changes over time and numbering is ad-hoc, this is tedious. I would love to be able to insert a generic rule (rather than a list of specific CRs, one per player) that could look like this:
Code: [Select]
+{var} /{var}/ of team /{var}#2/where +{var} matches any string that starts with a +.

This would define a code replacement rule that considers {var} as a variable, i.e., that replaces for example the code /+123/ by /123/ of team /123#2/, {var} being assigned 123. This would allow me to enter the player name of player X by entering /X/ and the player name including its team affiliation by /+X/.

Note: I assume in the example / being the code replacement separator.
Claude Diderich, sports photographer, member of AIPS and sportpress.ch

Online Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 25401
    • View Profile
    • Camera Bits, Inc.
Re: Using variables to define code replacement rules
« Reply #1 on: June 15, 2025, 07:46:52 AM »
Claude,

Have you investigated Photo Mechanic's Hot Codes feature (an extension of Code Replacements)?

https://docs.camerabits.com/support/solutions/articles/48001252633-hot-codes

HTH,

-Kirk