# Contact list as dictionary

by N3buchadnezzar   Last Updated August 13, 2019 20:23 PM - source

### Introduction

I am trying to create a template to make it easier to type problemsets and exams for the university I am working for. In that regard it is often neccecary to write down the contact information of the members of the faculty.

What I am looking for is a user friendly way to insert people into a "dictionary" and retrieve them using some ID.

Something like the following would ideal

### Example

\updateContactInfo{
id = joe,
name = Joe Doe,
mobile = 12345678,
phone = 87654321
}
id = jane,
name = Jane Doe,
mobile = 12345678,
phone = 87654321
}
}

\begin{document}

\getContactInfo[jane][name]

\end{document}


Here is what I have so far, but the code is not ideal. The syntax is hard to read and update for the normal user

### Code

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{xparse,xstring}

\NewDocumentCommand\contactInfo{m m}{%
\IfStrEqCase{#1}{%
{jane}{%
\IfStrEqCase{#2}{%
{name}{Jane Doe}
{mobile}{32132132}
{phone}{123123123}
}[]
}
{Joe}{%
\IfStrEqCase{#2}{%
{name}{Joe Doe}
{mobile}{32132132}
{phone}{123123123}
}[]
}
{richard}{%
\IfStrEqCase{#2}{%
{name}{Richard Roe}
{mobile}{32132132}
{phone}{123123123}
}[]
}%
}[]
}

\begin{document}

\contactInfo{jane}{mobile}

\end{document}

Tags :