系統(tǒng)編程工具REXX和CLIST_第1頁
系統(tǒng)編程工具REXX和CLIST_第2頁
系統(tǒng)編程工具REXX和CLIST_第3頁
系統(tǒng)編程工具REXX和CLIST_第4頁
系統(tǒng)編程工具REXX和CLIST_第5頁
已閱讀5頁,還剩68頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

第五章系統(tǒng)編程工具REXX和CLIST第一部分(REXX):

1.REXX簡介

2.Rexx入門學(xué)習(xí)

3.REXX編程基礎(chǔ)

4.程序調(diào)試和錯(cuò)誤處理第二部分(CLIST):

1.CLIST簡介第一部分(REXX)1.REXX簡介

2.Rexx入門學(xué)習(xí)

3.REXX編程基礎(chǔ)

4.程序調(diào)試和錯(cuò)誤處理

1.REXX簡介REXX的起源和歷史:由MikeCowlishaw設(shè)計(jì)

-1979-1982,IBMHursleyLabs,UK-Usingfeedbackfromover300usersonVNETDesignedtomaketheackofprogrammingeasierIntendeduses:-personalprogramming-Tailoringusercommands-Macros-Prototyping-ApplicationsNowrunsonmanyvendorsplatformsREXX簡介運(yùn)行平臺(tái):IBM的所有平臺(tái):

-VM–REXX首次出現(xiàn)(1983)

-OS/2-AIX-VSE-OS/390TSO(1988)1987年被選為SAAProceduralLanguage也可以用在許多非IBM平臺(tái)上:

-Tandem,VAX,Amiga-SeveralUNIXversions(includingLinux)-windows(ObjectREXXfromIBM)-NetRexxREXX簡介REXX特點(diǎn):易學(xué)易用性自由的語法格式Eitherinterpretedorcompiled豐富的built-in函數(shù)TypelessvariablesVerystrongparsing好的調(diào)試工具提供和其他語言的接口可擴(kuò)展性REXX簡介REXX在z/OS上的使用CommandproceduresPersonalprogrammingApplicationinitiationApplicationprototypingApplicationprogrammingCommonmacrolanguageforvariedapplications-ISPFEditmacros,ISPFDialogs,Netview-CICS,DB2,QMF-OthervendorproductsREXX簡介InterpretedversusCompiled解譯器:

-當(dāng)程序在運(yùn)行時(shí),翻譯并執(zhí)行每個(gè)程序語句編譯器:

-首先將整個(gè)程序翻譯成機(jī)器語言

-然后通過鏈接-編輯成加載模塊

-然后用戶可以運(yùn)行該程序REXX簡介一個(gè)簡單的REXX程序

/*REXXexectointroduceREXX*/Say“Hello!MynameisREXX.What’syours?”ParsePullnameIfname=‘’ThenSay“You’renotfriendly”ElseSayname“isanicename.”Exit02.Rexx入門學(xué)習(xí)REXXunderTSOREXXexec可以是一個(gè)順序數(shù)據(jù)集或一個(gè)PDS成員TSOEXEC命令調(diào)用一個(gè)REXX或CLIST程序三種使用EXEC命令的方法:

-Explicitexecution:EXECdatasetparameters-Implicitexecution:membernameparameters-Extendedimplicitexecution:%membernameparameters查找包括:

//SYSEXECDDconcatenationthen//SYSPROCDDconcatenation

用來作為命令行上的成員名.READY%myrexx2472my.dataREXXexecs在TSO下的執(zhí)行:在TSO/E中用EXEC命令運(yùn)行非編譯的程序。精確運(yùn)行一個(gè)REXX可執(zhí)行程序格式如下:

EXECDSName(數(shù)據(jù)集名字)Parameterexec例如:名為USERID.REXX.EXEC(TIMEGAME)的數(shù)據(jù)集被執(zhí)行,格式如下:完整數(shù)據(jù)集被調(diào)用,數(shù)據(jù)集名要被引號(hào)標(biāo)記,如下:

EXEC‘userid.rexx.exex(timegame)’exec非完整數(shù)據(jù)集被調(diào)用,如下:

EXECrexx.exex(timegame)exec/*eliminatesprefix*/

