Author Topic: Strange behaviour of code replacement "$ and $" in PhotoMechanics 6  (Read 695 times)

Offline Claude Diderich

  • Member
  • **
  • Posts: 53
  • Claude Diderich
    • View Profile
    • Claude Diderich Sports Pictures
I am using $ as code replacement delimiter character. I have a file that maps three letter ISO country codes to country names. Now, what I find strange is that when I enter $ and $, PhotoMechanics 6 replaces it with Andorra, although the code replacement file does not include spaces around and. By the way $and$ is also replaced by Andorra. I found that when pre-populating a caption with $ and $ are both ....

Is this a bug or meant to be like that?

My code replacement file reads as follows (excerpt):
Code: [Select]
// ISO country cods
// --
afg Afghanistan
ala Aland Islands
alb Albania
dza Algeria
asm American Samoa
and Andorra
ago Angola
aia Anguilla
Claude Diderich, sports photographer, member of AIPS and sportpress.ch

Offline alexmacnaughton

  • Newcomer
  • *
  • Posts: 12
    • View Profile
Re: Strange behaviour of code replacement "$ and $" in PhotoMechanics 6
« Reply #1 on: August 16, 2025, 04:57:39 AM »
Hi Claude, don't quite understand your problem.

I tested using CR with and without spaces, and the result is always without spaces.

Alex

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 25454
    • View Profile
    • Camera Bits, Inc.
Re: Strange behaviour of code replacement "$ and $" in PhotoMechanics 6
« Reply #2 on: August 16, 2025, 06:31:12 AM »
Claude,

I am using $ as code replacement delimiter character. I have a file that maps three letter ISO country codes to country names. Now, what I find strange is that when I enter $ and $, PhotoMechanics 6 replaces it with Andorra, although the code replacement file does not include spaces around and. By the way $and$ is also replaced by Andorra. I found that when pre-populating a caption with $ and $ are both ....

Is this a bug or meant to be like that?

What is it that you want it to do when there are spaces in addition to the word between your code replacement delimiters?  PM trims leading and trailing whitespace from your codes and replacements.

I would expect it to output your replacement either with or without spaces in addition to your code.

-Kirk

Offline Claude Diderich

  • Member
  • **
  • Posts: 53
  • Claude Diderich
    • View Profile
    • Claude Diderich Sports Pictures
Re: Strange behaviour of code replacement "$ and $" in PhotoMechanics 6
« Reply #3 on: August 17, 2025, 01:06:27 AM »
Thanks for your clarification. I would prefer PM not to trim spaces.

Here is my use case (note that $ is my delimiter character - that is most efficient for me on a Swiss keyboard):
  • I have a CR file mapping ISO country codes to countries. I have a generic CR file per sport (in this case volleyball). I have a event specific CR file, include players, per event. See below for a specific example!
  • When I want to add a caption of both teams standing for the national anthem, I enter the CR $!cna2$.
  • This would lead to the caption reading  (under the assumption that PM does not trim spaces) $ and $ national volleyball teams stand during the playing of the national anthems ahead of the men's EuroVolley 2026 qualifying match between Switzerland and Sweden at the WIN4 arena on {dow}, {monthname} {day}, {year4} in {city}, {country}. Note that the $ delimiter character serves as a placeholder for additional CRs. This helps me know where I need to add data to the generic caption.
  • I then would amend the caption as follows $sui$ and $swe$ national volleyball ..., leading to the final caption when fully evaluated: Switzerland and Sweden national volleyball teams stand during the playing of the national anthems ahead of the men's EuroVolley 2026 qualifying match between Switzerland and Sweden at the WIN4 arena on Saturday, August 16, 2025 in Winterthur, Switzerland.
  • This is, to me, a very efficient way of captioning photos in a consistent way. I only have to enter $!cna2$, sui$, and swe$.
  • Most of the times it works! But in this particular case $!cna2$ is evaluated to Andorra national volleyball teams stand during the playing of the national anthems ahead of the men's EuroVolley 2026 qualifying match between Switzerland and Sweden at the WIN4 arena on {dow}, {monthname} {day}, {year4} in {city}, {country}, because $ and $ evaluates, after space stripping to Andorra.

I am unclear of a use case where stripping spaces may be preferable over not stripping them in CRs, but would be interested to learn. Maybe having a toggle (enable/disable space stripping in CRs) in the Preferences could address that challenge, if I convinced you of the relevance and it can be implemented with reasonable complexity and I am not the only one running in this issue.

CR file: countries.txt (excerpt)
Code: [Select]
// ISO country cods
afg Afghanistan
ala Aland Islands
alb Albania
dza Algeria
asm American Samoa
and Andorra
ago Angola
aia Anguilla
CR file: volleyball.txt (generic, excerpt)
Code: [Select]
// core/spo/volleyball.txt
!ccsp   $ head coach speaks with his/her players $+capd$
!cf     $ fans follow the game $+capd$
!cna1   $ national volleyball team stands during the playing of the national anthems ahead of $+cap$
!cna2   $ and $ national volleyball teams stand during the playing of the national anthems ahead of $+cap$
!cwu    $ and $ warm-up ahead of $+cap$

CR file: sui-swe.txt (match specific, excerpt)
Code: [Select]
// event/volleyball/sui-swe.txt
+cap the men's EuroVolley 2026 qualifying match between Switzerland and Sweden at the WIN4 arena on {dow}, {monthname} {day}, {year4} in {city}, {country}
+capd during $+cap$

// Team Switzerland
ch01 Ramon Diem
ch02 Peer Harksen

tch01 $ch01$ of team Switzerland
tch02 $ch02$ of team Switzerland
« Last Edit: August 17, 2025, 01:52:27 AM by Claude Diderich »
Claude Diderich, sports photographer, member of AIPS and sportpress.ch