Giter Club home page Giter Club logo

mumps-examples's Introduction

MUMPS Examples

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...

The implementations currently available are:

The examples in this tutorial are run with GT.M.

Prerequisites

Additional Documentation

GPL Mumps


Quick Setup

To install GT.M on Debian based OS:

apt-get install fis-gtm

Set up the environment variables:

source /usr/lib/x86_64-linux-gnu/fis-gtm/V6.3-003A_x86_64/gtmprofile

Open the GT.M prompt:

gtm

GTM>write "Hello world"
Hello world
GTM>halt

To uninstall GT.M:

apt-get purge fis-gtm

Run the Examples

Copy the example of your choice into $gtmdir/$gtmver/r:

cp -r <your-folder>/mumps-examples/06-databases/basic-sql-blog/* $gtmdir/$gtmver/r

Or alternatively create a symbolic link:

ln -s <your-folder>/mumps-examples/06-databases/basic-sql-blog/*  ~/.fis-gtm/V6.3-003A_x86_64/r

Then run the example:

mumps -run ^Main

1. The Very Basics

Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
1:1 Hello world
1:2 Hello world
1:3 Hello world
1:4 Hello world
1:5 Hello world
2:1 Hello world
2:2 Hello world
2:3 Hello world
2:4 Hello world
2:5 Hello world
There were 7 apples, 8 pears and 9 oranges,
a total of 24 fruits in a basket.
Then, something happened:
1 apple, 2 pears and 0 oranges were eaten!
Now there are 21 fruits in the basket,
the average fruit value is 7.
Approaching the solar system:
Mercury
Venus
Earth
Mars
Jupiter
Saturn
Uranus
Neptune
Pluto

September 2019:
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 1 2 3 4 5 6

Genealogical tree:
Harry and Emily had Jack

Associative array:
Have you ever been to London?

The output obtained is the same as that in Arrays.m

2. Functions

The ASCII code of "a" is 97.
Alphabet:
abcdefghijklmnopqrstuvwxyz
Genealogical tree:
gtree(1)="Oliver"
gtree(1,1)="James"
gtree(1,1,1)="Harry"
gtree(1,1,1,1,1)="Robert"
gtree(1,1,2)="Emily"
gtree(1,2)="Amelia"
gtree(1,2,1)="Thomas"
gtree(1,2,2)="Jessica"

Data about a few nodes:
$d(gtree("foo")) is 0
$d(gtree(1,1,1,1,1)) is 1
$d(gtree(1,1,1,1)) is 10
$d(gtree(1)) is 11
Original string: Hello world!
Substring: Hello

3. Utility Routines

TODO.

4. User Defined Functions

Enter n: 5
5! = 120
Enter n: 5
5! = 120
Enter n: 9
F(9) = 34

5. User Defined Routines

Hello!
Enter n: 9

areaCircle(9) = 254.469
fibonacci(9) = 34
factorialByVal(9) = 362880
factorialByRef(9) = 362880

For further details also visit MyMathRoutines.m

6. Databases

User created:
^users(1)="[email protected]~Alice Jones"

User created:
^users(2)="[email protected]~Bob Smith"

User fetched (1):
data("email")="[email protected]"
data("fullname")="Alice Jones"
data("password")="password"
data("username")="alice"

User updated (1):
^users(1)="[email protected]~Amelia Roberts"

User fetched (1):
data("email")="[email protected]"
data("fullname")="Amelia Roberts"
data("password")="password"
data("username")="amelia"

User deleted (2)

User fetched (2):
data("email")=""
data("fullname")=""
data("password")=""
data("username")=""

Database successfully dropped!

For further details also visit:

Users:
^users(1)="[email protected]~Alice Jones"
^users(2)="[email protected]~Bob Smith"

Categories:
^categories(1)="foo~Foo"
^categories(2)="bar~Bar"
^categories(3)="foobar~Foobar"

Posts:
^posts(1,1,1)="lorem-ipsum~Lorem ipsum~Lorem ipsum dolor sit amet, consectetuer adipiscing elit."
^posts(2,1,1)="donec-pede-justo~Donec pede justo~Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu."
^posts(3,3,2)="curabitur-ullamcorper-ultricies~Curabitur ullamcorper ultricies~Curabitur ullamcorper ultricies nisi."
^posts(4,3,2)="donec-vitae-sapien~Donec vitae sapien~Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante."

Comments:
^comments(1,1)="This is awesome! Thank you."
^comments(2,2)="Thank you so much for sharing this."

Category fetched (3):
data("description")="Foobar"
data("slug")="foobar"

Post fetched (1):
data("description")="Lorem ipsum dolor sit amet, consectetuer adipiscing elit."
data("slug")="lorem-ipsum"
data("title")="Lorem ipsum"

Posts fetched by category (3):
data(3,3,2)="curabitur-ullamcorper-ultricies~Curabitur ullamcorper ultricies~Curabitur ullamcorper ultricies nisi."
data(4,3,2)="donec-vitae-sapien~Donec vitae sapien~Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante."

Posts fetched by user (1):
data(1,1,1)="lorem-ipsum~Lorem ipsum~Lorem ipsum dolor sit amet, consectetuer adipiscing elit."
data(2,1,1)="donec-pede-justo~Donec pede justo~Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu."

Comment fetched (1):
data("description")="This is awesome! Thank you."

Database successfully dropped!

For further details also visit:


Contributions

Would you help make this tutorial better? Contributions are welcome.

  • Feel free to send a pull request
  • Drop an email at [email protected] with the subject "Open MUMPS by Example"
  • Say hello on Twitter

Many thanks.

mumps-examples's People

Contributors

programarivm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.