转到内容

MUMPS 程序设计/简单输入和输出

来自维基百科,开放世界,开放书籍

MUMPS 使用 WRITE(缩写为 W)命令用于输出,并且使用 READ (R) 命令用于输入。除非由 USE (U) 命令指定,否则,输出的内容默认为与实现等效的 STDOUT,输入的内容默认为与 STDIN 等效。

USE 命令将 I/O 设备重定向到其他设备。它的语法因实现而异。在运行 DSM-11 的较早的 PDP-11 计算机上,设备进行了整数标识。VAX-DSM 和其他实现允许字符串指定主机操作系统的设备。

任何特定正在运行的实例的默认设备始终是 $PRINCIPLE ($P),并且大多数实现也将接受 0 作为 $P 的等效项。

ATM
Withdraw
	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
Exit
	W !,"Thank you visit again"
	Q


; Sundara Moorthy
; Sr. Cache And MUMPS Developer
; [email protected]
华夏公益教科书