{"id":19522238,"url":"https://github.com/programarivm/mumps-examples","last_synced_at":"2025-02-26T00:47:14.022Z","repository":{"id":47961235,"uuid":"210804466","full_name":"programarivm/mumps-examples","owner":"programarivm","description":"This is a collection of M scripts for learning purposes. The examples in this tutorial are run with GT.M.","archived":false,"fork":false,"pushed_at":"2019-09-29T10:29:57.000Z","size":71,"stargazers_count":38,"open_issues_count":0,"forks_count":12,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-01-08T14:15:34.523Z","etag":null,"topics":["cheatsheet","example","fis","gtm","m","mumps","tutorial"],"latest_commit_sha":null,"homepage":"","language":"M","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/programarivm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-25T09:18:08.000Z","updated_at":"2024-11-16T12:13:23.000Z","dependencies_parsed_at":"2022-08-12T15:20:17.000Z","dependency_job_id":null,"html_url":"https://github.com/programarivm/mumps-examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programarivm%2Fmumps-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programarivm%2Fmumps-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programarivm%2Fmumps-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programarivm%2Fmumps-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/programarivm","download_url":"https://codeload.github.com/programarivm/mumps-examples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240771906,"owners_count":19854982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cheatsheet","example","fis","gtm","m","mumps","tutorial"],"created_at":"2024-11-11T00:37:54.327Z","updated_at":"2025-02-26T00:47:13.971Z","avatar_url":"https://github.com/programarivm.png","language":"M","readme":"# MUMPS Examples\n\n**MUMPS** (\"Massachusetts General Hospital Utility Multi-Programming System\"), or **M**, is a general-purpose computer programming language originally designed in 1966 for the healthcare industry. Its differentiating feature is its \"built-in\" database, enabling high-level access to disk storage using simple symbolic program variables and subscripted arrays; similar to the variables used by most languages to access main memory. [Read more...](https://en.wikipedia.org/wiki/MUMPS)\n\nThe implementations currently available are:\n\n- [Intersystems (Caché)](http://www.intersystems.com/)\n- [FIS (GT.M)](http://www.fisglobal.com/products-technologyplatforms-gtm)\n- [MUMPS Database and Language by Ray Newman](http://sourceforge.net/projects/mumps/)\n- [Open Mumps](http://www.cs.uni.edu/~okane/)\n\nThe examples in this tutorial are run with GT.M.\n\n## Prerequisites\n\n- [GT.M Administration and Operations Guide](http://mumps.cz/gtm/books/ao/UNIX_manual/ao_UNIX_screen.pdf)\n- [The GT.M Programmer's Guide](http://www.mumps.cz/gtm/books/pg/UNIX_manual/webhelp/content/preface.html)\n- [GT.M Message and Recovery Procedures Manual](http://www.mupip.pl/books/mr/manual/titlepage.html)\n- [MUMPS Technology Portal](http://mumps.cz/)\n\n### Additional Documentation\n\n- [Sourceforge](http://mumps.sourceforge.net/)\n\n### GPL Mumps\n\n- [The Mumps Programming Language](https://www.cs.uni.edu/~okane/)\n- [Mumps Language Users' Guide](https://www.cs.uni.edu/~okane/source/MUMPS-MDH/ReadMe.pdf)\n- [Mumps Language Quick Introduction \u0026 Tutorial](https://www.cs.uni.edu/~okane/source/MUMPS-MDH/MumpsTutorial.pdf)\n\n---\n\n## Quick Setup\n\nTo install GT.M on Debian based OS:\n\n    apt-get install fis-gtm\n\nSet up the environment variables:\n\n    source /usr/lib/x86_64-linux-gnu/fis-gtm/V6.3-003A_x86_64/gtmprofile\n\nOpen the GT.M prompt:\n\n    gtm\n\n    GTM\u003ewrite \"Hello world\"\n    Hello world\n    GTM\u003ehalt\n\nTo uninstall GT.M:\n\n    apt-get purge fis-gtm\n\n---\n\n## Run the Examples\n\nCopy the example of your choice into `$gtmdir/$gtmver/r`:\n\n    cp -r \u003cyour-folder\u003e/mumps-examples/06-databases/basic-sql-blog/* $gtmdir/$gtmver/r\n\nOr alternatively create a symbolic link:\n\n    ln -s \u003cyour-folder\u003e/mumps-examples/06-databases/basic-sql-blog/*  ~/.fis-gtm/V6.3-003A_x86_64/r\n\nThen run the example:\n\n    mumps -run ^Main\n\n---\n\n## 1. The Very Basics\n\n### [`HelloWorld.m`](https://github.com/programarivm/mumps-examples/blob/master/01-the-very-basics/HelloWorld.m)\n\n    Hello world\n\n### [`HelloWorldInLoop.m`](https://github.com/programarivm/mumps-examples/blob/master/01-the-very-basics/HelloWorldInLoop.m)\n\n    Hello world\n    Hello world\n    Hello world\n    Hello world\n    Hello world\n    Hello world\n    Hello world\n    Hello world\n    Hello world\n    Hello world\n\n### [`HelloWorldInAnotherLoop.m`](https://github.com/programarivm/mumps-examples/blob/master/01-the-very-basics/HelloWorldInAnotherLoop.m)\n\n    Hello world\n    Hello world\n    Hello world\n    Hello world\n    Hello world\n    Hello world\n    Hello world\n    Hello world\n    Hello world\n    Hello world\n\n### [`HelloWorldInNestedLoop.m`](https://github.com/programarivm/mumps-examples/blob/master/01-the-very-basics/HelloWorldInNestedLoop.m)\n\n    1:1 Hello world\n    1:2 Hello world\n    1:3 Hello world\n    1:4 Hello world\n    1:5 Hello world\n    2:1 Hello world\n    2:2 Hello world\n    2:3 Hello world\n    2:4 Hello world\n    2:5 Hello world\n\n### [`ArithmeticOperations.m`](https://github.com/programarivm/mumps-examples/blob/master/01-the-very-basics/ArithmeticOperations.m)\n\n    There were 7 apples, 8 pears and 9 oranges,\n    a total of 24 fruits in a basket.\n    Then, something happened:\n    1 apple, 2 pears and 0 oranges were eaten!\n    Now there are 21 fruits in the basket,\n    the average fruit value is 7.\n\n### [`Arrays.m`](https://github.com/programarivm/mumps-examples/blob/master/01-the-very-basics/Arrays.m)\n\n    Approaching the solar system:\n    Mercury\n    Venus\n    Earth\n    Mars\n    Jupiter\n    Saturn\n    Uranus\n    Neptune\n    Pluto\n\n    September 2019:\n    26 27 28 29 30 31 1\n    2 3 4 5 6 7 8\n    9 10 11 12 13 14 15\n    16 17 18 19 20 21 22\n    23 24 25 26 27 28 29\n    30 1 2 3 4 5 6\n\n    Genealogical tree:\n    Harry and Emily had Jack\n\n    Associative array:\n    Have you ever been to London?\n\n### [`ArraysShortened.m`](https://github.com/programarivm/mumps-examples/blob/master/01-the-very-basics/ArraysShortened.m)\n\n\u003e The output obtained is the same as that in [`Arrays.m`](https://github.com/programarivm/mumps-examples/blob/master/01-the-very-basics/Arrays.m)\n\n## 2. Functions\n\n### [`Ascii.m`](https://github.com/programarivm/mumps-examples/blob/master/02-functions/Ascii.m)\n\n    The ASCII code of \"a\" is 97.\n\n### [`Char.m`](https://github.com/programarivm/mumps-examples/blob/master/02-functions/Char.m)\n\n    Alphabet:\n    abcdefghijklmnopqrstuvwxyz\n\n### [`Data.m`](https://github.com/programarivm/mumps-examples/blob/master/02-functions/Data.m)\n\n    Genealogical tree:\n    gtree(1)=\"Oliver\"\n    gtree(1,1)=\"James\"\n    gtree(1,1,1)=\"Harry\"\n    gtree(1,1,1,1,1)=\"Robert\"\n    gtree(1,1,2)=\"Emily\"\n    gtree(1,2)=\"Amelia\"\n    gtree(1,2,1)=\"Thomas\"\n    gtree(1,2,2)=\"Jessica\"\n\n    Data about a few nodes:\n    $d(gtree(\"foo\")) is 0\n    $d(gtree(1,1,1,1,1)) is 1\n    $d(gtree(1,1,1,1)) is 10\n    $d(gtree(1)) is 11\n\n### [`Extract.m`](https://github.com/programarivm/mumps-examples/blob/master/02-functions/Extract.m)\n\n    Original string: Hello world!\n    Substring: Hello\n\n## 3. Utility Routines\n\n\u003e TODO.\n\n## 4. User Defined Functions\n\n### [`FactorialByReference.m`](https://github.com/programarivm/mumps-examples/blob/master/04-user-defined-functions/FactorialByReference.m)\n\n    Enter n: 5\n    5! = 120\n\n### [`FactorialByValue.m`](https://github.com/programarivm/mumps-examples/blob/master/04-user-defined-functions/FactorialByValue.m)\n\n    Enter n: 5\n    5! = 120\n\n### [`Fibonacci.m`](https://github.com/programarivm/mumps-examples/blob/master/04-user-defined-functions/Fibonacci.m)\n\n    Enter n: 9\n    F(9) = 34\n\n## 5. User Defined Routines\n\n### [`Main.m`](https://github.com/programarivm/mumps-examples/blob/master/05-user-defined-routines/Main.m)\n\n    Hello!\n    Enter n: 9\n\n    areaCircle(9) = 254.469\n    fibonacci(9) = 34\n    factorialByVal(9) = 362880\n    factorialByRef(9) = 362880\n\n\u003e For further details also visit [MyMathRoutines.m](https://github.com/programarivm/mumps-examples/blob/master/05-user-defined-routines/MyMathRoutines.m)\n\n## 6. Databases\n\n### [`basic-sql-crud/Main.m`](https://github.com/programarivm/mumps-examples/blob/master/06-databases/basic-sql-crud/Main.m)\n\n    User created:\n    ^users(1)=\"alice~password~alice-jones@no-reply.com~Alice Jones\"\n\n    User created:\n    ^users(2)=\"bob~password~bob-smith@no-reply.com~Bob Smith\"\n\n    User fetched (1):\n    data(\"email\")=\"alice-jones@no-reply.com\"\n    data(\"fullname\")=\"Alice Jones\"\n    data(\"password\")=\"password\"\n    data(\"username\")=\"alice\"\n\n    User updated (1):\n    ^users(1)=\"amelia~password~amelia-roberts@no-reply.com~Amelia Roberts\"\n\n    User fetched (1):\n    data(\"email\")=\"amelia-roberts@no-reply.com\"\n    data(\"fullname\")=\"Amelia Roberts\"\n    data(\"password\")=\"password\"\n    data(\"username\")=\"amelia\"\n\n    User deleted (2)\n\n    User fetched (2):\n    data(\"email\")=\"\"\n    data(\"fullname\")=\"\"\n    data(\"password\")=\"\"\n    data(\"username\")=\"\"\n\n    Database successfully dropped!\n\nFor further details also visit:\n\n- [`Database.m`](https://github.com/programarivm/mumps-examples/blob/master/06-databases/basic-sql-crud/routines/Database.m)\n- [`User.m`](https://github.com/programarivm/mumps-examples/blob/master/06-databases/basic-sql-crud/routines/User.m)\n\n### [`basic-sql-blog/Main.m`](https://github.com/programarivm/mumps-examples/blob/master/06-databases/basic-sql-blog/Main.m)\n\n    Users:\n    ^users(1)=\"alice~password~alice-jones@no-reply.com~Alice Jones\"\n    ^users(2)=\"bob~password~bob-smith@no-reply.com~Bob Smith\"\n\n    Categories:\n    ^categories(1)=\"foo~Foo\"\n    ^categories(2)=\"bar~Bar\"\n    ^categories(3)=\"foobar~Foobar\"\n\n    Posts:\n    ^posts(1,1,1)=\"lorem-ipsum~Lorem ipsum~Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\"\n    ^posts(2,1,1)=\"donec-pede-justo~Donec pede justo~Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.\"\n    ^posts(3,3,2)=\"curabitur-ullamcorper-ultricies~Curabitur ullamcorper ultricies~Curabitur ullamcorper ultricies nisi.\"\n    ^posts(4,3,2)=\"donec-vitae-sapien~Donec vitae sapien~Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante.\"\n\n    Comments:\n    ^comments(1,1)=\"This is awesome! Thank you.\"\n    ^comments(2,2)=\"Thank you so much for sharing this.\"\n\n    Category fetched (3):\n    data(\"description\")=\"Foobar\"\n    data(\"slug\")=\"foobar\"\n\n    Post fetched (1):\n    data(\"description\")=\"Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\"\n    data(\"slug\")=\"lorem-ipsum\"\n    data(\"title\")=\"Lorem ipsum\"\n\n    Posts fetched by category (3):\n    data(3,3,2)=\"curabitur-ullamcorper-ultricies~Curabitur ullamcorper ultricies~Curabitur ullamcorper ultricies nisi.\"\n    data(4,3,2)=\"donec-vitae-sapien~Donec vitae sapien~Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante.\"\n\n    Posts fetched by user (1):\n    data(1,1,1)=\"lorem-ipsum~Lorem ipsum~Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\"\n    data(2,1,1)=\"donec-pede-justo~Donec pede justo~Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.\"\n\n    Comment fetched (1):\n    data(\"description\")=\"This is awesome! Thank you.\"\n\n    Database successfully dropped!\n\nFor further details also visit:\n\n- [`Category.m`](https://github.com/programarivm/mumps-examples/blob/master/06-databases/basic-sql-blog/routines/Category.m)\n- [`Comment.m`](https://github.com/programarivm/mumps-examples/blob/master/06-databases/basic-sql-blog/routines/Comment.m)\n- [`Database.m`](https://github.com/programarivm/mumps-examples/blob/master/06-databases/basic-sql-blog/routines/Database.m)\n- [`Post.m`](https://github.com/programarivm/mumps-examples/blob/master/06-databases/basic-sql-blog/routines/Post.m)\n- [`User.m`](https://github.com/programarivm/mumps-examples/blob/master/06-databases/basic-sql-blog/routines/User.m)\n\n---\n\n### Contributions\n\nWould you help make this tutorial better? Contributions are welcome.\n\n- Feel free to send a pull request\n- Drop an email at info@programarivm.com with the subject \"Open MUMPS by Example\"\n- Say hello on [Twitter](https://twitter.com/programarivm)\n\nMany thanks.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogramarivm%2Fmumps-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprogramarivm%2Fmumps-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogramarivm%2Fmumps-examples/lists"}