EXECrexx(timegame)exec/*eliminatesprefixandexec*/通常REXX命令的輸入執(zhí)行可以在ISPF.6對(duì)應(yīng)面板中的COMMAND后面輸入,也可以在READY提示符下面輸入。Rexx中的注釋:注釋以/*開始,以*/結(jié)尾.注釋可以嵌套.例:1./*REXXexecsshouldbeginwithacomment*/2.Say“Hello!”/*commentmayfollowinstruction*/3./*commentmayprecedeinstruction*/Say“Hello!”4./*Acommentmaybelong,upto250characters,anditmayspanmultiplelines*/5./*Commentsmay/*Commentsmaybenested*/benested*/繼續(xù)和縮排短指令可以用“;”分開:

a=‘Cat’;b=‘Dog’;c=17長指令可以用“,”分行:

sentence=“Thequickbrownfox”,“jumpsoverthelazydog.”REXX不支持縮排:

Ifa=bThenSay“aandbareequal.”ElseSay“aandbarenotequal.”變量REXX中,變量的命名規(guī)則:

-最多包含250個(gè)字符

-可以包含字母,數(shù)字和一些特殊字符(TSO中:@#$!?_.¢).-不能以數(shù)字或.開頭變量不用必須聲明.REXX中的變量是無類型劃分的,所有的數(shù)據(jù)都是字符型數(shù)據(jù).算術(shù)運(yùn)算:運(yùn)算符:**指數(shù)運(yùn)算*乘法

/除法

%整除

//取余

+加法

-減法算術(shù)優(yōu)先規(guī)則:REXX的通常優(yōu)先級(jí)規(guī)則:()圓括號(hào)+,-前綴符號(hào)**指數(shù)運(yùn)算符號(hào)*,/,%,//乘法和除法+,-加法和減法算術(shù)優(yōu)先規(guī)則:例:Say7*3+4Say2**3**2Say7+3*4Say2**(3**2)Say7–3+4Say-5+6Say7+3–4Say-5+6*2Say3**2Say–(5+6)*2Say指令:語法:Sayexpression每個(gè)Say指令顯示一行輸出.例:Say“Hello,world.”Say25*(9/3)Say“Theansweris:”num1+num2SaySay‘’Parse指令

語法:ParsesourcevariabletemplateWheresourceistheinputsourceofthedatatobeparsed,andvariabletemplatearetherulesforparsingthatdata,andthevariablestowhichthedatapartswillbeassigned.從鍵盤讀(ParsePull)語法:ParseUpperPullvariabletemplate-or–Pullvariabletemplatevariabletemplate是變量名的列表.

在給模板中的變量賦值前,將輸入數(shù)據(jù)自動(dòng)轉(zhuǎn)換成大寫形式.例:/*REXXsample*/Say“Pleaseenteryourname:”ParseUpperPullnameSay“Hello”name”.”Say“Enter2numbers:”ParseUpperPullnumanumbSay“Youenteredthesenumbers:”numa“and”numb如果保留輸入數(shù)據(jù)的大小寫形式,則刪除關(guān)鍵字Upper:ParsePullvariabletemplate從命令行接收參數(shù)(ParseArg)語法:ParseUpperArgvariabletemplate-or–Argvariabletemplate例:/*REXXsample*/ParseUpperArginparmsSayinparmsParseUpperArgparm1parm2parm3restSayparm1Sayparm2

如果保留輸入數(shù)據(jù)的大小寫形式,則刪除關(guān)鍵字Upper:ParseArgvariabletemplateTrace指令:語法:Traceoption有用的選項(xiàng):-NNormal(default)-OOff-RResults-IIntermediates注:Trace指令通常被用語Rexxexec程序的調(diào)試.跟蹤一個(gè)exec也就意味著你希望在exec中的指令被執(zhí)行前Rexx可以在屏幕上顯示出這些指令.3.REXX編程基礎(chǔ)比較關(guān)系REXX中的比較關(guān)系有時(shí)被稱為二進(jìn)制條件表達(dá)試,因?yàn)樗鼈兛偸侵挥袃煞N可能結(jié)果:True(值為1)和False(值為0).REXX中有兩種類型的比較關(guān)系:-字符串比較

-數(shù)值比較字符串比較兩種字符串比較類型:-普通:忽略字符串前后的空格

