12FISHREFERENCE2.1IntroductionandOverview简介和概述ThissectioncontainsadetailedreferencetotheFISHlanguage.Followingtheintroduction,Section2.2describestherulesofthelanguageandhowvariablesandfunctionsareused.Section2.3explainsFISHstatementsandSection2.4describeshowtheFISHlanguagelinkswithPFC2D.Pre-definedFISHvariables,functionsandarraysaredescribedinSection2.5.这部分包含FISH语言的详细参考。接下来,2.2描述语言规则及如何运用变量和函数。2.3解释FISH陈述。2.4描述FISH语言如何与PFC联系在一起。2.5讲述如何预定义FISH变量、函数和数列。FISHisaprogramminglanguageembeddedwithinPFC2Dthatenablestheusertodefinenewvariablesandfunctions.ThesefunctionsmaybeusedtoextendPFC2D’susefulnessoradduserdefinedfeatures.Forexample,newvariablesmaybeplottedorprinted,specialparticlegeneratorsmaybeimplemented,servo-controlmaybeappliedtoanumericaltest,unusualdistributionsofpropertiesmaybespecified,andparameterstudiesmaybeautomated.FISH是PFC内置的一种编程语言,用户可以自定义变量和函数。这些函数可用来扩展PFC的功能,或者增加用户定义的特征。例如:输出或者打印新的变量、实现特殊的颗粒生成、数值测试中中应用伺服控制、定义特殊的颗粒分布以及自动研究参数。FISHisa“compiler”(ratherthanan“interpreter”).ProgramsenteredviaaPFC2Ddatafilearetranslatedintoalistofinstructions(in“pseudo-code”)storedinPFC2D’smemoryspace;theoriginalsourceprogramisnotretainedbyPFC2D.WheneveraFISHfunctionisinvoked,itscompiledpseudo-codeisexecuted.Theuseofcompiledcode—ratherthaninterpretedsourcecode—enablesprogramstorunmuchfaster.However,unlikeacompiler,variablenamesandvaluesareavailableforprintingatanytime;valuesmaybemodifiedbytheuserbyusingPFC2D’sSETcommand.FISH是一个编程员,而不是一个翻译员。通过PFC数据文件输入的程序转化成一连串命令(以“pseudo指令”的形式)储存在PFC的存储空间。PFC没有保留初始源程序。无论何时援引FISH函数,其编好的pseudo指令执行。编好的指令—不是翻译好的源指令—的作用是使得程序更快的运行。然而,不像编程员那样,FISH在任何时间都可以打印变量的名字和数值,用户可以通过PFC中的SET命令修改数值。FISHprogramsaresimplyembeddedinanormalPFC2Ddatafile—linesfollowingthewordDEFINEareprocessedasaFISHfunction;thefunctionterminateswhenthewordENDisencountered.Functionsmayinvokeotherfunctions,whichmayinvokeothers,andsoon.Theorderinwhichfunctionsaredefineddoesnotmatter,aslongastheyarealldefinedbeforetheyareused(e.g.,invokedbyaPFC2Dcommand).SincethecompiledformofaFISHfunctionisstoredinPFC2D’smemoryspace,theSAVEcommandsavesthefunctionandthecurrentvaluesofassociatedvariables.2FISH程序简单的包含在正常的PFC数据文件里—DIFINE后边的命令行按FISH函数处理;函数以遇到END为结尾。函数也许会援引其他函数,其它函数亦会援引其他函数等等。函数定义的顺序没有影响。因为FISH函数的程序形式储存在PFC的存储空间,SAVE命令会存储函数及相关变量的当值。AsummaryofFISHlanguageandintrinsicnamesisprovidedinSection2intheCommandandFISHReferenceSummary.在CommandandFISHReferenceSummary.的第二章提供FISH语言及其内在名字的总结。2.2FISHLanguageRules,VariablesandFunctionsFISH语言规则,变量及函数2.2.1Lines命令行FISHprogramscanbeembeddedinanormalPFC2Ddatafileormaybeentereddirectlyfromthekeyboard.LinesfollowingthewordDEFINEaretakentobestatementsofaFISHfunction;thefunctionterminateswhenthewordENDisencountered.AvalidlineofFISHcodemusttakeoneofthefollowingforms.FISH程序包含在普通的PFC数据文件中或者直接从键盘键入。DIFINE后边的命令行按FISH函数处理;函数以遇到END为结尾。FISH的有效命令行必须是下述格式中的一种。1.Thelinestartswithastatement,suchasIF,LOOP,etc.(seeSection2.3).2.Thelinecontainsoneormorenamesofuser-definedFISHfunctions,separatedbyspaces—e.g.,fun1fun2fun3wherethenamescorrespondtofunctionswrittenbytheuser.Thesefunctionsareexecutedinorder.ThefunctionsneednotbedefinedpriortotheirreferenceonalineofFISHcode(i.e.,forwardreferencesareallowed).3.Thelineconsistsofanassignmentstatement(i.e.,theexpressionontherightofthe=signisevaluatedandthevaluegiventothevariableorfunctionnameontheleftofthe=sign).4.ThelineconsistsofaPFC2Dcommand,providedthatthelineisembeddedinasectionofFISHcodedelimitedbytheCOMMAND–ENDCOMMANDstatements(seeSection2.3.3).5.Thelineisblankorstartswithasemicolon.1.命令用IF,LOOP等开始。(见2.3)2.如果一行包含一个或更多用户定义FISH函数的名字,以空格号隔开。例如fun_1fun_2fun_3名字与用户所写的函数相对应,这些函数有序执行。一行FISH指令中,函数没有必要比其参考前定义。3(即允许参考在前面)3.命令行包含指派声明(例如等号右边的数学式被运算且其值赋予给等号左边的函数名称或是变量)4.命令行由PFC命令组成,通过COMMAND—ENDCOMMAND分隔FISH指令。命令行包含在FISH指令的一部分里面。5.命令行以分号开始或者结束。FISHvariables,functionnamesandstatementsmustbespelledoutinfull;theycannotbetruncated,asinPFC2Dcommands.Nocontinuationlinesareallowed;intermediatevariablesmaybeusedtosplitcomplexexpressions.FISHis“case-insensitive”bydefault—i.e.,itmakesnodistinctionbetweenuppercaseandlowercaseletters;allnamesareconvertedtolowercaseletters.(NotethatthiscanbechangedwiththecommandSETcasesensitivityon.)Spacesaresignificant(unlikeinFORTRAN)andservetoseparatevariables,keywords,andsoon;noembeddedblanksareallowedinvariableorfunctionnames.Extraspacesmaybeusedtoimprovereadability—forexample,byindentingloopsandconditionalclauses.Anycharactersfollowingasemicolon(;)areignored;commentsmaybeembeddedinaFISHprogrambyprecedingthemwithasemicolon.BlanklinesmaybeembeddedinaFISHprogram.函数的变量,函数名称或者声明必须完整拼写,在PFC命令中不能缩写。不允许有连续的命令行;可以利用中间变量分解复杂的表示式。FISH在默认状态下为“对情况不敏感”—即大写与小写字母之间没有区别,所有的名字都转换为小写字母(注意可以通过(SETcasesensitivityon)命令改变)。有相当大的空间来存储各自的变量、关键词等等(与FORTRAN不同)。在变量或是函数名中不允许含有空格。还留有格外的空间来提高可读性--例如通过缩进循环或是假定子句。分号后面的所有字都被忽略;FISH程序中包含的注释放在分号后面;FISH程序中可以包含空白行。2.2.2ReservedNamesforFunctionsandVariables为函数和变量保留的名字Variableorfunctionnamesmuststartwithanon-numberandmustnotcontainanyofthefollowingsymbols:.,*/+-ˆ=#()[]@;’变量或函数名必须以非数字开始,并且不包含下列符号:.,*/+-ˆ=#()[]@;’User-definednamescanbeanylength,buttheya