'LastDelimter' on string or ' .DelimitedText' on TStringList

Use this forum for everything concerning script usage
Post Reply
nycfella
Newbie
Newbie
Posts: 1
Joined: Sun Dec 18, 2011 6:50 pm

'LastDelimter' on string or ' .DelimitedText' on TStringList

Post by nycfella »

I am a total noob to the forum and to Delphi. I have been able to use some of the sample scripts to manipulate some strings (copy, trim, etc). I am trying to develop a script that uses 'LastDelimiter' on the Artist field to return the postion of the last space in an artist name. From there, I hope to get the last name of the artist regardless of the number of spaces in the name (i.e. "Jimi Hendrix" returns "Hendrix", "Stevie Ray Vaughan" returns "Vaughan", "George 'The Animal' Steele" returns "Steele", etc.)

My first attempts result in compile error: 'Unknown dentifier: LastDelimiter'

I'd also looked at using a TStringList.DelimitedText approach, but haven't attempted it.

I'm mostly trying to find out if LastDelimiter or DelimitedText are supported in TGF. Apologies in advance if this is a really stupid newbie question or syntax. I an clueless, and just want to work within what's supported.

Code: Select all

program LastName;

var
  sTmpArtist : string;
  sTmpLast : string;
  sTmpFull : string;
  iPos : integer;

begin

  if not tg_Init then exit;

  repeat


  sTmpArtist := tg_GetField( 'Artist' );
  iPos := LastDelimiter(' ', sTmpArtist);



  until not tg_Skip;


end;

User avatar
jtclipper
Administrator
Administrator
Posts: 768
Joined: Tue Aug 10, 2010 12:04 pm

Re: 'LastDelimter' on string or ' .DelimitedText' on TString

Post by jtclipper »

You can use the Rpos function to get the position of the last delimiter.

Code: Select all

 // this will also extract the last part of the artist field  
 Copy( tg_getField( 'Artist' ), RPos( ' ', tg_getField( 'Artist' ) ) + 1, 999 ) );

Post Reply