Splitting current field into two for custom field creation

If you made a script you can offer it to the others here, or ask help to improve it. You can also report here bugs & problems with existing scripts.
Post Reply
daws0n
Posts: 53
Joined: 2005-02-04 13:53:18

Splitting current field into two for custom field creation

Post 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]
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

s := Copy(s, i + 1, Length(s));
(or maybe i instead of i+1, to be tested :D)
daws0n
Posts: 53
Joined: 2005-02-04 13:53:18

Post 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).
daws0n
Posts: 53
Joined: 2005-02-04 13:53:18

Post by daws0n »

sorted :)

Code: Select all

GetCustomField('Custom1');
Post Reply