Page 1 of 1

Splitting current field into two for custom field creation

Posted: 2015-01-05 15:32:48
by daws0n
I would like to take advantage of AMC's custom field creation, historically I have used an uneeded catalog field (e.g borrower) to achieve similar usage.

In some cases I have used a single field, where ideally I would now like to use two... (e.g rotten tomatoes and metacritic ratings in one string). The values are split with a "/" between them.

I have copied the value I wish to "split" into two custom fields, and have I figured out how to truncate it so it only shows data before the "/" using a script kindly provided by soulsnake here:

viewtopic.php?t=5473&highlight=

Code: Select all

program KeepOnlyFirstValueInFieldCategory;
var
  s: string;
  i: Integer;
begin
  s := GetField(fieldCategory);
  i := Pos('/', s);
  if i = 0 then
    i := Pos(',', s);
  if i = 0 then
    i := Pos(';', s);
  if i > 0 then
  begin
    s := Copy(s, 1, i-1);
    s := Trim(s);
    SetField(fieldCategory, s);
  end;
end.
I would like to achieve the opposite thing in the second field - keeping only the data after the "/" not before it.

Is this possible?[/quote]

Posted: 2015-01-05 17:15:04
by antp
s := Copy(s, i + 1, Length(s));
(or maybe i instead of i+1, to be tested :D)

Posted: 2015-01-06 19:14:48
by daws0n
Thanks Antp! Am I able to manipulate custom fields using scripts aswell? At present I cannot get the script to identify the new custom field by it's tag name (Custom1).

Posted: 2015-01-06 19:59:25
by daws0n
sorted :)

Code: Select all

GetCustomField('Custom1');