-嚴(yán)格:每個(gè)字符必須精確匹配例:answer=“YES“/*assignvariable*/Sayanswer=“YES”/*normalcomparison*/Sayanswer=“yes”/*comparisonsare*//*casesensitive*/Sayanswer==“YES”/*strictcomparison*/Say5==5.0/*strictcomparison*/數(shù)值比較比較符:=equal\=notequal﹁=notequal<>notequal(lessthanorgreaterthan)><notequal(greaterthanorlessthan)<=lessthanorequalto\>lessthanorequalto(notgreaterthan)﹁>lessthanorequalto(notgreaterthan)>=greaterthanorequalto\<greaterthanorequalto(notlessthan)﹁<greaterthanorequalto(notlessthan)<lessthan>greaterthan數(shù)值比較例:num1=31;num2=30Saynum1=num2Saynum1\=num2Saynum1>num2Saynum1<num2If-Then-Else用法:語法:IfcomparisonTheninstruction1Elseinstruction2例:Ifvar1=var2ThenSay“Thevaluesareequal.”ElseSay“Thevaluesarenotequal.”Do-End組在Then或Else后面,多于一條指令時(shí),將這些指令包含在Do和End之間.Ifvar1=var2ThenDoinstruction1instruction2etc…End邏輯操作符比較結(jié)果(false是0,True是1)可能和這些操作符結(jié)合.操作符是:&與

|或

&&異或

\非邏輯操作符例:var1=1;var2=0Sayvar1&var2/*bothtrue?*/Sayvar1|var2/*eitheronetrue?*/Sayvar1&&var2/*onlyonetrue?*/邏輯表達(dá)試?yán)?var1=41;var2=1;var3=0Sayvar1>var2&var3>var2Sayvar1>var2|var3>var2Sayvar1>var2&&var3<var2Sayvar1>(var2|var3)>var2

If-Then-Else嵌套If-Then-Else結(jié)構(gòu)可以被嵌套.例:Iftoken1=“CONCAT”ThenDo..instructions..EndElseIFtoken1=“BLK”|token1=“BLOCK”ThenDo..instructions..EndElseIftoken1=“DATASET”ThenDo..instructions..End選擇結(jié)構(gòu)TEST1TEST2TEST3instruction(s)instruction1instruction2instruction3TRUETRUETRUESelect-When-Then-Otherwise用法Select結(jié)構(gòu)可以代替多I-T-Es.例:SelectWhentoken1=“CONCAT”ThenDo..instructions..EndWhentoken1=“BLK”|token1=“BLOCK”ThenDo..instructions..EndWhentoken1=“DATASET”ThenDo..instructions..EndOtherwiseSay“Error–unrecognizedtoken:”token1End/*ofSelect*/DoWhile循環(huán)語法:DoWhilelogicalexpression..loopinstructions..End例:var1=12DoWhilevar1>6Sayvar1var1=var1–1End/*DoWhile*/TESTProcessFALSETRUEDoUntil循環(huán)語法:DoUntillogicalexpression..loopinstructions..End例:var1=1DoUntilvar1>6Sayvar1var1=var1+1End/*DoUntil*/TESTProcessFALSETRUE控制重復(fù)次數(shù)的循環(huán)語法:Docntlvar=initTofinalByincrFormaxloopscntlvar-循環(huán)控制變量名

init-控制變量的初始值

final-控制變量的最大值

incr–循環(huán)變量循環(huán)一次增加的值

maxloops–最大循環(huán)次數(shù)控制重復(fù)次數(shù)的循環(huán)例如:Doi=1To100/*theseinstructionswillexecutewhilethevalueofthevariableichangesfrom1to2to3…to100.Thedefaultincrementvalueis1*/EndDoi=1To100By10/*execute10times*/Doi=100To1/*wrong,notbeexecuted*/Doi=100To1By-1/*execute100times*/

