资源预览内容
第1页 / 共21页
第2页 / 共21页
第3页 / 共21页
第4页 / 共21页
第5页 / 共21页
第6页 / 共21页
第7页 / 共21页
第8页 / 共21页
第9页 / 共21页
第10页 / 共21页
亲,该文档总共21页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
PML2Training NotesWhats New in PML2Objects and Object methodsForm names are now preceded with !i.e. setup form _fredfollowed by : setup form !fredresults in an error because !fred was already defined in the previous assignmentForms are now loaded dynamicallyreturn error noalertallows an error to be returned without any messagesWhat to avoid in PML2Commands with dollars in $m- $m+ $W25Numbered variables $v1-120The var command var !x name var !x readSynonymsGlobal variablesWhat to avoid in forms and menusDots in gadget namesselector gadgetsUserdataPixmap viewsAlert gadgetsRadiogroupsSimple Textin gadgetsNumbers at the beginning of gadget namesWaiton to show formsDo list/pane/selWhats not changed in PML2In theory, all old PML should work in PDMS11.1. Very little of the old appware has been converted because this would be a waste of resources. Cadcentre policy on converting appware to use new facilities is to only upgrade appware when modifications are being made in that area.The only exception to this, is where new facilities in core code supersede or improve functionality and it is necessary to write new code to use the extra functionality.New Environment VariablesPMLLIB/DIRECTORYNAMEThis is a directory which is searched when the system looks for functions and forms PMLTRACEON/OFFWhen set to ON, PMLTRACE will display a trace of all macros called in the unix command shell. This can also be switched on or off on the command line, so it is probably better to set the variable to off and use commands to control trace as before.The command in PDMS is -PML TRACE ON/OFFPMLCOMPILE ON/OFFEnvironment variable PMLDEBUG ON will write a trace fileAvailable variable types$v1old style not recommended!aNamed variables both global and local !global !localNOTE: !a is evaluated as text automatically by using $!A (early evaluation)Named variables are now typed variables as one of the followingSTRINGText in quotes or vertical bars up to a Max of 254? charREALAny numberBOOLEANTRUE,FALSEThese are not text i.e. TRUE,FALSEARRAYAny type including arrays of arrays of anythingOBJECTSA collection of different variables under a user defined typeVariables can be predefined as a particular type or revert to type when they are setThere are two ways of setting variablesVar !a (25) !a is a string!a = 25!a is a real!a = xyz!a is a string!a1 = 75!a1 is a real element of array !a Note: other elements in the same array can be of any type!a = TRUE!a is BOOLEANBeware Pre version 11 the var command was used to set all variables and it produced a string. Now we dont use var apart from collections.Variables may also be created before they are used using Methods!Answer = real()!textline = String()!test = boolean()!squares = array()All of the above have the value unset There are various ways of testing whether a variable exists or is set:If(undefined(!x)thenIf(defined(!x)thenIf(unset(!x)thenIf(!x.unset()thenIf(set(!x)thenIf(!x.set()thenTo make a variable undefined i.e. empty it.!x.delete()var !x delete Arraysarrays may be sparse i.e. you can set in index order Negative subscripts are not permittedA subscript of zero can be used but is not adviseddo loop from and to variables can now include expressions and even functionsArray methods!arraysize = !arraything.size() Replaces var !arraysisze (arraysize(!arraything)Sets the variable arraysize to the number of elements in the array!testarray.clear()Deletes all elements from !testarray!test.removefrom(5, 20)Removes 20 elements from element number 5!new = !test.removefrom(5,20)Removes 20 elements as above and creates a new array with the 20 elements inside.!myarray.append(!newdata)acts like var !array append fhjffj!myarray.27.delete()Deletes element 27 of the array the array still exists!myarray.delete()Deletes the array entirely!line = this is a line of text with some funny spaces !line = !line.trim(lrm) trims the spaces from the variable called !line!line = this is a line of text with some funny spaces !lines = !line.split(!line) Splits the string !line into an array of strings called !lines.Note: we could not use the same variable name because it is a different type!a = !lines.size() gives the number of elements in the array!a = !lines.width()gives the number of characters in the longest word of the arrayNo result methods.!lines.sort() sorts the array !lines and returns the array in its sorted form!lines.invert()inverts the array order first to last etc. These methods work only on the original array. Attempts to set another array results in an error.i.e. !
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号