0

I am using the following code to print a list of all characters that say something in a given scene of a play-script.

\newcommand\sceneroles[2][Roles]{%
  \def\scenename{#2}%
  \textbf{#1}:%
  \Bind{?id}{rdf:type}{rl:role}{%
    % \GetVal prints the variable name,
    % \GetValProperty extracts property from the name
    % Set the default left time
    % use the real at:left if it has been set
    \IfProperty{\GetVal{?id}}{is:playsin#2}{%
        \GetValProperty{?id}{rl:name}, %
    }{}%
  }%
}

the problem is, that I cannot get rid of the last comma.

what should be printed is:

Roles: Romeo, Juliet

what is printed:

Roles: Romeo, Juliet,

Tobi
  • 255
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – DG' Oct 05 '20 at 20:32
  • Should we look in every package to find out where \GetValProperty and \Bind are defined and guess how you get Romeo and Juliet out of thin air? – egreg Oct 05 '20 at 22:05
  • By the way, there's no trace of \GetValProperty in TeX Live files. – egreg Oct 05 '20 at 22:09
  • Sorry, it's rdfdef from this other question a few years ago: https://tex.stackexchange.com/questions/473097/define-a-command-like-table-of-contents-but-for-attendees – Tobi Oct 06 '20 at 12:11

1 Answers1

1

Use this definition:

\newcommand\sceneroles[2][Roles]{%
  \def\scenename{#2}% Store scene names
  \def\namesep{\def\namesep{, }}% One cycle delay name separator
  \textbf{#1}:%
  \Bind{?id}{rdf:type}{rl:role}{%
    % \GetVal prints the variable name,
    % \GetValProperty extracts property from the name
    % Set the default left time
    % use the real at:left if it has been set
    \IfProperty{\GetVal{?id}}{is:playsin#2}{%
      \namesep\GetValProperty{?id}{rl:name}%
    }{}%
  }%
}

It uses a cunning (La)TeX trick.

Werner
  • 603,163