{
  "id": "1996-december-lets-split",
  "slug": "1996-december-lets-split",
  "url": "https://dwillis.github.io/uplink/article/1996-december-lets-split.html",
  "year": 1996,
  "month": "December",
  "monthNum": 12,
  "headline": "Let's split",
  "kicker": "TechTip",
  "author_name": "Richard Mullins",
  "author_title": "Senior Contributing Editor",
  "affiliation": "NICAR",
  "summary": "A guide to learning FoxPro string functions through hands-on experimentation, using the practical example of splitting name fields separated by commas to help journalists master computer-assisted reporting.",
  "keywords": [
    "FoxPro",
    "functions",
    "reporting"
  ],
  "topics": [
    "Investigative Methods",
    "Technology",
    "Data & Databases"
  ],
  "technologies": [
    "FoxPro",
    "Access"
  ],
  "full_text": "One of the recurring questions on NICAR-L is some variation of: \"I have a table with a name field and I need to Those who are starting to bear the stains of exposure to computer-assisted reporting will use the term \"string functions.\"\n\nThe advice on several occasions recently has been a brief pointer at part of the FoxPro manual or the online help, accompanied by the encouragement to sweat it out on your own. This is good, sound advice. It's not motivated by laziness or a certain relish in picturing you slogging through the personal hell they were forced to go through, back in the old days, and not like you kids today, and you know the rest.\n\nHere how to slug it out on your own. Take short steps and make sure you understand each part before you go on. Here is the sort of answer you might get if you asked, \"How do I a put into a new field everything in a field that is found to the right of the comma?\" might come in handy for fields with contents like this: Smith, Robert- or, as in our example, Clinton, William Jefferson) REPLACE ALL RestName ; WITH SUBSTR (name, name) +1)\n\nIf you're thinking, \"This looks cryptic and hard to understand,\" then you should be declared legally sane. If you get the command to work, it may be the result of some luck and a few guesses in correcting the syntax errors after FoxPro tells you that you are missing argument, missing parenthesis, etc.\n\nTo illustrate the approach, assume a table called PREZ with a field called NAME. If the table is open and the record pointer (or cursor) is on the first row, you can try out the various functions and see the results on a single row, before you make any changes to your data. In the syntax examples that follow, the line in bold type is what you see on the FoxPro screen when you type in the command window. This is the convention used in the FoxPro manual. The question mark acts as a command word and means, \"print this on screen.\"\n\nTry out the left function with assorted numbers:\n\n? left (name, 3)\nCli\n? left (name, 11)\nClinton, Wi\n? left (name, 1)\nC\n\nNow, the original problem, posed for the sake of discussion and also one that comes up all the time in real life, is splitting name fields that are separated by a comma. If you understand how the FoxPro replace all command does the changes, then you only need three string functions to do the splitting:\n\nleft () at ( ) substr ()\n\nThe advice about sweating it out is related to the old \"teach someone to fish\" proverb: If you see these functions in action fixing one problem, you'll be able to figure out how to use them on new problems. After that, there is good news and more good news: There are more than three functions in FoxPro (and Access), and you know something useful about how to learn to use them.\n\nNow, back to the command window and taking small steps to solve the task at hand. We could state our instructions in English like this: \"For every row, find the location of the comma, then pick up the characters on the left side, up to, but not including the comma.\n\nWe've already seen how to print a certain number of characters, starting from the left. But names are not all the same length, which means the comma is not in the same place in every row of a table. This is not an obstacle, because of two facts about FoxPro: 1) There is a function to locate the position of a character within a string of characters, and 2) The results from one function can be submitted to another function. A short term for this, used by geeks, is nesting, an obvious metaphor when you think about it.\n\nApplying this, we try out the at(), function, then try combining it with left(), and when we're finished with that, put it all into the replace command. Using the at function on \"Clinton, William Jefferson\" gives the answer of 8 as the position of the comma. Note the syntax is:\n\nAT StringToSearchIn)\n\n? name\nClinton, William Jefferson\n\n? at (\",\", name)\n8\n\nBefore combining the two functions, we'll use the literal number 8 with the left function, and then using the At() we'll pass along the same number to the Left() function.\n\n? left (name, 8)\nClinton,\n? left (name, at (\",\" , name) )\nClinton\n\nTo fix the problem of the trailing comma, you include one less character in the left command. The math for this translates to subtracting one from the number that indicates the comma position.\n\n? left (name, 8 -\nClinton\n? left (name, at (\",\" , name) - 1 )\nClinton\n\nNow, you're ready to use this command to split the last name into its own field. Save yourself typing mistakes and paste your perfectly debugged statement into the replace all part of the command.\n\nREPLACE ALL LastName ; WITH left (name, at (\",\" name)\n\nTo do the right part of the name, you need to know how to use the substr( ) function. Here are two examples:\n\n? substr (name, 6)\nn, William Jefferson\n\n? substr (name, 6, 5)\nn, Wi\n\nYou could sweat this one out, or just go back to the top of this article for the answer.",
  "provenance": {
    "extracted_by": "anthropic/claude-sonnet-4-6",
    "extracted_at": "2026-07-05",
    "verified": true
  },
  "similar": [
    {
      "slug": "1992-november-unraveling-those-mysterious-string-functions",
      "score": 0.389
    },
    {
      "slug": "1997-august-car-tech-tip",
      "score": 0.353
    },
    {
      "slug": "1997-june-whats-your-function",
      "score": 0.299
    },
    {
      "slug": "1997-march-tech-tip",
      "score": 0.233
    },
    {
      "slug": "1998-april-foxpro-to-access-and-back-again",
      "score": 0.199
    }
  ],
  "html_url": "https://dwillis.github.io/uplink/article/1996-december-lets-split.html",
  "json_url": "https://dwillis.github.io/uplink/article/1996-december-lets-split.json"
}