《大型机编程工具》复习资料

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

第1页共19页REXX基本概念、主要语法及程序设计复习1.REXX:RestructuredEXtendedeXecutor;CLIST:CommandLIST。REXX和CLIST的主要区别:NOREXXCLIST(1)NewOld(2)GoodstringhandlingBadfordatastrings(3)English-likeLotsof&&&&&(4)ClearObscureattimes(5)ExcellentcontrolstructuresGoodcontrolstructures(6)GoodformathBadformath(7)ManygoodfunctionsFewusefulfunctions(8)CommonUnique(9)NopromptingforpositionalparmsPromptsforpositionalparms(10)REXXprogramsaregenerallycontainedinlibraries(PDSs)whosenamesendin.EXEC.(.EXECnotrequired,butrecommended).CLISTsaregenerallycontainedinlibraries(PDSs)whosenamesendin.CLIST.(.CLISTnotrequired,butrecommended).参考教材P12关于CLIST和REXX的使用方法。2.Rexx语言是一种解释型、非编译型、高级的脚本语言,要与C/C++、Java、COBOL等语言的区分开来。Rexx语言是一种解释型的“胶水”语言,它可以方便地调用其他语言编写的模块。无需对变量进行声明、赋初值即可使用,变量不区分大小写;但注意变量不能以“0~9”或“.”开头。所有变量都是无类型的“typeless”(也可以认为是单一数据类型,字符串)。要注意Rexx语言不适合使用的场合:如内存读写、驱动等。3.了解Rexx所属的标准范畴,①TRL-1,1985,Level3.50;②TRL-2,1990,Level4.00;③ANSIX3.274-1996,Level5.00。TRL:TheRexxLanguage。4.Rexx注释使用“/**/”,可包含多行;大型机上的Rexx程序,第一条语句通常使用包含REXX的注释,比如“/*REXX*/”。5.Rexx包含字符(串)可使用‘’或“”,注意字符串输出时混用以输出带有同样符号的字符串。6.在TSO/E环境下编写REXX脚本,可使用“HIREXX”命令对REXX代码高亮显示。7.REXX代码的书写:逗号“,”可表示续行,分号“;”可在一行分隔多条指令。8.REXX程序在TSO/E环境下的执行方式及参数传递方式,参见实验内容及P14、P33、P162。9.Rexx十六进制、二进制的表示:Num41inHex='41'x/*41isthenumber65inbase16*/SayNum41inHex/*displayalphabetA*/hexString=3E114AX/*Assignsahexstringvalue*/SayhexString/*displayJ*/第2页共19页bin_41_string='01000001'b/*displayA*/Bin_61_string='01100001'B/*displaya*/say414243X/*ABC*/X=5+6sayTheanswerisX/*语法错误*/10.Rexx算数运算符:11.Rexx数值精度numeric:(1)Tocontrolthenumberofsignificantdigitsinarithmeticresults(2)Sometimesreferstotheprecisionoftheresult.(3)Defaultnumericprecision=9digits.say2/3/*displays0.666666667bydefault*/numericdigits12/*setnumericprecisionto12digits*/say2/3/*displays:0.666666666667*/默认情况下,使用“saydigits()”可得到精度值9。12.比较操作符:第3页共19页Program:a=b=2Saya=aSayb=bThentheresult:a=,b=.Thisprogramcheckstoseeifb=2.Ifitis,itproducesa1,soaissetto1.Ifitisnot,aissetto0.Thevaluebisnotdeclared,soit’svalueisB.13.逻辑操作符:14.字符合并:(abuttal)||:Concatenatewithoutblank(blank):Concatenatewithblank15.结构化指令/语句,重点掌握do语句;do10/*Execute10times*/callsub_routineenddoj=1to10by1callsub_routineenddoj=1to10by1for3第4页共19页say'Loopexecuted:'j'times.'/*Endswith:'Loopexecuted:3times.'*/end16.非结构化指令/语句:Leave指令和Iterate指令都可终止循环结束,但终止退出的位置不同,见下图。Leave指令将中断并跳出当前的活动循环,在上面将直接跳至指令c;Iterate指令将忽略循环体内剩余的循环指令,直接运行至循环体的End指令。17.Signal和Iterate的区别,Signal和GOTO的区别j=1doforever/*dosomeworkhere*/j=j+1ifj=4thensignalmy_routine/*无条件转移到MY_ROUTINE*/end/*此处的其他代码被SIGNAL指令忽略*/my_routine:saySIGNALinstructionwasexecuted,MY_ROUTINEentered…DoForever…指令aLeave…指令bEnd指令cDoForever…指令mIterate…指令nEnd指令p第5页共19页Theiterateinstructioncausescontroltobepassedfromthecurrentstatementinthedolooptothebottomoftheloop.j=1dountilj=2sayLoopj=jwasenteredj=j+1ifj=2theniterate/*“注意去掉ifj=2then”的运行结果,若换成leave的结果*/sayITERATE1...sayITERATE2...endsayIntheend18.Select指令用法:selectwhengender='M'thensay'Genderismale'whengender='F'thendosay'Genderisfemale'female_count=female_count+1endotherwisesay'Error--Genderismissingorinvalid'say'Pleasecheckinputrecord'end/*thisENDpairswiththeSELECTinstructionitself*/19.CALL语句用法:Rexx’scallinstructioninvokesasubroutine,wherethesubroutinemaybeoneofthreekinds:Internal—ConsistsofRexxcoderesidinginthesamefileasthecaller.Built-in—OneoftheRexxbuilt-infunctions.External—Coderesidinginadifferentfilethantheinvokingscript.AnexternalsubroutinemaybeanotherRexxscript,oritmaybewritteninanylanguagesupportingRexx’sinterface.结合教材P28、P47掌握函数调用、返回值相关要点。第6页共19页20.非结构化控制指令21.数组初始化:list.=0books.=‘’不允许:members.=members.+5lista.=listb.lista.0通常设置为数组的大小22.I/Olinein—Readsonelinefromaninputstream.Bydefaultthisreadsthelinefromdefaultstandardinput(usuallythekeyboard).lineout—Writesalinetoanoutputstream.Bydefaultthiswritestostandardoutput(usuallythedisplayscreen).Returns0ifthelinewassuccessfullywrittenor1otherwise.lines—Returnseither1orthenumberoflineslefttoreadinaninputstream(whichcouldbe0).程序:/*FINDPAYMENTS:*//*Readsaccountslinesonebyone,writesoverduepayments*//*(containingthephrasePAYMENTOVERDUE)toanoutputfile.*/parseargfileinfileout/*get2filenames*/dowhilelines(filein)0/*dowhilealinetoread*/input_line=linein(filein)/*readaninputline*/ifpos('PAYMENTOVERDUE',input_line)=1then/*$Due?*/calllineoutfileout,input_line/*writelineif$overdue*/第7页共19页end运行:reginafind_payments.rexxinvoices_in.txtlost_payments_list_out.txtlineout/charout函数两种用法:calllineoutfileout,input_linefeedback=lineout(fileout,input_line)rc=lineout(fileout,input_line)注意:单单使用lineout(fileout,input_line)错误。lines函数:lines(file_name,C)—Count.Returnsthenumberoflineslefttoread.lines(file_name,N)—Normal.Returns1iftherearelineslefttoread.(Forbackwardcompatibility,thiscaseisthedefault.)文件打开关闭:1.Closeafileandflushthebuffersbyencodingalineoutfunction:calllineout'c:\output_file'/*flushesthebuffersand*//*closesthefile–inmostRexximplementations*/2.Usestreamfunctiontoclosefiles:status_string=stream(file_name)status_string=stream(file_name,'S')/*'S'optionrequestsreturnoffileSTATUS*/Basicfunctionsforstandard

1 / 19
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功