Author Topic: Code replacement range for a team  (Read 1911 times)

Offline Sc00ter

  • Newcomer
  • *
  • Posts: 11
    • View Profile
Code replacement range for a team
« on: May 13, 2014, 03:33:38 PM »
Version 5.0, build 15451 for Intel Mac

Cheers,

Will code replacement allow for a range of bib numbers to point to one team?

For instance;

400-406  Team 1
410-416   Team 2
etc...

Obviously I could just list it out, but it seems that PM might be smart enough to handle a script type description.

Thanks,

scoot

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24756
    • View Profile
    • Camera Bits, Inc.
Re: Code replacement range for a team
« Reply #1 on: May 13, 2014, 03:47:35 PM »
Will code replacement allow for a range of bib numbers to point to one team?

For instance;

400-406  Team 1
410-416   Team 2
etc...

Obviously I could just list it out, but it seems that PM might be smart enough to handle a script type description.

No.  It uses exact string matching.

-Kirk

Offline Sc00ter

  • Newcomer
  • *
  • Posts: 11
    • View Profile
Re: Code replacement range for a team
« Reply #2 on: May 13, 2014, 03:52:11 PM »
Thank you for the quick reply.

s.

Offline Brandon

  • Member
  • **
  • Posts: 85
    • View Profile
Re: Code replacement range for a team
« Reply #3 on: May 13, 2014, 05:12:53 PM »
Hi Sc00ter,

A little bit of ruby code and you can construct a simple line that will help to create a code replacement file for your situation.

If you do not have Ruby installed on your machines then you can copy and paste the code into http://ideone.com
You'll want to make sure that the Language setting next to the "stdin" button is set to Ruby then replace the "# your code goes here" with what's listed in the code block below


You can tweak the numbers in (1..50) to give it a different range, and change the text "Team 1" to whatever the team name is. If you have multiple replacements then you'll want to separate them with a \t character (represents the 'tab' key). The \n should always be at the end.

Code: [Select]
(1..50).each do |x|

puts x.to_s + "\tTeam 1\n"

end


EDIT: One of the engineers came up with the code snippet below that will perform exactly what you've requested in your original post.

Code: [Select]
label_ranges = [
  ["Team 1", 400..406],
  ["Team 2", 410..416],
                        # can add additional ranges here...
]

label_ranges.each do |label, range|
  range.each {|n| puts "#{n}\t#{label}"}
end

Then hit the green button that says "Run" and it'll generate a list for you in a section called "stdout" that you can then just hit the "copy" button to insert that into your clipboard for building your new code replacement file in a text editor. You can just run this each time for the different teams and combine it all into a single code replacement file.

I just tested this process on Windows 7 with Notepad++ as my text editor set to utf-8, everything is working as expected when loaded into Photo Mechanic 5.

« Last Edit: May 13, 2014, 05:56:14 PM by Admin »

Offline Hayo Baan

  • Uber Member
  • ******
  • Posts: 2552
  • Professional Photographer & Software Developer
    • View Profile
    • Hayo Baan - Photography
Re: Code replacement range for a team
« Reply #4 on: May 13, 2014, 11:16:07 PM »
Hi Sc00ter, since you're on a Mac, you'll definitely have Perl installed so here's an alternative script you could use.
Code: [Select]
#!/usr/bin/perl
my %ranges = ("Team 1" => [400 .. 406], "Team 2" => [410 .. 416]);
for my $team (sort keys %ranges) { print "$_\t$team\n" for (@{$ranges{$team}}) }
Save that in a textfile and run with "perl script > codereplacement.txt" on the command-line (Terminal).
This will produce a file codereplacement.txt that you can then use as codereplacement in PM.

You can also run this from the command-line directly (without saving a script first), but if you have many teams, this can become a bit tedious as editing on the command-line is more cumbersome:
Code: [Select]
perl -e 'my %ranges = ("Team 1" => [400 .. 406], "Team 2" => [410 .. 416]); for my $team (sort keys %ranges) { print "$_\t$team\n" for (@{$ranges{$team}}) }' > codereplacement.txt
Hope this helps :)
« Last Edit: May 13, 2014, 11:18:38 PM by Hayo Baan »
Hayo Baan - Photography
Web: www.hayobaan.nl