控制重復(fù)次數(shù)的循環(huán)下列循環(huán)將被執(zhí)行多少次?1.Doi=1…End/*forever*/2.Do5…End/*Do5*/3.DoForever…End/*Forever*/避免可怕的GoTo因?yàn)镚oTo語句經(jīng)常在程序中產(chǎn)生一些很嚴(yán)重的bug,所以REXX提供了一些其他的指令代替它執(zhí)行相應(yīng)功能,如下:-Leave-Iterate-Return-Exit-SignalReturnandExitwillbothcauseimmediatecessationofthecurrentlyexecutingroutine.Controlisreturnedtothecallingenvironment.LeaveandIterateLeave指令使得REXX終止當(dāng)前循環(huán):DoForever……Leave…EndIterate指令使得REXX經(jīng)由其余循環(huán)指令并將控制傳遞到End指令:DoForever……Iterate…End如何確定屬于哪個(gè)循環(huán)?循環(huán)是可以進(jìn)行嵌套的.循環(huán)控制變量可以作為循環(huán)的名字用在End,Leave和Iterate指令上.例:Doouter=1…Doinner=1…If…ThenIterateinnerIf…ThenIterateouterIf…ThenLeaveinnerEndinner…Endouter函數(shù)和子程序本節(jié)目標(biāo):1.明確什么是函數(shù)和子程序

2.明確函數(shù)和子程序間的不同點(diǎn)

3.Built-in函數(shù)的使用

4.如何寫內(nèi)部函數(shù)和子程序

5.如何寫外部函數(shù)和子程序什么是函數(shù)?向主調(diào)度程序返回一個(gè)值的一個(gè)程序或routine。返回值是一個(gè)單獨(dú)串。返回值代替函數(shù)調(diào)用,因此函數(shù)根本不回獨(dú)立使用。語法:

functionname(argument1,argument2,…)例:

parm=“Thisistheparameter.”n=Words(parm)4<wordsfunction>函數(shù)類型InternalBuilt-inExternal-TSO/Eexternal-YourownREXXcode-ProgramsinotherlanguagesSearchorder:-Internal-REXXBuilt-in-TSO/EExternal-FunctionPackage-Programsinotherlanguages-ExternalExecsandCLISTSBuilt-in函數(shù)最簡單和最有用的函數(shù)類型:-Stringmanipulation-Comparison-Formatting-Conversion-Binary-Arithmetic-Information-Programdiagnostic字符串操作函數(shù)Thesefunctionsextractportionsofstrings:-Substr(),Strip(),Left(),Right(),Delstr()Thesefunctionsaddtostrings:-Insert(),Center(),Justify(),Overlay()Thesefunctions“find”withstrings:-Pos(),Lastpos(),Verify(),Abbrev()Thesefunctionsmanipulatein“words”:-Word(),Wordindex(),Wordlength(),Wordpos()-Words(),Delword(),Subword()Togetthelengthofastring–Length()Totranslateastring–Translate()Toreversethecharactersinastring–Reverse()Substr()Substr()函數(shù)將一個(gè)輸入串分成幾個(gè)部分并返回其中的一部分.語法:Substr(input,n),length,padSubstr()例:x=Substr(‘a(chǎn)bcdefg’,3)==>returns‘cdefg’

x=Substr(‘a(chǎn)bcdefg’,3,4)==>returns‘cdef’x=Substr(‘a(chǎn)bcdefg’,3,7,‘!’)==>returns‘cedfg!!’Formatting函數(shù)Center()/Centre()Copies()Format()Justify()Left()Right()Space()Strip()Formatting函數(shù)函數(shù)解釋:NotethatboththeUSEnglishandtheUKEnglishspellingsofCenterareaccepted.Tomakemultiplecopiesofastring,useCopies().Toformatandroundanumber,useFormat().Toaddordeletespacesandothercharactersbetweenwords,useSpace().Toremoveleadingand/ortrailingcharactersfromastring,useStrip().例:x=Left(‘a(chǎn)bcdefg’,4)returns’abcd’x=Right(‘a(chǎn)bcdefg’,4)returns‘defg’x=Left(‘a(chǎn)bcdefg’,10)returns‘a(chǎn)bcdefg’x=Right(‘a(chǎn)bcdefg’,10)returns‘a(chǎn)bcdefg’Conversion函數(shù)字符,十六進(jìn)制和十進(jìn)制數(shù)之間的轉(zhuǎn)換

-用于任何比較

C2X(),C2D(),D2C(),D2X(),X2C(),X2D()-二進(jìn)制和十六進(jìn)制之間的轉(zhuǎn)換

B2X(),X2B()其他函數(shù)二進(jìn)制邏輯函數(shù)

