violin的声音's profile燕南飞之蓝色幻想PhotosBlogListsMore ![]() | Help |
|
燕南飞之蓝色幻想April 27 rtf文件格式资料今天在做rft文件的解析
copy别人一个blog就充一下资料吧
RTF文件格式研究报告(代开版辞)摘要: 本文对RTF文件格式进行分析研究,对RTF文件结构及特性进行了阐述,并分别列举了几个实用性的例子进行详细分析,最终通过VB程序代码实现了一个RTF书写器(不具有所见即所得特性)。本文对软件开发人员及RTF文件格式感兴趣的人员具有参考价值。
关键字:RTF、Rich Text Format、Office、文件格式。
一、引言富文本格式(RTF)规范是为了便于在应用程序之间轻松转储格式化文本和图形的一种编码方法。现在,用户可以利用特定转换软件,在不同系统如MS-DOS、Windows、OS/2、Macintosh和Power Macintosh的应用程序之间转移字处理文档。RTF规范提供一种在不同的输出设备、操作环境和操作系统之间交换文本和图形的一种格式。RTF使用ANSI, PC-8, Macintosh, 或IBM PC字符集控制文档的表示法和格式化,包括屏幕显示和打印。凭借RTF规范,不同的操作系统和不同的软件程序创建的文档能够在这些操作系统和应用程序之间传递。 将一个格式化的文件转换为RTF文件的软件称为RTF书写器。RTF书写器用于分离现有文本中的程序控制信息,并且生成一个包含文本和与之相关的RTF组的新文件。将RTF文件转换成格式化文件的软件则称为RTF阅读器。
二、RTF基本语法RTF文件由未格式化本文、控制字、控制符和组组成。RTF文件没有限制文件的行的最大长度。
控制字是RTF用来标记打印控制符和管理文档信息的一种特殊格式的命令。一个控制字最长32个字符。控制字的使用格式如下:
\字母序列<分隔符>
注意:每个控制字均以一个反斜杠\开头。字母序列由a~z 的小写字母组成。控制字(或者称为关键字)通常应该不包含任何大写字母。
分隔符标记RTF控制字的结束, 可以是下列各项之一:
· 一个空格,这时空格是控制字的一部份。
· 一个数字或连字符(-), 表示跟随的一个数值参数。该数字序列的长度由其后的一个空格或除了字母和数字的其他字符划定。这个参数可以是正数或者负数,它的取值范围通常是从-32767到32767。
· 任何非字母和数字的其他字符。这种情况下,此分隔字符结束控制字,而它并不属于控制字的一部分。
控制符由一个反斜线\跟随单个非字母字符组成。例如,\~代表一个不换行空格。控制符不需要分隔符。
组由包括在({})中的文本、控制字或控制符组成。左扩符({)表示组的开始,右扩符(})表示组的结束。每个组包括文本和文本的不同属性。RTF文件也能同时包括字体、格式、屏幕颜色、图形、脚注、注释(注解)、文件头和文件尾、摘要信息、域和书签的组合,以及文档、区段、段落和字符的格式属性。如果包括字体、文件、格式、屏幕颜色、校订标记,以及摘要信息组、文档格式属性,则他们一定要在文件的第一纯文本字符之前,这些组形成RTF的文件头。如果包括字体组,则它应该在格式组之前。如果组未使用,可以省略。
对于RTF文件的详细语法及关键字说明请参阅《Rich Text Format (RTF) Specification v1.7》,这里不作更详细的说明。
三、Hello Word国际惯例,一个Hello Word!演示例子,内容如下:
{\rtf1\ansi\ansicpg936\deff0\deflang1033\deflangfe2052
{\fonttbl{\f0\fmodern\fprq6\fcharset134 \'cb\'ce\'cc\'e5;}}
{\*\generator Msftedit 5.41.21.2500;}\viewkind4\uc1\pard\lang2052\f0\fs20 Hello World!\par}
该文件分析如下(红色):
1、文件基本属性:
{\rtf1 RTF版本\ansi字符集\ansicpg936简体中文\deff0默认字体0\deflang1033美国英语\deflangfe2052中国汉语
2、字体表:
{\fonttbl{\f0字体0\fmodern\fprq6字体间距为6\fcharset134GB2312国标码 \'cb\'ce\'cc\'e5宋体;}}
3、生成器信息:
{\*\generator Msftedit 5.41.21.2500;}
4、文档属性:
\viewkind4正常视图\uc1单字节\pard默认段落属性\lang2052中国汉语\f0字体0\fs20字体大小20磅
5、正文文本:
Hello World!\par段落标记
}文件结束
注意:在RTF文件中,中文等双字节字符采用其单字节ASCII码序列表示,例如文本“宋体ABC”应该表示为:\'cb\'ce\'cc\'e5ABC,这就是为什么RTF可读性差的原因。如果需要通过程序获取某个字符串的合法ASCII序列,可以采用如下的VB函数:
Public Function StrToASC(ByVal strIn As String) As String
'将中文字符串转换为ASC串(包括英文一起)
'先将特殊字符进行转义:
strIn = Replace(strIn, Chr(9), "\TAB ")
strIn = Replace(strIn, Chr(13) + Chr(10), "\par ")
Dim i As Long, s As String, lsChar As String, lsPart1 As String, lsPart2 As String
Dim lsCharHex As String
For i = 1 To Len(strIn)
lsChar = Mid(strIn, i, 1)
If lsChar = "?" Then
lsCharHex = LCase(Hex(Asc(lsChar)))
If Len(lsCharHex) = 4 Then
lsCharHex = "\'" + Mid(lsCharHex, 1, 2) + "\'" + Mid(lsCharHex, 3, 2)
Else
lsCharHex = lsChar
End If
s = s + lsCharHex
Else
lsCharHex = LCase(Hex(Asc(lsChar)))
If Len(lsCharHex) = 4 Then
lsCharHex = "\'" + Mid(lsCharHex, 1, 2) + "\'" + Mid(lsCharHex, 3, 2)
Else
lsCharHex = lsChar
End If
s = s + lsCharHex
End If
Next
StrToASC = s
End Function June 29 家有新人 明天 我的侄儿就两个星期了,8斤的小孩,一直想为他写点什么
总是没有时间,听他在电话中的哭声,仿佛看到了父亲的微笑 ,母亲
的欢喜,哥哥的兴奋,嫂子的憔悴,辛苦了 ,我们的亲人们,我们在
转转之地终于了新一代的传人。
虽然自己不怎么迷信 ,但是给小孩子取名字还是蛮看中的 ,毕竟这
是我们家的new hope ,邦彦名字好,但是五行不好,博轩很有才气,
也是风水的问题,紫谦,和我们的姓黄色倒是蛮配的,都是高贵之气,
本想用来中和一下运气的,还是觉得彦字不错,俊才亚,五行缺金,挑
选了一个锋字,用测字软件一查,^_^,居然有96分,不错不错,各个
天格地格 人格都都很好,总格也是不错,就选它了 ,彦锋,看不来也不
名字结构也不错。自己都快成天文算术家了(想起了2004年的那些同事
大p了)
btw:哥哥说小名叫根伢子,根者 ,土,俗 ,希望小侄子好养活。
都不错的。 谁是主角巴西对加纳的比赛 ,巴西队好像从来就不越位 ,尤其是第二个球 ,明显第一次传递的时候中路的队员已经是越位了 ,如果说他没有参与进攻 ,可以接收的(类别法国队亨利当时在中路停止了动作 ,里贝里带球打进过程)。但是这个人还在前进 ,接着二次传递 ,又是越位,球进了 虽然加纳的防守不怎么样,但是一次进攻两次越位都没有判罚,天了 世界杯的真正主角们,漂亮的回家了 ,丑陋的在继续,这就是你们要的结果 btw: 昨天晚上没有比赛 ,发现自己晚上看代码效率很高 不是吗? May 26 TO_DATE使用詳解時常使用to_date函數來查詢特定時間內的資料。
但每次都是用別人寫好的語句再改一下日期,一直對TO_date函數的格式不太了解。今看了oracle的書上面to_date函數講的比較好。
語法:
to_data(date&time,format)
其中第一個參數date&time是我們要查詢的具體日期和時間,比如:2006年5月21日。但是這個時間也分為很多種精度的,比如:
2006年5月21日
2006年5月21日17:24
2006年5月21日17:34分55秒
這個精度要根據實際情況來定。
另外一個參數format決定的日期的表示方法,比如:
2006年5月21日 可以表示為:060521、20060521、2006FEB21等等
而他們對應的format為
060521 YYMMDD
20060521 YYYYMMDD
2006FEB21 YYYYMONDD
示例:
select * from book where intime=to_date('2003/02/17/17/53/55','YYYY/MM/DD/HH24/MI/SS')
上面的語句是查詢:2003年8月17日下午5點53分55秒,入庫的書本。
其實用下面的寫法也是可以的
select * from book where intime=to_date('20030217175355','YYYYMMDDHH24MISS')
select * from book where intime=to_date
('2003-02-17-17-53-55','YYYY-MM-DD-HH24/-I-SS')
中間的連字符“/”、“:”或是“-”,並不影響表達,只是為了更加容易看清楚。
表示年份有以下幾種格式,及這種格式對應的表達方法:
2003年為例
YYYY 2003
YYY 003
YY 03
月份表示格式及表達方法:
二月分為例
MM 08
RM IIX(羅馬數字)
MONTH february
MON feb
日期的格式及表達方法:
17號為例
DDD 76 2月的17日在本年度(不是閏年的情況)是多少天
DD 17 在本月中是號(17號)
D 在這一個星期是哪天
星期的格式和表示方法:
星期一為例
DAY monday 全名顯示
DY mon 縮寫
小時的格式和表示方法:
HH24 18 二十四小時制
分鐘的格式和表示方法:
MI 32 該小時32分鐘
秒的表示方法
SS 28 該分鐘28秒
既然知道格式和表示方法就簡單了,比如我想知道在
2005年12月15日18時21分08秒 至
2006年 2月23日19時00分00秒 共入庫多少書本我們就可以用以下語句
SELECT SUM(QTY) FROM BOOK WHERE INTIME BETWEEN TO_DATE('2005/12/15-18:21:08','YYYY/MM/DD-HH24:MI:SS') AND TO_DATE('2006/02/23-19:00:00','YYYY/MM/DD-HH24:MI:SS')
具體使用什麼樣的格式就要看我們的需要和使用習慣了,但這並不影響結果 May 25 你的定位,你的一生--解读IT人员的从业方向 转载一、关于企业计算方向 企业计算(Enterprise Computing)是稍时髦较好听的名词,主要是指企业信息系统如 ERP 软件(企业资源规划)、CRM 软件(客户关系管理)、SCM 软件(供应链管理,即物流软件),银行证券软件财务软件电子商务/政务(包括各种网站),数据仓库,数据挖掘,商务智能等企业信息管理系统. 企业计算领域对人才的需求显然永远是数量最大的因为这是计算机应用最多的领域. 搞这方面的好处是: (1)人才需求量极大从事企业计算的公司在IT企业中占了大多数。除非在专业上一无特长一般在这一领域总能找到工作。 (2)这方面的入门门槛相对较低(如果你的软件功底不是很深可考虑这一领域) (3)这方面的大公司较多大公司要赚大钱所以多将精力花在企业计算业务上.如与正规高校软件学院同学目前实习的CitiCorp、HP、IBM、SAP、NEC等公司都属这一领域的公司。如果将来想到大公司找一份相对稳定的工作,从事这方面机会要大很多。 但从事这一领域的缺点也是明显的: 由于这方面的入门门槛相对较低,虽然这方面的人才需求量是最大的,但将来竞争对手会较多。您会发现,即使他原不是学IT专业的人,也许他突击几个月后,做得照样像模像样。特别是当您年纪渐大后,您可能会发现,后面的年轻人可能很容易追上你的水平。如果您将来到国外去工作,你可能会发现从事这领域的人更多且高手如云。当然,若您在这一领域经过多年企业经验,达到较高境界(如能设计软件架构),则身价永远是高的。国内在这方面人才领域的主要问题是,有经验的高手太少,皮毛了解的人太多。 从事企业计算领域,最重要的技能型技术课程是 (1) J2EE架构与程序设计 (2) 大型数据库系统(如Oracle) (3) 基于UML的系统分析与设计。 如果说还有什么重要的技能,还可将XML与Web Service技术包含进来,若您在这几个领域掌握较好,则不愁找不到工作。其中尤其以J2EE最为重要,目前J2EE已成为企业计算软件开发的最主要平台,也是正规高校软件学院的最重要课程之一。 尽管该课程只能作为选修课,我们希望正规高校软件学院同学无论将来想从事何种方向,都应学一下J2EE课程,至少可为将来找工作备一手关键功夫。包括想从事嵌入式或其它领域的同学,也是很有必要学一下J2EE的,毕竟J2EE是目前最重要的平台之一,即使您将来不想从事企业计算领域,了解一下J2EE也是必要的,就像一门常识课程一样。 其它与企业计算关系较密切的技能还包括: Dot Net架构与程序设计、软件测试技术、软件配置管理,该领域较高层次的技能包括数据仓库技术、构件与中间件技术、设计模式等。像通信协议分析与网络程序设计,Unix系统管理等也属有些关系的课程。02级本学期开设的企业计算课程不多,主要是J2EE、Oracle/MSSQL、UML等企业计算领域的最关键技能型技术课程都已学完了。 您应在空余时间将J2EE,DB、UML等技术再深入地钻研下去,一定要在某个领域有深入的掌握。只是跟着听课,即使学了再多课程也是没用处的,自己钻研下去才是最重要的。只一个J2EE便是博大精深的,足够你啃下去的,钻研下去,您会发现你还要学的相关知识还有很多(包括EJB、XML、Web Service、Design Pattern等)。 在国外,会SAP的人特别值钱。物以稀为贵,这永远是颠扑不破的真理。SAP的价值不仅是因为他是一个ERP软件, 而是其中体现的现代企业管理理念(如根据订货需求自动安排原料采购和生产计划等)。一般500强公司绝不会像国内很多企业那样,用J2EE从头设计企业的ERP系统(即将是怎样的人力投入,而且设计出来的系统怎么可能是完善的),一定都会使用SAP这样成熟的ERP软件。用不起SAP的公司可能会用J2EE设计ERP系统。 这方面的人才之所以稀缺,是因为会大型机的人都是老人(90年代以前搞IT的人),全世界新毕业的IT毕业生不可能再去学IBM大型机(这是一种相对“古老“的技术)没有新人补上而银行的系统必须维持下去而且银行还要不断开发新业务(如新的存款品种)虽然对IBM大型机人才的绝对需求量不很大但相对恒定银行到哪里找这方面的新人很难找到. 若好找花旗软件也不会花那么大的代价去培训我们的实习同学了(去年培训20多个人听说公司就花了数十万元培训费). 如果您将来到国外找工作会IBM大型机可能是最好找工作的领域之一了而且保证找的都是大银行等好工作我以前教过的计算机专业90-94级的一些同学凡是毕业后从事大型机开发的现多在国外一些很好的公司工作(有几位同学在各国各公司跳来跳去简直如履平地). 其实我觉得我们最幸福的同学就是在花旗软件做IBM大型机银行软件的同学这样的机会太难得了.正规高校软件学院00级22班一位同学当初放弃保研看准在花旗软件做大型机并且非常努力还未毕业公司便派她到国外参加一个项目的开发成了项目骨干我觉得她当初选择是完全正确的,01级一位女同学刚刚也自愿放弃了保研机会去花旗做大型机,我们祝愿她将来也能有好的前景。其实像花旗软件主动安排并鼓励员工读在职研究生,这样开明的公司目前并不多的,在职读研也是一种不错的选择,又不会失去自己喜欢的实习工作机会,能兼顾)读书的最终目地还是为了工作. 如果您将来在国外找工作根本没人管您是什么文凭国外企业绝不会花冤枉钱只会招有领域工作经验能立即上手的人用最少的钱在限定的时间完成项目. 而在国内因为人力成本较低公司招聘一很多高学历的人才尽管可能根本用不到这么高的学历但国内的人力太便宜了为什么不高消费一下人才呢这样公司的门面还要好看些。 若不了解处理器原理,怎么能控制硬件工作,怎么能写出节省内存又运行高速的最优代码(嵌入式软件设计特别讲究时空效率),怎么能写出驱动程序(驱动程序都是与硬件打交道的)很多公司招聘嵌入式软件人员时都要求熟悉ARM处理器,将来若同学到公司中从事嵌入式软件开发,公司都会给你一本该设备的硬件规格说明书 (xxx Specification),您必须能看懂其中的内存分布和端口使用等最基本的说明(就像x86汇编一样),否则怎么设计软件。有些同学觉得嵌入式处理器课程较枯燥,这主要是硬件课程都较抽象的原因,等我们的嵌入式实验室10月份建好后,您做了一些实验后就会觉得看得见摸得着。还有同学对ARM汇编不感兴趣,以为嵌入式开发用C语言就足够了。其实不应仅是将汇编语言当成一个程序设计语言,学汇编主要是为了掌握处理器工作原理的。一个不熟悉汇编语言的人,怎么能在该处理器写出最优的C语言代码。 在嵌入式开发的一些关键部分,有时还必须写汇编,如Bootloader等(可能还包括BSP)。特别是在对速度有极高要求的场合(如DSP处理器的高速图像采集和图像解压缩),目前主要还要靠汇编写程序(我看到过很多公司是这样做的)。当您在一个嵌入式公司工作时,在查看描述原理的手册时,可能很多都是用汇编描述的(我就遇到过),这是因为很多硬件设计人员只会写或者喜欢用汇编描述,此时您就必须看懂汇编程序,否则软硬件人员可能就无法交流。很多嵌入式职位招聘时都要求熟悉汇编。 对于急于完成,不想拿嵌入式Linux冒险的开发场合,WinCE是最合适了(找嵌入式Linux的人可没那么好找的),毕竟公司不能像学生学习那样试试看,保证开发成功更重要。根据不同的侧重点 ,WinCE还有两个特殊版本,一个是MS PocketPC操作系统专用于PDA上(掌上电脑),另一个是MS SmartPhone操作系统用于智能手机上(带PDA功能的手机),两者也都属于WinCE平台。在PDA和手机市场上,除WinCE外,著名的PDA嵌入式操作系统还有Palm OS(因出现很早,很有名)、Symbian 等,但在WinCE的强劲冲击下,Palm和Symbian来日还能有多长正规高校软件学院可能是全国高校中唯一一家开设专门的“Windows CE嵌入式操作系统“课程的学校,这主要是基于以下原因:正规高校软件学院本身前面便有Windows程序设计课程,同学学过VC后再学WinCE非常方便自然,通过学习WinCE同样也可了解嵌入式软件的一般开发过程,对Linux有惧怕心理的同学也很合适。 很显然,嵌入式Linux永远不可能替代WinCE,而且将来谁占份额大还很难讲,毕竟很多人更愿意接受MS的平台,就像各国政府都在大力推LINUX已好长时间,但您能看到几个在PC机上真正使用LINUX的用户据我观察目前在嵌入式平台上LINUX是叫得最响但还是WinCE实际用得更多.嵌入式LINUX可能更多地是一些有长远产品计划的公司为降低成本而进行长远考虑 二是微软亚洲研究院对正规高校软件学院WinCE课程的支持计划,我们也很希望将来正规高校软件学院能有同学通过微软的面试去实习。WinCE和多媒体(如MPEG技术)是微软亚洲工程院目前做得较多的项目领域之一他们很需要精通WinCE的人。 失落在数字时代的纸牍书信 某天午饭时,朋友给我讲述了一件令人感伤的事情:她无意中发现了一个破旧的手提箱,里面装满了她母亲的各种来往信函。这的确是一个宝库,里面是她父亲珍藏的情书、贺年卡、照片及航空信函,这个手提箱已在柜子中沉睡了几十年。她的母亲在她5岁时就离开了人世。对我的这个几乎已把母亲忘记了的朋友来说,这是一段心路历程,母亲的生活和致命的疾病一幕幕从她的脑海里闪过。当我倾听她的故事并小心翻看著一位40年前去世的女人的照片时,我不禁想到我自己:天啊,我们到底做了些什么? 我的内心正在激烈地交战。一方面,作为技术爱好者而言,我感觉到了通讯领域的巨大进步。另一方面,作为不合格的历史学家,我担心我们并未真正意识到数字化、互联网和电脑的兴起究竟给人类的交流和值得记忆的历史给带来了何种程度的破坏。一方面,我能通过互联网穿越空间阻隔、同远在十几个时区外的兄弟经常免费地交流。另一方面,自1991年我迷上互联网以来就再也没有给他写过信。当然,我们彼此写电子邮件,发送讯息,有时甚至相互交谈。我们比以往更多地出现在彼此的生活中,至少是在彼此生活的边缘。但由于是即时交流,所以交谈内容都是随意的,很快就会忘记。因此每次对话都是这样开始的:“我们上次谈过这个吗?我们以前都同意这点吗?”这更像是员工会议,而不是家庭聚会。 而且,也没有了那种心跳的感觉──没有航空邮件以及异国他乡的邮票和邮戳的到来,没有了小心翼翼地打开信封,也没有了轻轻地展开信纸。现在,用鼠标点一下绿色按钮就可开始交谈,很快也会忘记我们谈过些什么。同大多数互联网上的交流一样,我们沟通的质量显然同沟通的便利程度成反比。 不仅仅是质量的问题:还有保存的问题。未来的几代人将不会对我们的创造能力拍案叫绝;他们将会对我们远离书写和打印的模拟时代,轻易地进入数字时代感到震惊;在数字时代,一切都是以数字形式保留下来的,要么就再也看不到踪影了。在不到20年的时间里这些都变成了现实。当我80年代末生活在曼谷时,我都是用手动打字机书写所有的信件,用薄薄的黄纸复制一份,因为许多信件可能会在途中丢失。我收发的这些信件比我在互联网时代之后所写的任何信件都更接近于我朋友母亲的信函。 作为不合格的历史学家,我一直保留著各种这些双向交流的记录,包括写给我的所有信件、生日贺卡和明信片。我仍保留著这些,尽管它们已经非常脆弱而无法扫描进我的电脑中,但却非常具有价值,而不能扔掉,这令我的太太深为不满。当然,自进入互联网时代以来,保存此类财富的工作就变得更加简单了,因为需要保存的非数字化信息非常少。但我的感觉却并不好。首先,浏览过去的电子邮件或数码照片在感觉上就不如传统的信件或照片。其次,不是所有的数字内容都得到平等的对待:我们的网上对话能够永远保留下来,但看来我们并不想这样做,比如,你是否尝试将一个重要的短信息保存到安全的地方?今后的人们会比我们更加清楚地意识到我们的生活从实物时代转向数字时代时所发生的巨大困惑。 我并不是说这样不好。能够迅速方便地接触到我们所爱的人的确很好。我相信仍由许多人仍像我朋友的母亲那样亲手写信。其中一些人肯定并未受到网络媒介本身的影响,电子邮件也写得长而深刻。但我们这代人可能是将财富保留在箱子中的最后一代人了,将要消失的不仅仅是信中的文字,还有个人信件带来的气味、感觉、触觉,以及所属的那个时代。下一代人面临的挑战可能是找到一种箱子的替代品。眼下,我建议你认真保留和备份好你的电子邮件、照片和视频内容,把它们作为数字传家宝看待。即使你已经离不开数字装备了,也可以偶尔给妈妈或孩子写封信,或是发张明信片。 May 23 M Technology and MUMPS Language FAQ, Part 2/2 续Appendix 6: An example of "textbook" M coding styleThis is based on an example from a well-known M textbook, "The Complete MUMPS" by John Lewkowicz. It shows how M can support a "modern" appearance and coding style. See notes below for more detail. 1 zsample ;dpb;09:18 PM 6 Aug 1994
2
3 ;Test the Stats routine:
4 ;Calculate 1000 points w. approx. Gaussian distribution,
5 ;then call Stats on the result
6 ;Execution time: 5 seconds with DTM on a 33 MHz 386DX
7
8 New Data,i,j,output
9 For i=1:1:1000 Set Data(i)=$$Normal
10 Do Stats("Data",.output)
11 Write !,output
12 Quit
13
14 ;----------------------------------------
15 ;Based on Lewkowicz, "The Complete MUMPS," examples 9.15-9.17
16 ;Modified slightly:
17 ;Used argumentless Do instead of two If's for Num>1 block
18 ;Corrected calculation of the standard error
19 ;----------------------------------------
20
21 Stats(Ref,Results) ; Calculate simple Statistics on Array nodes
22 New High,i,Low,Mean,Num,StdDev,StdErr,s,Sum,SumSQ,Var
23 Set High=-1E25,Low=1E25,(Sum,SumSQ,Num)=0,s=""
24 For Set s=$O(@Ref@(s)) Q:s="" Do StatsV(@Ref@(s))
25 If 'Num Set Results="" Goto StatsX
26 Set Mean=Sum/Num
27 Set (StdDev,StdErr,Var)=""
28 If Num>1 Do
29 . Set Var=-Num*Mean*Mean+SumSQ/(Num-1)
30 . Set StdDev=$$SQroot(Var)
31 . Set StdErr=StdDev/$$SQroot(Num)
32 Set Results=Num_";"_Low_";"_High_";"_Mean
33 Set Results=Results_";"_Var_";"_StdDev_";"_StdErr
34 Goto StatsX
35 StatsV(Val) ;Process an individual value
36 Set Val=$$NumChk(Val) Quit:Val=""
37 Set Num=Num+1,Sum=Sum+Val,SumSQ=Val*Val+SumSQ
38 Set:Val"<"Low Low=Val Set:Val">"High High=Val
39 Quit
40 StatsX Quit
41
42 SQroot(Num) ;Return the SQUARE ROOT of abs(Num)
43 New prec,Root Set Root=0 Goto SQrootX:Num=0
44 Set:Num<0 Num=-Num Set Root=$S(Num>1:Num\1,1:1/Num)
45 Set Root=$E(Root,1,$L(Root)+1\2) Set:Num'>1 Root=1/Root
46 For prec=1:1:6 Set Root=Num/Root+Root*.5
47 SQrootX Quit Root
48
49 NumChk(Data,Range,Dec) ;Check for valid NUMBER
50 Set Data=$TR(Data,"+ $,")
51 Goto NumChkE:Data'?.E1N.E,NumChkE:Data'?."-".N.".".N
52 If $D(Dec),Dec?1N.N g NumChkE:$L($P(Data,".",2))>Dec
53 Set:'$D(Range) Range="" Set:Range="" Range="-1E25:1E25"
54 If $P(Range,":")'="" Goto NumChkE:Data<$P(Range,":")
55 If $P(Range,":",2)'="" Goto NumChkE:Data>$P(Range,":",2)
56 Set Data=+Data Goto NumChkX
57 NumChkE Set Data=""
58 NumChkX Quit Data
59 ;
60 ;----------------------------------------
61 ;
62 ;Part of demo/test code, Dan Smith, 8/26/94
63 Normal() ;Return random # with approximately Gaussian distribution
64 New i,x,n ;n=# iterations
65 Set x=0,n=3 ;Higher n = slower, better Gaussian approximation
66 ;$random(1201) has approx. mean=600, variance=120000
67 For i=1:1:n*n Set x=x+$random(1201)-600
68 Set x=x/(346.4101615*n) ;variance now 1
69 Quit x
[Lines 21-58 are from Examples 9.15, 9.17 and 9.18 of "The Complete MUMPS," by John Lewkowicz, ISBN 0-13-162141-6, 1989, Prentice-Hall, Englewood Cliff, New Jersey and are copyright 1989 by Prentice-Hall, Inc. Permission to use these examples has been solicited from Prentice-Hall, but no reply has been received. This Appendix may be modified or omitted in future versions if Prentice-Hall objects to its inclusion] . Notes: Line 8: Command names: Command names in M are case-insensitive, and may either be spelled out in full or abbreviated to a single character. Thus, the NEW command could be written as "NEW" or "New" or "new" or "N" or "n". Lewkowicz consistently spells them out in full, with mixed case. NEW command: This is not a declaration, but an executable command. In M, this is the way you effectively make a variable private to a subroutine. On entry to zsample, the variables Data, i, j, and output may or may not have values. The New command stacks the old identity of these variables, which now become undefined. zsample may freely use the variables. On Quit-ing from the subroutine, any values the subroutine established for them are discarded and the old values restored. It is good practice to New the variables used for temporary storage within a subroutine, and some programmers do this systematically. Lewkowicz does it, and alphabetizes the order of the names in the New list to make maintenance easier. Lines 8, 10, and 21: Passing an array reference as an argument. "Stats" is a subroutine which takes a parameter list. It is designed to work generally using any array, local or global, or array reference. The argument that is passed is a string; here, the string "Data", which names a local array. Within the subroutine, the "subscript indirection" mechanism is used; i.e. because Ref has been set equal to the string "Data", the expression @Ref@(s) refers to Data(s). If Ref were set to "^Permanent", the expression @Ref@(s) would refer to ^Permanent(s). Ref could also be set to an array subnode. Line 28: An "argumentless DO." This structure causes the set of lines beginning with periods to be executed. Argumentless "DO's" can be nested. They stack and restore the value of $T. Using these tools it is possible to write nested "If-Else" structures that behave as expected.
Appendix 7: An example of "traditional" M coding style%DTC
%DTC ; SF/XAK - DATE/TIME OPERATIONS ;1/16/92 11:36 AM
;;19.0;VA FileMan;;Jul 14, 1992
D I 'X1!'X2 S X="" Q
S X=X1 D H S X1=%H,X=X2,X2=%Y+1 D H S X=X1-%H,%Y=%Y+1&X2; K %H,X1,X2 Q
;
C S X=X1 Q:'X D H S %H=%H+X2 D YMD S:$P(X1,".",2) X=X_"."_$P(X1,".",2) K X1,X2 Q
S S %=%#60/100+(%#3600\60)/100+(%\3600)/100 Q
;
H I X<1410000 S %H=0,%Y=-1 Q
S %Y=$E(X,1,3),%M=$E(X,4,5),%D=$E(X,6,7)
S %T=$E(X_0,9,10)*60+$E(X_"000",11,12)*60+$E(X_"00000",13,14)
TOH S %H=%M>2&'(%Y#4)+$P("^31^59^90^120^151^181^212^243^273^304^334","^",%M)+%D
S %='%M!'%D,%Y=%Y-141,%H=%H+(%Y*365)+(%Y\4)-(%Y>59)+%,%Y=$S(%:-1,1:%H+4#7)
K %M,%D,% Q
;
DOW D H S Y=%Y K %H,%Y Q
DW D H S Y=%Y,X=$P("SUN^MON^TUES^WEDNES^THURS^FRI^SATUR","^",Y+1)_"DAY"
S:Y<0 X="" Q
7 S %=%H>21608+%H-.1,%Y=%\365.25+141,%=%#365.25\1
S %D=%+306#(%Y#4=0+365)#153#61#31+1,%M=%-%D\29+1
S X=%Y_"00"+%M_"00"+%D Q
;
YX D YMD S Y=X_% G DD^%DT
YMD D 7 S %=$P(%H,",",2) D S K %D,%M,%Y Q
T F %=1:1 S Y=$E(X,%) Q:"+-"[Y G 1^%DT:$E("TODAY",%)'=Y
S X=$E(X,%+1,99) G PM:Y="" I +X'=X D DMW S X=%
G:'X 1^%DT
PM S @("%H=$H"_Y_X) D TT G 1^%DT:%I(3)'?3N,D^%DT
N F %=2:1 S Y=$E(X,%) Q:"+-"[Y G 1^%DT:$E("NOW",%)'=Y
I Y="" S %H=$H G RT
S X=$E(X,%+1,99)
I X?1.N1"H" S X=X*3600,%H=$H,@("X=$P(%H,"","",2)"_Y_X),%=$S(X<0:-1,1:0)+(X\86400),X=X#86400,%H=$P(%H,",")+%_","_X G RT
D DMW G 1^%DT:'% S @("%H=$H"_Y_%),%H=%H_","_$P($H,",",2)
RT D TT S %=$P(%H,",",2) D S S %=X_% I %DT'["S" S %=+$E(%,1,12)
Q:'$D(%(0)) S Y=% G E^%DT
PF S %H=$H D YMD S %(9)=X,X=%DT["F"*2-1 I @("%I(1)*100+%I(2)"_$E("><",X+2)_"$E(%(9),4,7)") S %I(3)=%I(3)+X
Q
TT D 7 S %I(1)=%M,%I(2)=%D,%I(3)=%Y K %M,%D,%Y Q
NOW S %H=$H,%H=$S($P(%H,",",2):%H,1:%H-1)
D TT S %=$P(%H,",",2) D S S %=X_$S(%:%,1:.24) Q
DMW S %=$S(X?1.N1"D":+X,X?1.N1"W":X*7,X?1.N1"M":X*30,+X=X:X,1:0)
Q
COMMA ;
S %D=X<0 S:%D X=-X S %=$S($D(X2):+X2,1:2),X=$J(X,1,%),%=$L(X)-3-$E(23456789,%),%L=$S($D(X3):X3,1:12)
F %=%:-3 Q:$E(X,%)="" S X=$E(X,1,%)_","_$E(X,%+1,99)
S:$D(X2) X=$E("$",X2["$")_X S X=$J($E("(",%D)_X_$E(")",%D+1),%L) K %,%D,%L
Q
HELP S DDH=$S($D(DDH):DDH,1:0),A1="Examples of Valid Dates:" D %
S A1=" JAN 20 1957 or 20 JAN 57 or 1/20/57"_$S(%DT'["N":" or 012057",1:"") D %
S A1=" T (for TODAY), T+1 (for TOMORROW), T+2, T+7, etc." D %
S A1=" T-1 (for YESTERDAY), T-3W (for 3 WEEKS AGO), etc." D %
S A1="If the year is omitted, the computer "_$S(%DT["P":"assumes a date in the PAST.",1:"uses the CURRENT YEAR.") D %
I %DT'["X" S A1="You may omit the precise day, as: JAN, 1957" D %
I %DT'["T",%DT'["R" G 0
S A1="If the date is omitted, the current date is assumed." D %
S A1="Follow the date with a time, such as JAN 20@10, T@10AM, 10:30, etc." D %
S A1="You may enter a time, such as NOON, MIDNIGHT or NOW." D %
I %DT["S" S A1="Seconds may be entered as 10:30:30 or 103030AM." D %
I %DT["R" S A1="Time is REQUIRED in this response." D %
0 Q:'$D(%DT(0))
S A1=" " D % S A1="Enter a date which is "_$S(%DT(0)["-":"less",1:"greater")_" than or equal to " D %
S Y=$S(%DT(0)["-":$P(%DT(0),"-",2),1:%DT(0)) D DD^%DT:Y'["NOW"
I '$D(DDS) W Y,"." K A1 Q
S DDH(DDH,"T")=DDH(DDH,"T")_Y_"." K A1 Q
;
% I '$D(DDS) W !," ",A1 Q
S DDH=DDH+1,DDH(DDH,"T")=" "_A1 Q
[NOTE: this example is extracted from VA FileMan Version 19.0. There is no copyright notice in the text of the source code or any of the accompanying documents; FMANPROG.TXT and FMANUSER.TXT each specifically contain the statement "VA FileMan is a public domain software package that is developed and maintained by the Department of Veterans Affairs." I therefore believe no permission is required to reproduce this passage.--Daniel P. B. Smith]
Appendix 8: Mumps, A Solution Looking For A Problem By Chris RichardsonThis article on MUMPS appeared in an old issue of a computer newsletter Mumps, A Solution Looking For A Problem By Chris Richardson (Copyright (c) 1993 Personal Systems, the monthly journal of the San Diego Computer Society; all rights reserved. Permission to reproduce this article is granted to other non-profit organizations such as computer user groups for non-commercial use as long as credit to the author and group is given and provided a copy of the newsletter is sent to us at: San Diego Computer Society, ATTN: Editor, Personal Systems; 5694 Mission Center Road; Suite 602, Box 350; San Diego, CA 92108) What is MUMPS? Is it a programming language that thinks it is a database, or is it a database that thinks it is a programming language? What does that mean to anyone who is knocking out little applications on a home PC or Apple? Well, the nice thing about an ANSI Standard language is that the code you write on the Apple in standard MUMPS transports nicely to the IBM PC without any change. And if that other system is a mainframe, like a Vax or a large IBM system, your application will work there also. Where did MUMPS come from and what does MUMPS stand for? If it was written by a hospital, does it only do hospital problems? It was designed to solve the problem of tracking patient data. How does patient data differ from auto supply inventory or a check book? A patient can have many attributes that describe each encounter. For instance, suppose a patient gets admitted to a hospital with a traditional square record database, and is known to have six allergies, but there is only room for five allergies in the record. Which allergy will you elect not to record? If this patient dies because of that one allergy that you did not record, your hospital may change ownership in settling his estate. For the majority of patients, the space reserved for the five allergies will not be used and is wasted space. That means that your hospital will be buying more disk space a lot sooner. In the MUMPS environment, the database disk space is not allocated until it is needed (run-time). This means that the patient record expands to fit the amount of data required for that patient. If the space is not used, it is not allocated. If you have 12 patients in your database, you have only the space for these 12 records allocated. In most traditional databases, you must allocate as many records as you expect before the first record is allocated. With MUMPS, many databases can be described but they will not take up any space until actual records are created. There is no theoretic maximum number of records that a specific database can contain. It is only bound by the actual amount of disk space that is available to be assigned. Talk about getting 10 pounds in a 5 pound sack. Many database environments already exist for the PC, why should you be interested in another? MUMPS is unlike most other databases in that it is also a special type of programming language called an interpreter. OK, we hear the moans from the BASIC programming crowd. And did you think you got rid of interpreters when BASIC compilers came out. Well, you didn't. Interpreters don't have to be slow and most database environments actually do go interpretive when they service user queries. Anyway, even if the MUMPS interpreter was slow (which it isn't) the levels of run-time and error-time support is worth the difference. When a MUMPS application stops for some reason, the symbol table remains intact at the line of code being executed when the error occurred. In the event of an error, control may be passed to another routine to capture the conditions of the failure or even attempt to recover from the error condition. Traditionally, MUMPS database applications have a short mean-time-to-repair (MTTR) of just a few minutes and a long up-time record. Also, in many cases, the application that blew up can be re-started from where it left off. What does MUMPS look like? Most MUMPS commands may be abbreviated to a single character. Or spell them out if you choose. Code generation is quick. MUMPS commands can be easily combined to form more complex and complicated structures. Each line of code is a block of code. MUMPS makes little distinction between data and code. Code can be created and executed from a database or the symbol table at run-time. Data can be stored in a routine and accessed at run-time. MUMPS is a sparse matrix array processor. This means that arrays are allocated at run-time; the arrays may be created in any order. Array element 1000000 can be created and then element 2 can be created and yet the array only has 2 elements in it. Because there are only string data types, the subscripts of a MUMPS array are strings. What a concept! You can subscript an array by "APPLES" and "ORANGES", and "AVOCADOS". Now for the good news, when those subscripts are created, they are sorted alphabetically. MUMPS means never having to say you're sorting. The language is still growing. Every ANSI Standard has a built-in sunset of seven years. That means that if nothing is done with a standard in seven years, it ceases to be a standard. Well, MUMPS has had an ANSI standard for 1977, 1984, 1990, and the MUMPS Development Committee is attempting to release a 1993 standard. Additional standards for WINDOWING, Networking, and Transaction Processing are currently in process. MUMPS is transportable. It doesn't matter if MUMPS code is running under MS-DOS, Windows NT, UNIX, VMS, VM, or nearly any operating system you might mention, the code and database will still run. In fact, in some implementations MUMPS is also the operating system. Who uses MUMPS? Is it just for hospitals? No, MUMPS is an excellent choice for nearly any database operation, especially if not every aspect of the situation is known. MUMPS is being used by banks and credit unions. Do you travel on airlines? You have probably been scheduled on a MUMPS system. All of the postage stamp sales for the U.S. Postal Service are tallied on a MUMPS system each evening. Auto parts houses keep track of their inventories with MUMPS systems. Language translators have been implemented in MUMPS and it also works well with artificial intelligence projects. If MUMPS was developed here, is it only used in this country? If MUMPS is so good, why haven't I heard of it? When a MUMPS implementation is installed to replace an existing traditional system, usually there are sufficient resources for the MUMPS environment, with plenty of resources left for future expansion. Alright, I'm sold. Where can I get MUMPS for my system? By the way, there is extensive documentation available for this product. There is a MUMPS Users' Group (now called the M Technology Association) which can be contacted at: The free MUMPS evaluation copy is available by calling Tati Goodnough, the product manager for DataTree's DT-Student at (617)-890-2082 (She is a nice lady. Don't pass up the opportunity to talk to her.) or write her at: [Editors Note: Old Address - see other sections of this FAQ] (Author Profile: Chris Richardson is a Software Engineer with Science Applications International Corporation in San Diego and is a member of the MUMPS Development Committee, the ANSI Standards writing organization for the MUMPS language. He has worked for NASA, the U. S. Public Health Service, the U. S. Navy, Army, and the Air Force as well as Computer Sciences Corporation and Singer-Link in Houston. He has taught Real-time FORTRAN and MUMPS to professionals in the industry and government). Appendix 9: Tributes, Accolades and Honorable Mentions outside the M CommunityThis section is dedicated to mentioning articles, white papers, research, et al that is no produced by the M Community, but by someone in the "Real World". I will accept submissions of articles, pointers, etc. for published matertials (electronic or physical) as of 1/1/96 on. Older submissions may be included if they are of a unique, or highly informative nature. I. Computer Language Rating Table: Try looking at http://www.spr.com/library/langtbl.htm. It contains a language ranking, based on the amount of effort required to code a function point and M ranks very well. Appendix 10: Contact information: E-mail and URL addresses:This document contains url's and addresses that were acurate at the time of the original inclusion. URL's and e-mail addresses change however, and will (when notified) be reflected in Appendix 10. So, if you wish to reach a contributor, confirm addresses there. Ellis A. Bauman, <ellis.bauman@AUP.WISC.EDU> Ben Bishop, aci@shore.net Dennis J Brevik, <dbrevik@ix.netcom.com> Etienne Cherdlu, <gz64@cityscape.co.uk> Floyd Dennis, <fbdennis@mindspring.com> Jon Diamond, jon.diamond@capemini.co.uk Rod Dorman, <rodd@panix.com> John D. Godfrey, Godfrey@msmail.vet.cornell.edu Gavin Greig, ggreig@mcs.dundee.ac.uk Russell Haddleton, rfh2y@uvacs.cs.Virginia.EDU Lev Jacob, <lev@TRENDLINE.CO.IL> Scott P. Jones, scott@INTERSYS.COM John E. Kemker, III, kemker.j@atlanta.va.gov Mark Komarinski, komarimf@craft.camp.clarkson.edu Monika Kratzmann, <monika@INTERSYS.COM> Jeff Loeb, LOEB.JEFFREY_L@san-diego.va.gov Keith F. Lynch, kfl@access.digex.net Jim McIntosh, <jim@american.edu> Ed de Moel, DEMOEL@saltmine.radix.net Steve J. Morris, sjm2@shore.net Kevin O'Gorman, kevin@kosman.uucp Paul Perrin, <Admin@admatic.com> Doug Preiser, preiser@cancer.unm.edu Harold Pritchett, <harold@UGA.CC.UGA.EDU> Aaron Seidman, seidman@world.std.com Kate Schell, cschell@radix.net Tilman Schmidt, ts@gb1.sema.de Arthur B. Smith, ART@vets.vetmed.missouri.edu Daniel P. B. Smith, <dpbsmith@world.std.com> Richard J. Tomlinson, Richard@rtsysgen.demon.co.uk Gardner Trask, trask@world.std.com David Whitten, whitten@netcom.com Appendix 11: FAQ Change HistoryChanges since version 1.3: 10/1/96
Changes since Version 1.2: 07/01/96:
Changes since Version 1.1: 01/01/95:
M Technology and MUMPS Language FAQ, Part 2/2M-FAQ HTML version prepared by Dan Baer Archive-name: m-technology-faq/part1 Last-modified: 1997/08/01 Version: 1.6 Posting-Frequency: monthly M Technology and MUMPS Language FAQ This FAQ is copyright ©1997 by Gardner S. Trask III. All rights reserved. Permission is granted for this FAQ to be redistributed provided:
Post comments or suggestions to comp.lang.mumps or email to trask@world.std.com . Editors
Contents of Part 2:
Appendix 1: List of M Vendors[1/08/95] InterSystems has acquired Digital's DSM product line. Digital Equipment Corporation was formerly listed first (alphabetically) in this section. According to material published by InterSystems corporation on 1/2/95, specifically the files dsmpr.txt, dsmqam.txt, and dsmlet.txt in their public FTP area, "Digital Equipment Corporation and InterSystems have formed a strategic partnership to expand the worldwide use of M Technology, particularly in the enterprise client/server arena. Simultaneously, InterSystems has acquired the DSM software product line, Digital's implementation of M." "DSM will be marketed and sold by InterSystems' world-wide network of direct sales staff and distributors. In addition, Digital will continue to sell DSM in Japan and to certain customers under existing multi-year contracts." dsmqam.txt lists the following contacts for more information: InterSystems Corporation Micronetics Design Corporation Extensao Informatica e Tecnologia Greystone Technology Corporation Digital Equipment Corporation International Business Machines MGlobal International, Inc. MUMPS Systems Laboratory Patterson, Gray and Associates PFCS Corporation VISO-DATA Computer Appendix 2: The M Technology AssociationFor current pricing information, please contact the relevant group. Membership for almost all MTAs includes:
MTA-North America also provides
Other MTAs provide additional services. For example M Professional (technical journal from MTA-Europe). M Technology Association MTA-Europe: Association Headquarters There are also MTAs in Belgium, Brazil, Bulgaria, China, Czech/Slovak Republics, Finland, France, Germany, Great Britain, Ireland, Israel, Italy, Japan, Netherlands, Russia, Spain, Switzerland. Please contact either of the above addresses for current information. You can get a list of MTA's around the World at the MTRC website. Appendix 3. USA Local M Users GroupsA current list of M User Groups in the US can be found at the MUMPS of Georgia website. If you need to add or change your User Group info, please fill out the form or email mga@mindspring.com Appendix 4: Is the official name of the language "M" or "MUMPS?"This is the M community's very own little religious war. Not everyone prefers the name M. Many feel strongly about the issue. Ed de Moel says that "within the M[UMPS] community, there is a strong sentiment that MUMPS is not the right name for the language; there is an (equally?) strong sentiment that MUMPS is a better name than any of the proposed alternatives." All of the following opinions can and have been supported:
The following samples show the diversity of opinions. I have given Ed de Moel, a member of the MUMPS Development Committee, the last word. (However, it is possible to find other views within the MDC membership). [DPBS] I'm curious as to how long it will take "M" to fully replace "MUMPS". I was disappointed that [comp.lang.mumps] wasn't created with that name. [Russell Haddleton, rfh2y@uvacs.cs.Virginia.EDU] The name of the language is MUMPS. 'M Technology' is a marketing ploy that ignores the language; what it's called doesn't change what it IS. (The MDC has NOT changed the name of the language as far as I know -- they permitted M as an alternate name) [Ben Bishop, aci@world.std.com] The name of the group should be comp.lang.m. I understand the issue of "grep'ing" on M prohibitive, but I can't see throwing out all the hard work of the MTA. M is the name. [Gardner Trask, trask@world.std.com] DSM stands for Digital Standard M now. In recent advertising DataTree refers to their product as DataTree M. I thought the official name of the language was M too, but this is not the case. The primary name for the language is still MUMPS. The ANSI standard refers to the language as MUMPS with M as an alternate name. The M Technology Association decided to use M as the primary _reference_ to the language MUMPS. [Doug Preiser, preiser@cancer.unm.edu] Can anyone think of something you can do in some other language that you can't do in MUMPS ? Well, let's try using 'M' instead of MUMPS for a start, before any XJ-11 people start flaming. [Richard Nason, rick@rnason.demon.co.uk] M is a well-accepted nickname for a programming language called MUMPS. MUMPS, in turn, is an acronym that stands for Massachusetts (General Hospital) Utility Multi Programming System. MUMPS is a language that goes by many names. Since a number of years, there has been a strong movement to change the name of the language to something else than MUMPS, countered by an equally strong movement to keep the name as is was. The first official request to change the name of the language to "M" was in 1980, when Terry Ragon (now president of InterSystems) wrote a letter to the MUMPS Development Committee, requesting this change. At that moment in time, it was decided to keep the name MUMPS, but the movement to change the name did not disappear. Over the years, there has been a number of informal requests to change the name of the language, but, oddly, there never was a formal proposal to do this before the MUMPS Development Committee (the only body that can change the name of the language). The only thing that happened officially was that the nickname "M" became accepted as an alternate name. The language is still officially called MUMPS. Other official designations are ANSI X11.1 (1990) and ISO 11756 (1991). Several of the user's groups have adopted the nickname, and changed their name to reflect that adoption, so we now have a MTA (USA), MTA-Japan, MTA- Europe, but Germany uses MUG-Deutschland (M Users Group) and Soyuz-DIAMS in Russia. The most recent formal resolution that was passed by the MUMPS Development Committee regarding the name was to use the nickname throughout the document that is currently being circulated through the canvass process as the new draft ANSI standard. Evidently, this strongly promotes the use of the nickname over the 'real' name, but it still doesn't change the name of the language. Maybe one day, someone will submit a formal proposal to the MUMPS Development Committee, but until such a proposal is submitted and favourably voted upon, "M" will remain a (well accepted) nickname for MUMPS. [Ed de Moel, demoel@saltmine.radix.net] Appendix 5: A "secret decoder ring:" highlights of the M languageThis incomplete, informal sketch seeks to give programmers familiar with other languages a feeling for what M is like. It doesn't tell you enough to write M code; it may help you to read it. Neither the language description and the descriptions of each feature are complete, and many very significant features have been omitted for brevity.
COMMANDS:
OPERATORS:
INTRINSIC (built-in) FUNCTIONS:
Convenience functions similar to library functions in other languages:
[DPBS] M Technology and MUMPS Language FAQ, Part 1/2续Does M support Microsoft Windows and other GUI's?A 1994 addition to the M standard, the M Windowing API (MWAPI), defines an interface between the M language and windowing systems. InterSystems and Micronetics offer versions of M that implement the MWAPI in a Microsoft Windows environment. Digital has an implementation [is it commercially released? Details?] for Windows NT. The M Windowing API and its commercial implementations are relatively new and have rough edges. The MWAPI has the advantage of portability and platform-independence, but has some limitations associated with the "least- common-denominator" approach. A unique feature of the MWAPI is that this "API" does not consist of subroutine calls (except for a few incidental functions). MWAPI programming consists mainly of performing sets and kills into a "structured system variable," which looks like a standard M global. For example, to set the title of a window to "M Technology Demonstration," you write
To make its dimensions 300 by 200, you write
The MWAPI is currently offered for Microsoft Windows by InterSystems and Micronetics, and for Windows NT by Digital Equipment Corporation. It is often presented as the windowing future for M technology. VISUAL-BASIC-LIKE APPROACHES InterSystems' "Visual M" is a set of tools which link M with Microsoft Visual Basic, creating an integrated dual-language environment. M code can be accessed and edited from within the VB design environment, can access VB control properties, and can be triggered by VB events. Micronetics [product name????] provides a Visual-Basic-like environment entirely based on M and the MWAPI. "WRITE-SLASH" APPROACHES InterSystems' "DT-Windows," MGlobal's MGM-PC (for MS-Windows) and MGM-Mac (for the Macintosh) use a feature of the M standard that allows the language to be extended for device-specific purposes by means of the "write-slash" syntax. In DT-Windows and MGM, the windowing system is treated as a "device" with an unusually rich repertoire of device-specific commands. Although DT-Windows and MGM are conceptually similar, they are incompatible with each other. They are ad-hoc language extensions. Neither seems to have set a defacto standard. Why do these products (DT-Windows and MGM) provide a nonstandard approach? The answer, in part, is that they were introduced prior to the finalization of the MWAPI standard. Why do they still exist? Because they are closer to their underlying windowing platform than the MWAPI, they arguably provide better performance and broader access to the GUI system's functionality. Examples from the DT-Windows manual and MGM product literature, respectively, show how an "OK" button is added to a dialog box: Are there any M magazines or journals?The M Technology Association publishes "M Computing," a technical journal. Members receive it free. See Appendix 2. MTA-Europe publishes "M Professional" a news/technical journal in English 3 times a year. MTA-Europe members receive it free. Non-members can order a subscription. Other MTAs also produce newsletters, mostly in local languages. Contact them directly for more information. Which is the "official" name, M or MUMPS?This topic seems to be the M community's very own little religious war. The following represents the editor's opinion. Other views, including one from a member of the MUMPS Development Committee, are represented in Appendix 4. M and MUMPS are alternate names for the same language. M, the newer name, is now very widely accepted in the M community. The name change was introduced to address long-standing problems with the name MUMPS. The name MUMPS gave many the impression that the language was specifically for hospitals and health care applications. Many also felt it was undignified. M/MUMPS has evolved rapidly, with new ANSI standards being successfully issued in 1977, 1984, 1990, and a new standard now in canvass, which will probably issue in 1995. It is not the same language that it was in 1967. [DPBS] Is M a mainstream language?1991 worldwide revenue in the M marketplace was estimated at $1 billion, projected to grow to $2 billion by 1996. Approximately 2,000 individuals/organisations belong to M Technology Association-North America, with approximately another 1,000 belonging to other MTAs. Versions of the M language are available from twelve vendors on every significant hardware platform. Some versions provide direct support for non- English languages, for example German, Russian, Japanese. But: "The national meeting of the MTA draws fewer attendees than the northeast regional meeting of the SAS Users' Group." [Thomas C. Salander, M Computing, June 1994, p. 72]. Is M useful for non-medical applications?Although it originated in a medical environment, nothing in the language is specific to medical applications. Non-medical applications can be, and have been, implemented successfully in M. The Gartner Group report, "1992 MUMPS Assessment and Opportunity," notes: "[M-based trust software from NCS] is used by several of the top 200 U.S. banks to control more than 375 accounts totalling $600 billion in trust assets. Lloyds of London, Barclays, and Bank of Bermuda ... use M systems... M moved into communication, shipping and transportation, law enforcement and other areas in the 1970s and 1980s. The Veteran's Administration, Discovery Channel, Coca-Cola and Schweppes, Ltd. Star Shipping, and the Law School Admission Service are among the M users." A recent M Technology Association press release describes how M Systems Plus won a contract with American Express's Travel Related Service Division (AMEX) in Atlanta contract to convert 2,000 cruise bookings acquired from a West Coast firm. It is said that the M System was designed and developed within two and a half weeks, and was up and running on schedule, processing over 500 telephone booking inquiries the first day. It has since been expanded to include brochure fulfillment, customer service, word processing, questionnaires that gauge customer reaction, and agent telephone activity tracking. [DPBS] Is M object-oriented?No. A working group within MDC (the MUMPS development committee) is, however, actively considering object-oriented extensions. One vendor, ESI is marketing a development system, ESIObjects, that allows fully object-oriented programming in M. [DPBS] ESI, 5 Commonwealth Road, Natick, MA 01760 1-508-651-1400, FAX 1-508-651-0708However, M has many of the characteristics of newer OO languages. For example: dynamic memory usage, late-binding, encapsulation possibilities. [Jon Diamond, jdiamond@hoskyns.co.uk] Is M structured?Yes, no, maybe, sort of. M syntax is not for purists or academicians. If you want to code in a structured style:
M does not enforce a structured style. And because the features that support structured programming were absent from the MUMPS of the early eighties, there is a substantial body of unstructured legacy code still in use, and a substantial number of M programmers comfortable with what might be called the "traditional" coding style. The M "ELSE" statement is a simple executable statement. It is not syntactically paired with an IF. The semantics are, approximately:
An IF statement sets the value of $TEST according to whether the condition was true or false. An ELSE statement is equivalent to IF '$TEST (the apostrophe is the "not" operator). Unfortunately, the traditional MUMPS subroutine does not push and pop the state of $TEST. Thus,
performs as expected, but
may not, particularly if the REPORT1 subroutine itself contains If statements of its own. This problem is solved by a feature called the "argumentless Do." Actually the argumentless Do plays three separate roles in M programming:
Is MUMPS structured? I think it is. We haven't outlawed the GOTO true, but we have named subroutines, controlled loops (while loop is the same as argumentless FOR with a QUIT), iterated loops (FOR), Parameter Passing to subroutines, functions with return values... We also have line scoping on IFs, ELSEs and FORs. What else do you need to be structured? [David Whitten, whitten@netcom.com] What about declaration of variables? What about scope of variables aside from line scope? I'm not convinced that the "while" exactly counts as a feature of MUMPS - in fact, an argumentless FOR with a QUIT is a "repeat...until", for a "while" you would need to perform an initial IF. Do such composite statements really count as proper controlled loops? Even if MUMPS is technically structured, it goes (IMHO) against the spirit of structured programming with commands reduced to a single letter whenever possible, short variable names encouraged, and no white space. The significance of the space character (in argumentless commands) is completely counter intuitive. I can't say that technically you're not correct in mentioning the above features but one of the primary aims of structured programming is to make support of existing code easier. In my experience, MUMPS encourages hacking and badly designed code. [Gavin Greig, ggreig@mcs.dundee.ac.uk] Is M suitable for multiuser systems?Yes. An important feature of the M language is that the standard language core includes multiuser and multitasking features. These facilitate writing portable distributed-processing applications. A "JOB" command allows one process to initiate other, independent processes. Processes can arbitrate access to resources with each other via a "LOCK" command. There is no specific formal interprocess communication. Interprocess communication is achieved via the LOCK mechanism and shared use of "global" data (which are available to all processes) [--DPBS] Does M work on LANs?Yes. The primary method of implentation might be termed "remote global access." Globals residing on a remote system can be accessed and locked simply by using extended syntax to refer to them. For example,
refers to a piece of data on my local system, while
might refer to a piece of data on a remove system. Thus, the same programming techniques used to build multiuser and multiprocess applications on a single system can be used to build distributed network systems. In addition to this explicit networking most vendors allow for implicit network referencing, allowing system managers to choose the location of data independent of the application programs. A networking protocol standard, "Open MUMPS Interconnect," provides least- common-denominator capability so that systems from different vendors can participate on the same network. In addition, for competitive reasons, most vendors support the major protocols of their competitors. An M-based LAN system in use at Brigham and Women's hospital, with 3,000 PC clients and over 100 servers, is a well-known and very successful application of the technology. There are also a number of systems with M operating in more complex client/server situations, with M acting as a front-end to other systems and also a back-end via RPC etc to applications created using other tools, for example Visual Basic, C++ and so on. Is M standard?1977: accepted as an ANSI standard, ANSI/MDC X11.1 1984: revised ANSI standard ANSI/MDC X11.1-1984 1986: approved as a Federal Information Processing Standard (FIPS) 1990: revised ANSI standard ANSI/MDC X11.1-1990 1992: accepted as an international standard, ISO/IEC 11756-1992 1993: revised FIPS 125-1 1994: revised standard currently in ANSI canvass procedure for approval as ANSI/MDC X11.1-1994 (or maybe 1995) and distributed for comments in ISO as ISO/IEC 11756-1995. [DPBS, compiled from others' comments] Is M portable?As a standardized language, M is portable as long as only the features defined in the standard are used. In practice, the portability of M programs is typically as good as or better than that of C, and much better than BASIC, because, unlike BASIC for example, standard MUMPS is sufficiently rich to implement real-world applications mostly without resorting to vendor-specific extensions. [Tilman Schmidt, ts@gb1.sema.de] The contents of the ISO standard is IDENTICAL to the contents of the ANSI standard. This is another thing that makes M[UMPS] special: it is not uncommon that nationally accepted versions of standards differ in details from their internationally accepted counterparts. [Ed de Moel, demoel@saltmine.radix.net] MUMPS has better portability than C or any other language I'm aware of. The VA has successfully run the same 15000 routine system on almost every platform imaginable. VA Kernel and FileMan, the core of Decentralized Hospital Computer Program (DHCP) and CHCS (The DoD version of DHCP) and IHS (Indian Health Services) has been run, with very few changes, on machines ranging from PC's (over 80 VA Medical Centers running on 486's) to VAXen (other VA's running VMS) to Alpha AXP's (the replacement for the VAXen and some 486 sites) to IBM RS/6000's running AIX (DoD with CHCS from SAIC) . [John E. Kemker, III, kemker.j@atlanta.va.gov] MUMPS is available for at least the following platforms:
[Jon Diamond, jdiamond@hoskyns.co.uk] How does M compare to SQL?M is a full-featured procedural general-purpose programming language. SQL is a declarative language for relational database queries only, and must be embedded in a general-purpose programming language in order to achieve Turing completeness. M accesses its database at low level, almost like programming in ISAM level. SQL works on the relational level, a higher level of abstraction. How does M compare to BASIC?Both are procedural, interpreted applications languages. Both have a line-oriented, verb-object type syntax. M has additional features: better string handling, multidimensional string-indexed arrays, persistent variables, multitasking, multi-user support, dynamic code. M offers greater standardization and portability. Although there is an ANSI standard for BASIC, it is of little practical importance because few vendors conform to it, it is not rich enough to permit development of real-world applications within the standard, and there is a tradition of non-standard vendor extensions. The state of M standardization is superior. The Veterans' Administration, in particular, took a leadership role in writing validation suites that assure vendor conformance to the standard. Vendor choice: BASIC is currently dominated by a single company, Microsoft. There are other vendors but few have any practical importance. M is available from a wider range of vendors. Are there M-based 4GLs and application generators?DASL (DSM Application Software Library). Based on DSM (Digital Standard M), it allows one to build database applications by defining data items and interactively designing screen placement. DASL runs on VMS and Unix platforms. "I used to build apps with DASL... One of the things I really liked about DASL is that it handled a lot of routine stuff, allowing me to build apps in about 30% of the time that it would have taken with straight M coding-- which, in turn, is considerably faster than coding in most other languages :^) Because DASL is written in M it was easy to modify to add special features." [Aaron Seidman]
[Jon Diamond, jdiamond@hoskyns.co.uk] Are there M bulletin boards? M FTP sites? M WWW sites?[01/95] Arthur B. Smith, ART@vets.vetmed.missouri.edu, has recently launched what is probably the first general-purpose public M FTP site. You can reach it by anonymous ftp. The location, in URL format, is: ftp://vets.vetmed.missouri.edu/mumps/ For conventional ftp access, issue the command ftp vets.vetmed.missouri.edu. The beginning of a session looks like this: ftp vets.vetmed.missouri.edu Connected to vets.vetmed.missouri.edu Name (vets.vetmed.missouri.edu:dpbsmith): anonymous 331 Anonymous Login OK, send id as password. Password: [type in your e-mail address here] 230-User logged in 230- Welcome to the University of Missouri-Columbia Department of 230- Veterinary Medicine and Surgery FTP Server. As of 1/95, this location appears to contain everything from the NEMUG BBS, as well as DT-STUDENT and the M FAQ. See the description of the NEMUB BGS, below. --DPBS (All of the BBS'es listed here are in the USA. --DPBS)
There are several WWW sites that deal with MUMPS. Instead of listing them all here, we have only listed a few. These sites have references to other sites on the WWW.
"What happened in 1841?"In M, the current date and time is contained in a special system variable, $H (for "HOROLOG"). The format is a pair of integers separated by a comma, e.g. "54321,12345" The first number is the number of days since December 31st, 1840, i.e. day number 1 is January 1st, 1841; the second is the number of seconds since midnight. But why 1841? According to Steve Clay, steve_clay@delphi.com, the following answer appeared in the "Just Ask!" column of the September 1993 issue of "M Computing," a publication of the M Technology Association, Silver Spring, MD 20903 (Phone: 301-431-4070), in the form of a letter from James M. Poitras: "Starting in early 1969, our group created the Chemistry Lab application at Massachusetts General Hospital (MGH), which was the first package in the MGH MUMPS with Global Data Storage and many of the features of the language today... "When we started programming, there were no utility programs of any type. We had to write them all: time, date, verify database, global tally, print routine, etc. I ended up writing initial versions of most of these. "When I decided on specifications for the date routine, I remembered reading of the oldest (one of the oldest?) U.S. citizen, a Civil War veteran, who was 121 years old at the time. Since I wanted to be able to represent dates in a Julian-type form so that age could be easily calculated and to be able to represent any birth date in the numeric range selected, I decided that a starting date in the early 1840s would be 'safe.' Since my algorithm worked most logically when every fourth year was a leap year, the first year was taken as 1841. The zero point was then December 30, 1840... "That's the origin of December 31, 1840 or January 1, 1841. I wasn't party to the MDC negotiations, but I did explain the logic of my choice to members of the Committee." How do I list a global directory on this unfamiliar M system?Although the M language itself is standardized, the operating environment and utilities, alas, are not. And they are nonstandardized in the worst way: the actual functionality doesn't vary much across vendors, but the details do. Gardner Trask has provided the following guide: Function MSM DSM MVX/MSQL DTM Utility Menu %UTL %UTL UTIL zzu Routine Directory %RD/%ROU %RD/%RDX %RD/%RDISP %rd Routine Print %RP %RS %RO %rsave Routine Change %RCHANGE %RCE %RCHANGE %rsearch Routine Compare %RCMP %RCMP %RCMP %rload Global Directory %GD/%GLO %GD %GD/%GDISP %gd Global List %GL %G %G %g Global Edit %GEDIT %GEDT %GED %gedit Global Change %GCHANGE %ZGE %GCHANGE %gedit Global Transfer %GCOPY %GC %GOQ %GIQ [Gardner Trask, trask@world.std.com] Do comments really affect efficiency?[In case anyone is not familiar with Scott Jones, let me say, in a offhand, understated way, that he knows what he is talking about--DPBS] A number of people have talked about the performance/maintenance issues with comments, so I thought I'd clear things up a bit, at least for the implementations that I deal with (ISM,DTM). Double semi-colon comments are placed in-line into the object code, so it is best (from a maintenance view as well) to have a separate label for each logical section of data, followed by lines of ;; data, that is not in any path of execution. For normal comments, if they are at the end of a line that already has code on it - there is absolutely NO effect at all on performance, so comment to your hearts content. If the comment is all that is on the line, there is still a beginning of line token - which can be expensive, esp. in frequently executed loops. The reason is that the BOL token does a lot of work after every so many lines, such as allow the next process to run (on systems like DTM), or check for ^C,RESJOB, or other inter-process communication. For long runs of comments, such as the maintenance section at the top of a well written routine, if you have M/SQL (for ISM,DTM,DSM or MSM), you can simply use the macro pre-processor and bracket the code in #if 0 ... #endif. This technique totally eliminates the overhead, but it does mean that the maintenance section is not present in the M source, only in the macro source (this can be an advantage if you ship M source to customers, but don't want them to see all of your descriptions of bug fixes). Alternatively, try not to start execution on the first line, but use a label after the comment section. (i.e. DO entry^foobar instead of DO ^foobar) [Scott P. Jones, scott@INTERSYS.COM] What is the MDC?The MUMPS Development Committee (MDC) is responsible for defining the M Standard. Unlike other language standards bodies (such as ANSI and ISO), the MDC is dominated by users - systems developers, rather than implementors. Anyone with an interest in the M language can join the MDC and all members have a single vote. MTA-North America acts as the MDC Secretariat and publishes all documents pertaining to ANSI X11.1, including the Standard, bindings specifications (for example, X Windows, SQL and GKS) and MDC proceedings. There are also counterparts to the MDC in Europe, Brazil and Japan (MDCCs) which feed in non-US contributions and have voting rights at the MDC. [Jon Diamond, jdiamond@hoskyns.co.uk] Compare M with the Xbase languagesAnswering complex questions is one of the biggest reasons we invest in the time and expense of using a database management system. Several types of graphical products exist today to help you query your database. Of these, dedicated front-end query and reporting tools such as Borland ReportSmith for Windows and Intersolve Q+E are probably the best-known in corporate environments. Such tools are typically client applications designed to query data from corporate databases residing on client servers. Typically, these products have no built-in data-management capabilities; many require you to have a detailed knowledge of your database and the workings of relational databases in general. PC-based database management systems let you construct queries and produce reports. You need a fair amount of database savvy to construct a query that produces the right result. Fortunately, the products are getting better at making this process easier. The two leading PC-based database management systems are Microsoft Access 2.0 and Borland Paradox for Windows 5.0. A query is a request for information from a database. Methods for specifying a query have improved over time. Traditionally, one would have used SQL, or structured query language. In the late 1970s, IBM Research developed a new query technique called QBE, or query by example. In QBE, one supplies query details by filling in a table with values. For instance, to locate rows where the state value is New York, one would move to the State column and enter NY. To find salaries greater than $40000, one would enter > 40000. The basic idea of QBE is to make the dialogue easy to learn and reduce any reliance on keywords or language syntax. It is possible to set up a database in M using a tool such as the VA Fileman package. Reports can be generated by means of the Report Writer feature of VA Fileman. Related records in a database are organized together to form a file, or in MUMPS terms a global. A field is a unique observation or data element. A record is comprised of one or more fields, a file (or global in M) is a collection of records and a database is the collection of all files comprising an application. [ Jeff Loeb (loeb@san-diego.va.gov) ] A Brief History of MAs told in a series of e-mail exchanges in comp.lang.mumps in Sept/Oct 1996. Accuracy is not insured. From: Monika Kratzmann (monika@INTERSYS.COM) "Ellis A. Bauman, 608-829-5334" (ellis.bauman@AUP.WISC.EDU) Among the chief developers was Neil Pappilardo who later left Mass Gen, and started Meditech, adding some proprietary features to MUMPS and calling the result MIIS (Meditech Interactive Information System) --- marketing medical records systems to hospitals, clinics, medical labs,etc. At Mass Gen, the language was used to deal with clinical medical data --- hence its strengths in string handling (lots of text data), sparse arrays (not every patient undergoes every possible lab test), and other such features. The original platform was (at least I think it was) a PDP-15. It was later ported to the PDP-11 and other similar "minis" such as the Data General machines like Novas and Eclipses. As the idea spread among other medical researchers, people began adding other features, and there soon developed a whole bunch of "dialects" which frustrated the researchers because they couldn't exchange software very easily. To solve that problem, the MUMPS Users' Group was formed and efforts to standardize the language began. Dr. Barnett was among those who was most forceful in arguing for the creation of MUG and the standardization effort. I do not remember who first proposed that ANSI approval be pursued. The current MTA organization is what MUG has evolved into, via the name change. I believe Joan Zimmerman was the first MUG staff member, and she wrote (or edited?) some of the first MUMPS tutorial materials published by MUG. There is probably lots more material, and details, available from the MTA "archives", and other people who were involved in those early days. Perhaps some of the other newsgroup members will know how to contact some of the people I've mentioned. For example, there is a short history in Chapter 1 of "The Complete MUMPS" by John Lefkowitz. There are also some historical notes in the MUMPS FAQ (for example, "What happened in 1841?"). I hope the above is both accurate and helpful. From: rodd@panix.com (Rod Dorman) From: Lev Jacob (lev@TRENDLINE.CO.IL) From: Dennis J Brevik (dbrevik@ix.netcom.com) Dr. Octo Barnett was in charge at the Laboratory of Computer Science at MGH. Neil Papalardo and Bob Greenes were major contributors. Neil went on to form Medical Information Technology (Meditech), Greenes was a medical doctor as well as holding a PhD in computer science - both degrees awarded simultaneously from Harvard. Bob went on to be President of Automated Health Systems of Wakefield MA and Burlingame CA. In a Boston meeting in Fall 1972 Bruce Waxman of NIH told the audience in no uncertain terms that if they wanted to get NIH money for their computer projects they damned well better be using MUMPS, that NIH was not interested in reinventing THAT wheel, thank you. MUMPS took off. I was the original product line and technical leader on MUMPS-15 at DEC. Paul Stylos was the technical leader for MUMPS-11. Evelyn Dow was the original Marketing representative. And let us not forget Dave Ensor of Scotland, who made significant technical contributions. The DEC executive who originally saw the value in MUMPS was Stan Olsen. Sam Moulton was also on the technical side. From: "Ellis A. Bauman, 608-829-5334" (ellis.bauman@AUP.WISC.EDU) From: dpbsmith@world.std.com (Daniel P. B. Smith) According to the article, the first implementation, of a language called MUMPS, by Neil Pappalardo, was on a PDP-7. Not a PDP-15 or a PDP-9, a PDP-7. He traces its origins from JOSS through BBN's Telecomp and StringComp. Richard Walters' "An ABC of MUMPS" contains a "Brief History of MUMPS" on pp. 20-22 with a family tree showing the root in Rand Corporation JOSS, through BBN JOSS, via TELCOMP and STRINGCOMP to MGH MUMPS. -- Daniel P. B. Smith dpbsmith@world.std.com From: Etienne Cherdlu (gz64@cityscape.co.uk) 1.04 TYPE #,"ENTER ONE OF THE FOLLOWING:-";MENU 1.05 TYPE FORM X FOR X=1:1:4 FOR END=10^15 1.06 READ GRNO IN FORM 15 1.065 DONE IF GRNO=END 1.07 TO STEP 1.06 IF GRNO>4 1.08 TO PART GRNO+1 2.01 DO PART 50 2.02 READ N,K 2.03 DO PART 51 2.04 TO PART 15 .. 15.01 LINE FOR X=1:1:3 15.02 TYPE MINPL,MAXPL IN FORM 17 15.03 TYPE FORM 17 15.04 DO PART GRNO+15 FOR X=MNPL:STPL:MXPL 16.01 Y=(X^N)+K 16.02 Y1[X]=(((Y-MNPL)/(MXPL-MNPL))*2)-1 .. FORM 15 ITEM NUMBER? ##### FORM 17 MINIMUM ##### MAXIMUM ###### Comparison with M:
Clearly some of the origins of M can be seen in TEL 7) DCOMP. Does anyone know where the idea for globals originated? What elements did other languages, such as JOSS bring to M? From: Jon Diamond (jon.diamond@capgemini.co.uk) How Exactly does $ORDER work?The first thing to be aware of is "arrays" as they work in other languages: when you have a "set" of components (like the states in the USA) you want to use a method of reference that allows you to manipulate the "set" as a unit when that is convenient, and its members when you are dealing with the properties of the individual members of that set. Now, in languages like Pascal and C, you would create an array with 50 members, and you would build a table: State[0] = (pointer to string) "Alabama" State[1] = "Alaska" ... State[49] = "Wyoming" and probably some associated tables: Capital[0] = "Montgomery"; Abbrev[0] = "AL"; Capital[1] = "Juneau"; Abbrev[1] = "AK"; ... Capital[49] = "Cheyenne"; Abbrev[49] = "WY"; If you want to loop through these arrays, you don't need any special functions: there are 50 elements in each, and "for i=0 to 49" or for (i=0; i < 50; i++) will do just fine. In M[UMPS], arrays can be done in the same fashion, in which case For i=0:1:49 would do just fine to loop through all states, but it is much more common to use a different method of indexing the array(s), using a string as an index. You could store the array as: State["AL"] = "Alabama/Montgomery" State["AK"] = "Alaska/Juneau" ... State["WY"] = "Wyoming/Cheyenne" (or, if your method of usage would make that more convenient you could use State["Alaska"]="AK/Juneau" State["Juneau"]="AK/Alaska" for that matter). However you "index" the array, the addressing will not be as simple and straightforward as in traditional languages:
Or, a simple loop across all states would look like: Set index="" For Set index=$order(State(index)) Quit:index="" do... The function $order looks at this internal table, and tells you what the next index is after the one that you specify. So... At the first call, the specified index is "" (empty string), and $order will look for the first entry in the table. Currently this is "AK". After "AK", $order would find "AL", "AR", "AZ", etcetera, up to "WY". When called with the "last" index ("WY"), $order would return the value "" (empty string) to signal that it could find no more members. Now, that seems fair for an array like this, and we'll always have the same 50 members, and always find the same ones in the same order, so why go through all this bother? Well, that will become clear when you're dealing with sets that are more dynamic in nature. Suppose that Good Old Fidel finally steps down and Cuba requests membership as a state, there would be a storm of protests, but let's assume that the request would be approved. In most other languages, we would have to do a lot of recoding to insert Cuba in the "proper" place in the new array of states. In M[UMPS], all we have to do is Set State("CU")="Cuba/Havana" $order(State("CT")) currently returns "DE", but after this insertion, it would suddenly return "CU", and $order(State("CU")) would return "DE": by the way of indexing that M[UMPS] does for you "behind the scenes", indexes are always stored in alphabetic order, and you won't have to worry where things are, or how to get them into the proper sequence. Of course, this is where it starts to matter what value you use for an index:
In this example, I also used another "idiosyncracy" of M[UMPS]: I stored "State/Capital" into one single value. You would use the function $Piece to separate out these values. Whether you would use a set-up like I depicted above, or State(abbreviation,"Cap")=capital State(abbreviation,"Name")=name is up to the needs of your application. Of course (and I don't want to say that M[UMPS] is an object oriented language, it's 30 years old now, and definitely showing its age), this is a feature that you see a lot nowadays in object oriented programming as well: you pass the complete object, and leave it to the recipient-software to figure out which properties of the object are interesting to it. [Ed de Moel] M as a first computer language.A lively debate concerning M as a first language for non computer types had varied and interesting opinions. Here are some of them; -- From: Paul Perrin I think M is a *perfect* language to learn about fundamental programming principles. Software engineering can come later - and is abusable in any language. A computer handles three types of execution - sequential, conditional and iterative. Each type can be demonstrated (and learned) in M with _no_ messing about - no 'declarations', no 'introductions', no 'directives', no compiling etc... Experienced programmers _forget_ how they learned to program - Ken Knecht's 1979 definition of a string in 'Microsoft Basic' from the dilithium Press as 'a group of alphanumeric characters surrounded by double quotes' left me blank for weeks - what did he mean by group? Character mode M is (at least) as good as the original 'basic's were for discovering what computers can 'decide' and 'think' and 'store'. Don't listen to the experts -- they forget from whence they came. Show him M (and follow up with Java). Regards Paul Perrin -- From: fbdennis@mindspring.com (Floyd Dennis) Paul Perrin wrote: >I think M is a *perfect* language to learn about fundamental programming principles. For some reason, it surprises me that I tend to agree. <g> Before a "beginner" can even begin to grasp such things as "structured programming", "top-down", etc., they have to get a good feel for the basics. Things like Control, ALU, I/O, and Storage. M brings you a lot closer to the basics than many higher(?)-level languages. Also - for educational purposes, interpreted languages are great. Nothing is going to give a better instant gratification kick than being able to type a command directly and get an immediate answer. <g> ><snip> >Show him M (and follow up with Java). > *THAT* will send him running back to M in a hurry. :) Floyd Dennis M Technology and MUMPS Language FAQ Part 1/2Table of ContentsAppendix 1: List of M Vendors What is M?M is a procedural, interpreted general-purpose programming language oriented towards database applications. Its characteristic features are:
[Tilman Schmidt (ts@gb1.sema.de), ed. DPBS] M has many good points: high productivity, low hardware requirements, good scalability. But M also has some weaknesses: low transaction reliability, character-based screens, poor integration with other environments, and few development tools. [Thomas C. Salander, M Computing, June 1994, p.74] M is a lousy language with one great data type. [Steve J. Morris, sjm2@shore.net] Massachusetts General Hospital Utility Multi-Programming System. A programming language with extensive tools for the support of database management systems. MUMPS was originally used for medical records and is now widely used where multiple users access the same databases simultaneously, e.g. banks, stock exchanges, travel agencies, hospitals. Early MUMPS implementations for PDP-11 and IBM PC were complete operating systems, as well as programming languages, but current-day implementations usually run under a normal host operating system. A MUMPS program hardly ever explicitly performs low-level operations such as opening a file - there are programming constructs in the language that will do so implicitly, and most MUMPS programmers are not even aware of the operating system activity that MUMPS performs. Syntactically MUMPS has only one data-type: strings. Semantically, the language has many data-types: Text strings, binary strings, floating point values, integer values, Boolean values. Interpretation of strings is done inside functions, or implicitly while applying mathematical operators. Since many operations involve only moving data from one location to another, it is faster to just move uninterpreted strings. Of course, when a value is used multiple times in the context of arithmetical operations, optimised implementations will typically save the numerical value of the string. MUMPS was designed for portability. Currently, it is possible to share the same MUMPS database between radically different architectures, because all values are stored as text strings. The worst an implementation may have to do is swap pairs of bytes. Such multi-CPU databases are actually in use, some offices share databases between VAX, DEC Alpha, SUN, IBM PC and HP workstations. Versions of MUMPS are available on practically all hardware, from the smallest (IBM PC, Apple Macintosh, Acorn Archimedes), to the largest mainframe. MSM (Micronetics Standard MUMPS) runs on IBM PC RT and R6000; DSM (Digital Standard Mumps) on the PDP-11, VAX, DEC Alpha, and Windows-NT; Datatree MUMPS from InterSystems runs on IBM PC; and MGlobal MUMPS on the Macintosh. Multi-platform versions include M/SQL, available from InterSystems, PFCS <mumps@pfcs.com> and MSM. Greystone Technologies' GT/M runs on VAX and DEC Alpha. This is a compiler whereas the others are interpreters. GT/SQL is their SQL pre-processor. ISO standard 11756 (1991). ANSI standard: "MUMPS Language Standard", X11.1 (1977, 1984, 1990, 1995?). The MUMPS User's Group is known as the M Technology Association. Mailing list: MUMPS-L@UGA.BITNET. Usenet newsgroups: comp.lang.mumps, comp.std.mumps. (10 Jan 1995) [Submitted by: "Daniel P. B. Smith" Original Author unknown] Where can I get a no-cost version of M?
What is comp.lang.mumps?(11/94) comp.lang.mumps (read c.l.mumps) is a "USENET newsgroup." It was created in July, 1994. It is an unmoderated newsgroup; anyone can post messages to it and anyone can read all the messages posted to it. The newsgroup's charter is given below. The charter is what was voted on by the USENET community when the group was created. As with all unmoderated newsgroups, the health of the newsgroup depends on goodwill, courtesy, and voluntary adherence to the spirit of the charter. Since its inception, comp.lang.mumps has been a friendly newsgroup with a comfortable volume, typically one to five messages per day. Recent topics have included: M coding standards/practices/conventions; rumors about possible M vendor mergers; job postings; and inquiries about specific problems with particular M implementations. CHARTER of comp.lang.mumps The proposed unmoderated newsgroup comp.lang.mumps will be open to discussions on almost all topics related to versions of the M technology and the M language (also known as MUMPS). Appropriate topics would include, but not be limited to:
The only topic that is excluded is: discussion of the standard for the M (MUMPS) language, ANSI X11.1 which should be discussed in the existing group comp.std.mumps. Subsequent custom has established that informal discussions of standards- related issues are very welcome in this newsgroup. MDC members have suggested that they welcome informal discussions be conducted in comp.lang.mumps, while formal proposals should be posted to comp.std.mumps. It is also clear that the membership welcomes job postings and job information. SUBSCRIBING TO COMP.LANG.MUMPS There are different kinds of Internet access. One common situation is a company that "has Internet access" via their internal e-mail system. Such arrangements often are e-mail only; if so, you must use the "MUMPS-L gateway" access method described below. Other sites have direct access to the USENET newsgroups. This is common for academic and government sites, and commercial services. Find out whether your site has direct access to the newsgroups. If you have it, this is the best way to read and post to comp.lang.mumps. If you are on a typical UNIX host at an academic or government institution, one way to check is to type the names of the most popular "newsreaders" -- rn, trn, tin, and nn -- at the command prompt and see if any of them are installed. If not, you probably do not have USENET access and should use the MUMPS-L gateway. If you find that a newsreader is installed, consult an Internet-savvy colleague, system administrator or help desk for more information. (11/94) Most of the commercial services, including America On-Line, CompuServe, DELPHI, and Prodigy now offer direct newsgroup access. Details for CompuServe are noted below. THE MUMPS-L GATEWAY (8/94) Anybody with Internet E-mail can participate in comp.lang.mumps by making use of a gateway and mailing list provided by American University and BITNET. Out of courtesy to the host organization, please use this method only if you cannot get access to comp.lang.mumps in any other way. For those who CANNOT get comp.lang.mumps in ANY other way: To receive MUMPS-L and comp.lang.mumps: Send an e-mail message To: LISTSERV@uga.cc.uga.edu The subject line doesn't matter. The message text should consist of the single line: SUBSCRIBE MUMPS-L Within a short time, you'll get an automated acknowledgement from the list server confirming your subscription and giving other information, and you'll start getting the comp.lang.mumps and MUMPS-L posts. To post a message to MUMPS-L and comp.lang.mumps: Send an e-mail message To: MUMPS-L@uga.cc.uga.edu IMPORTANT: NOTICE THE DIFFERENCE IN THE ADDRESSES. To start and stop subscriptions, you address the request to LISTSERV. Thanks to: American University, for hosting and operating the gateway; Jim McIntosh, jim@american.edu, for administering it; Harold Pritchett, harold@UGA.CC.UGA.EDU, owner and administrator of the MUMPS-L list; and the BITNET organization generally. COMPUSERVE (1/95) Some users have advised making sure that you understand CompuServe's rates, terms, and conditions before using CompuServe to access comp.lang.mumps, as the charges may be higher than anticipated. As of 11/28/94, according to a CompuServe representative (Julie Borders), Newsgroup access is an "extended service" charged by the hour at the same rate as other extended services. "To send Internet e-mail it is $.15 for the first 7500 characters and $.05 for each additional 2500 characters. It is the same rate to receive Internet e-mail." -- [DPBS] (11/94) CompuServe now offers direct newsreader access to the Usenet newsgroups. CompuServe subscribers may already using the MUMPS-L gateway, as described above. If you are doing this now and are satisfied with this system, there's no need to change. Here are the steps I took to read comp.lang.mumps on CIS. Depending on exactly how you're set up (for example, whether you're using CIM), the details may be different for you, but everything should be clear once you GO USENET. For me: the steps were I typed "GO USENET" I chose #6, "USENET Newsreader" I read some pages of warnings, disclaimers, and advice I chose #3, "Subscribe to newsgroups" I chose #1, "Subscribe to one known newsgroup" I typed "comp.lang.mumps" in response to the prompt "Newsgroup name" I typed "m" to return to the previous menu I chose #1, "Access your USENET newsgroups." It listed "comp.lang.mumps (18 articles) " as the only newsgroup I'm subscribed to, then offered choices. I chose #3, "Read articles" --[DPBS] What are some books about M?The following books can be ordered from any M Technology Association. Contact them for prices. In the USA, contact: M Technology Association Introductory/Tutorial: Other: MUMPS POCKET GUIDE - 1990 by Joel Achtenberg, revised by Thomas C. Salander (MTA item #2018) A COOKBOOK OF MUMPS by David B. Brown & Donald H. Glaeser, D.Sc.(MTA item #2024) Introductions and Tutorials:
What do M programmers love about M?High productivity, low hardware requirements, good scalability. [Thomas C. Salander in M Computing, June 1994, p.74] I still program with other languages (Pascal, C, APL, LISP, and so on), but almost always find myself saying, 'but it's so much easier in MUMPS!' ... it's just plain quicker to implement most applications MUMPS. MUMPS is a powerful computing language designed to solve real-world problems. [John Lewkowicz, The Complete MUMPS, p. xii] When I was first at the VA, Greg here gave me a 1 page batch of M code and asked if I could do it any faster in C. Two weeks, a lot of aspirin, and two compilers later, I had 'barely' working code (it would only run *once*). [Mark Komarinski, komarimf@craft.camp.clarkson.edu] M is powerful and succinct. It's excellent for general hacking. If I suddenly get a hankering for the first thousand digits of pi, or for all the order 4 magic squares, or for a table of word frequencies in a document, I don't know of any language I can accomplish this in faster. [Keith F. Lynch, kfl@access.digex.net] f p=2,3:2 s q=1 x "f f=3:2 q:f*f>p!'q s q=p#f" w:q p,?$x\8+1*8 [part of Keith Lynch's .signature; it prints a table of primes, including code to format it neatly into columns -- DPBS] I really like the way that the global tree is "just there" without any file opening, record declarations, and the like. [Kevin O'Gorman, kevin@kosman.uucp] Indirection. Execute strings. String subscripts. Enormously valuable. No other language has all of them. [Ricardo Garcia] I haven't touched MUMPS since the late 70's. I`ve been missing globals ever since. While I was using MUMPS I implemented a simple programming tool couple of pages of MUMPS code. I've missed that tool ever since, as well as how easy it was to implement. [Steve J. Morris, sjm2@shore.net] What things about M are generally disliked?Low transaction reliability, character-based screens, poor integration with other environments, and few development tools. [Thomas C. Salander in M Computing, June 1994, p.74] Are all vendors utilities crap? Having worked with DTM, DSM, MSM it seems lots of effort went into the M and no thought went into the programmer utilities. [Richard J. Tomlinson, Richard@rtsysgen.demon.co.uk] When I look back on my Fortran code from school I am a little embarrassed but I understand it. When I look back on my MUMPS I can't even read it without slow token by token translation. It's amazing to me how fluent I was when I wrote it and how fluent I'm not when I read it. [Steve J. Morris, sjm2@shore.net] It's possible to write completely obfuscated MUMPS code, and too many MUMPS programmers do it. Some even brag about nobody else being able to read their code. Fortunately for those of us in the VA who have to maintain that code, they are becoming a minority. [John E. Kemker, III, kemker.j@atlanta.va.gov] Why is M called a "database language?"M is a programming language with a strong emphasis on text handling and database management. However, M is NOT a data base management system. The disadvantage of being a programming language is that it takes more expertise to apply the language to create a working data base, but the advantage of not being a dedicated database management system is that it is infinitely more flexible. [Ed de Moel, demoel@saltmine.radix.net] Is M an RDBMS?The so-called DBMS component of M is another name for the feature of persistent associative array variables, i.e. arrays that can be indexed by strings, on an arbitrary number of levels, and that survive the termination of the program, being transparently stored on a permanent medium (hard disk). This feature is comparable to what ISAM (Indexed Sequential Access Method) packages offer for other languages, but it is more powerful than ISAM and it is seamlessly integrated into the language. It is *not* a relational database system, although it can serve as a basis for implementing one and does so in several commercial products. [Tilman Schmidt (ts@gb1.sema.de)] Databases that have a lot of many-to-many relations, and/or a lot of sparse information (fields that are more often empty than filled in) do not fit the relational model well. While a relational database can represent this data, it does it with great complexity or inefficency. The sparse hierarchical array structure assumed by M is a much more natural fit for this type of data. [Arthur B. Smith, ART@vets.vetmed.missouri.edu] The M standards suite includes a standard for embedded SQL, and embedded SQL is provided in commercial products such as InterSystems' M/SQL and KBase's KB/SQL. [David Whitten, whitten@netcom.com] Initial development of the "relational model" of databases appeared to place MUMPS at a disadvantage, but recent advances in so-called non-first-normal form, a reference to hierarchical structures characteric of MUMPS, open the door for MUMPS to take a leadership role in current research in that field. [Richard F. Walters, "The ABCs of MUMPS"] Is M compiled or interpreted?M was designed to be interpreted. Real compilation of an M program into a machine program for the target machine is not feasible due to the following of M's features:
[Tilman Schmidt (ts@gb1.sema.de)] Greystone has a product that compiles to .EXE files that are comparable in size to C source .EXEs. [David Whitten, whitten@netcom.com] Most of the versions of MUMPS these days are pre-compilers; a tokenized version of the routine is actually stored separately and usually runs faster. [Ben Bishop, aci@world.std.com] The reasons to use a pseudo-code approach instead of trying to generate machine code has a lot to do with memory efficiency - M has a well deserved reputation for requiring very little in the way of hardware resources, such as RAM. It also has a lot to do with what people do in M. If you do profiles on M applications, you find that much of the time they are doing things that wouldn't be helped by trying to compile to assembly code anyway (they are accessing globals, doing I/O, etc.). Also, with a good C implementation of M, I can port to a new Unix platform in a day or so (and then take a few weeks more if we want to assembly optimize the most commonly executed simple tokens - which I have done for most of the current architectures (Intel, Alpha, Mips, RS/6000-PowerPC, Motorola 68K, Motorola 88K, and Sparc). That would not be possible with an implementation that actually compiled to machine code. (Look at the delays of moving VC++ 2.0 to non-Intel architectures). Finally, with pseudo-code (we call ours m-code), you can share a compiled routine across all platforms (as we do with our M/SQL code). [Scott P. Jones, scott@INTERSYS.COM] How fast is M?One company developing heavily in MUMPS ran tests to determine performance characteristics of MUMPS vs. Oracle. MUMPS ran approximately six times faster. Digital's DSM (Digital Standard MUMPS) consistently sets benchmark records for transaction processing. [John E. Kemker, III, kemker.j@atlanta.va.gov] In benchmarking MUMPS and alternatives such as RPG, BASIC, COBOL and FORTRAN, Casimiro Alonso reports that "A user choosing MUMPS for interactive data base applications can expect up to five times more power from a given computer" and that "the applications development took about one-third the amount of time forecast for the use of other languages...." with the MUMPS database occupying "only one-half to one-quarter of the disk space required by others. [C. Alonso, A Case for MUMPS, Computerworld, January 9, 1984, as cited by William J. Harvey and Frederick G. Kohun in the article, "MUMPS," from Encyclopedia of Microcomputers, 1993.] Very rough tests suggest that DTM is about twice as fast as Visual BASIC's implementation of the BASIC language. These tests involve simple code, coded similarly in each language, that exercise fundamental operations that are common to, and natural in, both languages (FOR loops involving arithmetic and fundamental string operations). On a 33MHz 386DX, Visual BASIC runs at very roughly 1000-2000 commands/second, DTM about twice that. Double that for a 486 DX2, quadruple that for a Pentium. [DPBS] What is M Technology?M Technology refers to the suite of technologies that includes the language specification, M, and related bindings and protocols. M Technology is a programming language, database management system and related bindings and protocols. The main features of M are:
Also integrated in M Technology are:
Portability and scalabilityMUMPS (also known as M) is available on most platforms, including PC's and UNIX. Common capabilities are provided throughout the computer spectrum from desktop processors to enterprise-wide systems. Each M implementation is tailored to its host environment, delivering exceptional performance. The ISO standard includes statements on portability, identifying the minimum set of requirements which all M implementations must meet. The Language M[UMPS] has been an ANSI standard since 1977, with updates in 1984, 1990, and 1995. The identical standard has been adopted by ISO, BSI and FIPS. A worldwide M Development Committee evaluates enhancement requests and recommends improvements to the standard. M Technology supports new developments in computing technology - distributed databases, Windows and GUI's, SQL and client-server architecture - while the standard ensures backward compatibility. M has a strong emphasis on text handling and database management, with multi-user and multi-tasking support. The code is extremely compact because commands can be abbreviated, lines contain multiple commands, and each command can be associated with a separate run-time condition. In addition to its portability, M is popular because it is simple and direct with a relatively small command set, providing the power and flexibility of a 3GL, with the programming ease of a 4GL. World-wide Support for MM is supported by M Technology Associations located across the United States, UK, Europe (including Eastern Europe), the Pacific Rim and South America. These groups are vendor-independent with members from hardware and software vendors, academic institutions and end-users. There are also many independent local MUMPS User Groups in the United States. Defined at a high level, M is a comprehensive development through run-time software technology. M is a procedural, interpreted general-purpose programming language oriented towards database applications. Its characteristic features are:
The environment includes a high-performance database and fully integrated graphical user interface. The ANSI standard M Language upon which M Technology is based shares the attributes of high productivity terseness and power found in fourth generation languages (4GLs). M also provides the benefits of open, multi-vendor platform development and industry recognized standards that are missing from traditional proprietary 4GLs. M's roots are in the healthcare industry. It was first developed at Massachusetts General Hospital and named MUMPS (MGH Utility Multi-Programming Systems). MUMPS became an ANSI standard in 1977. It received Federal Information Processing Standard (FIPS) approval in 1986 (FIPS 125).
April 19 今天AC和巴萨对决,0:1 虽然没有看电视,感觉ac真的有点疲惫了,后防太老了,改造还得进行;前锋线英扎吉没有上,吉拉蒂洛还是抗不住大赛的压力
期待晚上的枪手和黄色潜水艇的对决,期待枪手的胜利 惆怅的种子 今天看了几个同学的blog,每个人都有那么多故事,而我自己却没有给自己留下什么 ,虽然从小不喜欢写日记 ,但是每天看自己的日子的流逝,却不知道自己的生命的真正意义是什么?心中淡出一股幽幽的伤感和惆怅。很久之前就看过一朋友 的blog,当时自己也想把心路历程记录一下 ,但是一荒废有是野草一片。来北京这么久了,心灵很少有过沟通的地方,看大学的挚友的记录,感悟一下,发现和同学现在联系好少,感觉自己失去了好多 ,满心惆怅 April 08 冠军杯的狂喜欧洲冠军杯 ,阿森纳、巴萨和ac都进入四强 ,我最喜欢的三支球队 ,心里渴望哪支球队胜利都是一种难以割舍的感觉,不过看赛程安排,我期待枪手的胜利 ,对手是西甲的比利亚雷儿,相对巴萨和ac是对手实力最少低一个档次 ,黄色潜水艇的中场核心里克儿梅在阿森纳的技术流中不一定能够出色 ,以枪手强大的火力 ,进入决赛是完全没有问题了 ,但是决赛我就有点担心了。ac 和巴萨,都是技术流的代表,球风都很类似,巴萨的梅西 小罗 和eto前场实力强大 ,ac中舍普和kaka ,还有我最喜欢的小刀英扎吉,前场实力也是剧强,现对于后防线,巴萨的实力应该没那么强硬 ,比较ac中的大佬都是意大利的精度后卫,唯一担心的后防线能否抗击住小罗等人的冲击力 ,比较如果保罗和科老年纪都一大把了
巴萨中场哈维小白 范哥都是强人,ac的小皮 屠夫 西多夫 人还是不少的
最后还是期待阿森纳能够抢到大耳朵,毕竟,如果亨利的离开,阿森纳就将降低一个等级
我可是不期待看不到他们黄色的流畅的比赛 April 13 如何连接oracle数据库及故障解决办法-总结 (转帖)该文是我连接oracle的总结,特别适合于程序开发人员与oracle菜鸟 抱歉,我写的有错误的地方: 用sqlplus程序通过test网络服务名进行测试,如sqlplus system/manager@test。如果不能连接到数据库,则在tnsname.ora文件中的test网络服务名(net service)后面加上Oracle数据库的DB_Domain参数值,通过用sqlplus> show parameter db_domain命令察看。此处db_domain参数值为testserver.com,将其加到网络服务名后面,修改后的tnsname.ora中关于该网络服务名的内容为:
|
|||||
|
|