MUMPS Programming/simple input and output

MUMPS uses the WRITE (abbreviated W) command for output and the READ (R) command for input. Unless specified by the USE (U) command, output defaults to the STDOUT equivalent for the implementation and input from STDIN equivalent.

The USE command redirects the I/O device to other devices. Its syntax varies from implementation to implementation. On older PDP-11 computers running DSM-11, devices were given integer designators. VAX-DSM and other implementations allowed strings to specify host OS devices.

The default device for any particular running instance is always $PRINCIPLE ($P) and most implementations will also accept 0 as the equivalent of $P.

	K Amount,Availablenotes,TMP
	I ($G(^ATM(1000))+$G(^ATM(500))+$G(^ATM(100)))<=0 D
	. W #,!,"There is no money available in this Machine. Sorry for the inconvenience."
	. Q	
	Set Availablenotes=$S($G(^ATM(100)):"100",1:"")
	Set Availablenotes=Availablenotes_" "_$S($G(^ATM(500)):"500",1:"")
	Set Availablenotes=Availablenotes_" "_$S($G(^ATM(1000)):"1000",1:"")
	W #,!,"Only ",Availablenotes," note(s) are available"
	R !,"Enter the Amount :",Amount:60
	I '$T D
	. W !,"Sorry! Time Out!"
	. R TMP#1:5
	. G Exit
	I Amount>10000 D
	. W !,"Please enter an amount less then 10000."
	. R TMP#1:5
	. G Withdraw
	I (Amount#100) D
	. W !,"Please enter an amount in multiples of 100."
	. R TMP#1:5
	. G Withdraw
	I (($G(^ATM(1000))*1000)+($G(^ATM(500))*500)+($G(^ATM(100))*100))<Amount D
	. W !,"Transaction failed"
	. R TMP#1:5
	. G Withdraw
	I (Amount<500)&&($G(^ATM(100))<(Amount#100)) D
	. W !,"Transaction failed"
	. R TMP#1:5
	. G Withdraw
	W !,"Thank you visit again"

; Sundara Moorthy
; Sr. Cache And MUMPS Developer