-Bitand()-Bitor()-Bitxor()數(shù)值函數(shù)

-Abs(),Min(),Max(),Sign(),Trunc(),Format()-Random()-Digits(),Form(),Fuzz()信息函數(shù)常規(guī)信息函數(shù):-Date(),Time(),Userid()系統(tǒng)程序信息函數(shù):-SYSVAR(),MVSVAR(),SYSCPUS()程序診斷函數(shù):-Sourceline(),Errortext(),Condition()終端寬度:-Linesize()子程序子程序與函數(shù)的區(qū)別:1.Functionmustreturnavaluesubroutinemayormaynot2.Valuereturnedfromfunctionreplacesfunctioncall,valuereturnedfromsubroutinepassedtoREXXspecialvariable‘result’3.Functioninvokedwithfunctioncall–funcname(args)4.SubroutineinvokedwiththeCallinstructionCall指令語法:CALLsubrtnarguments所有的函數(shù)都可以被作為子程序調(diào)用.為什么要用函數(shù)和子程序?結(jié)構(gòu)化程序所必須的將程序分為多個(gè)模塊代碼的重復(fù)利用函數(shù)和子程序可以是內(nèi)部或外部的4.程序調(diào)試和錯(cuò)誤處理程序目標(biāo):-可靠性

-能處理不可預(yù)測事件

-給用戶發(fā)送有意義的錯(cuò)誤信息

-錯(cuò)誤返回非零值

-易維護(hù)性易維護(hù)性包括好的注釋大多數(shù)可執(zhí)行程序還包括:-包含修改歷史的文檔

-主程序

-子程序

-錯(cuò)誤恢復(fù)程序使用有意義的變量名采用一致的設(shè)計(jì)方法形成一種編碼風(fēng)格Signal指令CauseunusualtransferofcontrolUsedtotraperrorconditionsDestroyscontrolstructures-Do–End,If,SelectFivesignaltraps:-Error-uninitializedvariablehasbeenused-Failure–non-zeroreturncodefromhostcommand-Halt–negativereturncodefromhostcommand-Novalue–externalattempttointerruptexec:PA1,thenHI-Syntax–syntaxerrorsandrun-timeerrorsSignal指令Toturnthetrapon,theinstructionis:SignalOntrapnameToturnthetrapoff,theinstructionis:SignalOfftrapnameForexample:AlmosteveryexecshouldincludeSignalonNovalueAtornearthebeginningoftheprogram.返回值的規(guī)定0=complete,unambiguoussuccess4=verylikelysuccessful,butwarning8=probablefailure,butthesystemisstillworking12=certainfailure16=worsethan1220=fundamentalsystemenvironmenterrorThehigherthenumber,theworsetheerror.Diagnostic函數(shù)Sourceline()-Returnsnumberoflinesofcode,oractuallineofsourcecodeCondition()-Returnsinformationdependingononeoffourarguments(C(condition),D(descriptive),I(instruction)andS(status))Errortext()-ReturntextofREXXerrormessageassociatedwithargumentnumberREXXspecialvariablesigl-Assignedwithlinenumberwhereconditiontraperroroccurred測試測試的數(shù)量取決于可能的最終用戶規(guī)模開始用少量數(shù)據(jù)測試測試代碼的所有部分從錯(cuò)誤中測試可恢復(fù)性UseREXXaidstoconfirmtheprogramflow-TraceinstructionTrace指令REXXTrace指令-有用的選項(xiàng):TraceR–“Results”–mostusefulTraceN–“Normal”–tracesnegativereturncodesTraceO–“Off”–turnstracingoffTraceI–Intermediates–mostinformation其它Trace選項(xiàng):-A,C,E,F,L,S,?,!,+n,-nTrace-不修改代碼

-TSO命令EXECUTILTS–運(yùn)行可執(zhí)行程序之前REXXTrace()函數(shù):-trace_actions_in_effect=Trace()

交互式調(diào)試Trace?在每個(gè)指令處停止:-Pressentertocontinue-type“=”tore-executelastclause-typeanythingelse–likeREXXTRY–processlineimmediatelyTracen–skipnpause(nisawholenumber)其他調(diào)試工具Attentionmode(PA1)immediatecommands-HE–haltexecution-HI–haltinte

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論