28.01.2015 Views

Hermes: A Tutorial and Reference Manual - Researcher - IBM

Hermes: A Tutorial and Reference Manual - Researcher - IBM

Hermes: A Tutorial and Reference Manual - Researcher - IBM

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

201.5.Declarations<strong>and</strong>Denitions while('true')repeat<br />

twoareidenticaltoHelloWorld.Itwouldbeeasyforaneditororother Noticethatexceptfortheprogramname,therstvelines<strong>and</strong>thelast endprocess returnParms; on(GetLineInterface.EndStream) endblock; endwhile; callParms.GetLine(Line);<br />

tooltoinserttheselinesautomaticallyasboilerplatearoundanyst<strong>and</strong>ard callParms.PutLine(Line);<br />

<strong>Hermes</strong>doesn'tallowyoutohideanouterdeclarationbydeclaringanew intheregionofvisibilityofavariable.Thisruledoesnotexistinmost variablewiththesamenameinaninnerblock.Thisavoidshaving\holes" onlywithintheblock.Thisruleisfoundineveryblockstructuredlanguage. one-lineprogram,<strong>and</strong><strong>Hermes</strong>doesn'tappearsoverbose. tion.Ifavariablenameisdeclaredwithinablock,thenthatnameisvisible clientprogram.Ifthisisdone,thenHelloWorldonceagainbecomesa<br />

conictsifyoucopycodecontainingblocksfromoneprogramtoanother. otherblockstructuredlanguages.Youmayhavetowatchoutforname HerearetheprogramsFilter<strong>and</strong>Compound.Thistime,we'lljustshow Inthisexample,thereisaninnerblockstatementcontainingadeclara-<br />

theheader<strong>and</strong>declarationswithoutrepeatingthecode: Filter:using(St<strong>and</strong>ard,Filter)process(Init:FilterIn) line begin declare<br />

endprocess Prefix:Charstring;--stringtoprependtoeachoutputline --codeforprocessFilter PutLineCM:PutLineInterface;--callmessagecontainingthe Out:PutLineOut;--outputport:boundtoputlineservice Parms:FilterInterface;--initializationcallmessage In:PutLineIn;--inputport:requestsfromclient<br />

Compound:using(St<strong>and</strong>ard,Filter)process(Init:St<strong>and</strong>ardIn) declare begin Client:St<strong>and</strong>ardOut;--porttoinitializeclient Mark:integer;--positionof"/"delimitingname/parameters Filter:FilterOut;--porttoinitializefilter Parms:St<strong>and</strong>ardInterface;--initializationcallmessage CliToFil:PutLineOut;--outputportconnectedtofilter ClientName:charstring;--nameofclientprogram Arguments:charstring;--argumentstoclientprogram

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!