Trainer Notes.docx

上传人:b****8 文档编号:29279551 上传时间:2023-07-21 格式:DOCX 页数:24 大小:24.68KB
下载 相关 举报
Trainer Notes.docx_第1页
第1页 / 共24页
Trainer Notes.docx_第2页
第2页 / 共24页
Trainer Notes.docx_第3页
第3页 / 共24页
Trainer Notes.docx_第4页
第4页 / 共24页
Trainer Notes.docx_第5页
第5页 / 共24页
点击查看更多>>
下载资源
资源描述

Trainer Notes.docx

《Trainer Notes.docx》由会员分享,可在线阅读,更多相关《Trainer Notes.docx(24页珍藏版)》请在冰豆网上搜索。

Trainer Notes.docx

TrainerNotes

PML2TrainingNotes

What’sNewinPML2

ObjectsandObjectmethods

Formnamesarenowprecededwith!

!

i.e.setupform_fred

followedby:

setupform!

!

fred

resultsinanerrorbecause!

!

fredwasalreadydefinedinthepreviousassignment

Formsarenowloadeddynamically

returnerrornoalertallowsanerrortobereturnedwithoutanymessages

WhattoavoidinPML2

Commandswithdollarsin

$m-$m+

$W25

Numberedvariables

$v1-120

Thevarcommand

var!

xname

var!

xread

Synonyms

Globalvariables

Whattoavoidinformsandmenus

Dotsingadgetnames

selectorgadgets

Userdata

Pixmapviews

Alertgadgets

Radiogroups

SimpleTextingadgets

Numbersatthebeginningofgadgetnames

Waitontoshowforms

Dolist/pane/sel

What’snotchangedinPML2

Intheory,alloldPMLshouldworkinPDMS11.1.Verylittleoftheoldappwarehasbeenconvertedbecausethiswouldbeawasteofresources.Cadcentrepolicyonconvertingappwaretousenewfacilitiesistoonlyupgradeappwarewhenmodificationsarebeingmadeinthatarea.

Theonlyexceptiontothis,iswherenewfacilitiesincorecodesupersedeorimprovefunctionalityanditisnecessarytowritenewcodetousetheextrafunctionality.

NewEnvironmentVariables

PMLLIB/DIRECTORYNAME

Thisisadirectorywhichissearchedwhenthesystemlooksforfunctionsandforms

PMLTRACEON/OFF

WhensettoON,PMLTRACEwilldisplayatraceofallmacroscalledintheunixcommandshell.Thiscanalsobeswitchedonoroffonthecommandline,soitisprobablybettertosetthevariabletooffandusecommandstocontroltraceasbefore.

ThecommandinPDMSis-PMLTRACEON/OFF

PMLCOMPILEON/OFF

EnvironmentvariablePMLDEBUGONwillwriteatracefile

Availablevariabletypes

$v1oldstylenotrecommended

!

aNamedvariablesbothglobalandlocal!

!

global!

local

NOTE:

!

aisevaluatedastextautomaticallybyusing$!

A(earlyevaluation)

Namedvariablesarenowtypedvariablesasoneofthefollowing

STRING‘TextinquotesorverticalbarsuptoaMaxof254?

char’

REALAnynumber

BOOLEANTRUE,FALSEThesearenottexti.e.‘TRUE’,’FALSE’

ARRAYAnytypeincludingarraysofarraysofanything

OBJECTSAcollectionofdifferentvariablesunderauserdefinedtype

Variablescanbepredefinedasaparticulartypeorreverttotypewhentheyareset

Therearetwowaysofsettingvariables

Var!

a(25)!

aisastring

!

a=25!

aisareal

!

a=‘xyz’!

aisastring

!

a[1]=75!

a[1]isarealelementofarray!

a

Note:

otherelementsinthesamearraycanbeofanytype

!

a=TRUE!

aisBOOLEAN

BewarePreversion11thevarcommandwasusedtosetallvariablesanditproducedastring.Nowwedon’tusevarapartfromcollections.

VariablesmayalsobecreatedbeforetheyareusedusingMethods

!

!

Answer=real()

!

textline=String()

!

test=boolean()

!

squares=array()

Alloftheabovehavethevalue‘unset’

Therearevariouswaysoftestingwhetheravariableexistsorisset:

If(undefined(!

x))then

If(defined(!

x))then

If(unset(!

x))then

If(!

x.unset())then

If(set(!

x))then

If(!

x.set())then

Tomakeavariableundefinedi.e.emptyit.

!

x.delete()

var!

xdelete

Arrays

arraysmaybesparsei.e.youcansetinindexorder

Negativesubscriptsarenotpermitted

Asubscriptofzerocanbeusedbutisnotadvised

doloopfromandtovariablescannowincludeexpressionsandevenfunctions

Arraymethods

!

arraysize=!

arraything.size()Replacesvar!

arraysisze(arraysize(!

arraything))

Setsthevariablearraysizetothenumberofelementsinthearray

!

testarray.clear()Deletesallelementsfrom!

testarray

!

test.removefrom(5,20)Removes20elementsfromelementnumber5

!

new=!

test.removefrom(5,20)Removes20elementsasaboveandcreatesanew

arraywiththe20elementsinside.

!

myarray.append(!

newdata)actslikevar!

arrayappend‘fhjffj’

!

myarray.[27].delete()Deleteselement27ofthearraythearraystillexists

!

myarray.delete()Deletesthearrayentirely

!

line=‘thisisalineoftextwithsomefunnyspaces‘

!

line=!

line.trim(‘lrm’)

trimsthespacesfromthevariablecalled!

line

!

line=‘thisisalineoftextwithsomefunnyspaces‘

!

lines=!

line.split(!

line)

Splitsthestring!

lineintoanarrayofstringscalled!

lines.

Note:

wecouldnotusethesamevariablenamebecauseitisadifferenttype

!

a=!

lines.size()givesthenumberofelementsinthearray

!

a=!

lines.width()givesthenumberofcharactersinthelongestwordofthearray

Noresultmethods.

!

lines.sort()sortsthearray!

linesandreturnsthearrayinitssortedform

!

lines.invert()invertsthearrayorderfirsttolastetc.Thesemethodsworkonlyontheoriginalarray.Attemptstosetanotherarrayresultsinanerror.

i.e.!

new=!

lines.sort()Givesanerror

Theoldmethod.

!

ind=!

lines.sortedindices()Producesasortedindexwithoutchangingtheoriginalarray.Thiscanbeusedtosortparallelarraysinthesamewayasbefore.

!

lines=!

lines.relindex(!

ind)Re-ordersanarrayaccordingtotheorderofarray!

ind

Ifappliedtotheoriginalarray,itwouldhavethesameeffectasasimplesort,itsuseistosortparallelarrays.

TheCurrentElementvariable

Thereisoneglobalvariablewhichisalwayssetbythesystemtobetheelementyouarepositionedatinthedatabase-thisiscalled!

!

CE.!

!

CEisanobjectoftypeDBREF.Itsattributesaredescribedasmembersoftheobject.

e.g.

!

tem=!

!

ce$*createsavariablewhichisacopyof!

!

ce

1

qvar!

tem$*QueriestheattributesoftheDBREFpointedtoby!

item

=8196/8

NAME->‘DA/2000’

TYPE->‘SITE’

LOCK->FALSE

OWNER->=8196/0

DESC->‘MAINREACTORAREA’

FUNC->‘’

PURP->‘’

NUMB->0

AREA->0

POS->E0mmN0mmU0mmWRT/*

ORI->YisNANDZisUWRT/*

MODU->‘’

ORRF->Unset

STMF->Unset

:

MATERIAL->‘CarbonSteel’

qvar!

item$*gives

/DA/2000$*withoutalloftheotherstuff

!

item$*asacommand,doesnothing

$!

item$*navigatesto/DA/2000

Queryingattributes

qvar!

item.pos$*gives

E0mmN0mmU0mmWRT/*

ORIGIN=8196/0

UP0

EAST0

NORTH0

qvar!

item.e$*querytheeastposition

0

qvar!

item.pos.origin$*givesalloftheattributesof=8196/0

qvar!

item.pos.origin.lock$*givesthelockof=8196/0

qvar!

item.pos.wrt(=8196/32)$*usesthemethodWRT(DBREF)toextracta$*positionrelativetosomeotherdatabase$*reference

METHODS/FUNCTIONS

Differentdatatypesinpmlhaveassociatedbuiltin‘methods’whichmaybeusedtoconvertorreaddatainaparticularway.Somemethodsaresimilartothebuiltinfunctionspreversion11.1asintheexamplebelow:

!

NCHARS=!

MYSTRING.LENGTH()$*THISISAMETHOD

!

NCHARS=LENGTH(!

MYSTRING)$*THISISAFUNCTIONCALL

Thepreversion11.1syntaxforthefunctioncallwouldhavebeenasfollows:

VAR!

NCHARSLENGTH(|$!

MYSTRING|)$*THISISA10.5FUNCTIONCALL

Thedifferencebetweenthe10.5exampleandthe11.1exampleisthatversion11nowreturnsatypedvariable(REAL)whereversion10.5wouldhavereturnedastring.

MethodsarebuiltinforvariousdatatypesandarelistedinappendixAoftheCustomisationguide.

Blockevaluationofarrays

Blockevaluationisamethodofsteppingthrougheachelementofanarrayandperformingsomeaction.Ineffect,itislikeasinglecommanddoloop.

Toperformblockevaluation,therearetwostages:

Firstyouneedtodefinetheexpressionwhichwilloperateonthearrayelements

Second,youneedtoapplytheexpressiontoanarray

Theexpressionisstoredinavariableandisdefinedasfollows:

!

EXPRESSIONVAR=OBJECTBLOCK(‘!

!

ARRAYNAME[!

EVALINDEX]*2’)

the!

!

arrayname[!

evalindex]bitiseffectivelythenameofthevariablebeingoperatedonbytheexpression.Intheexampleabove,theresultwouldbetomultiplyallofthenumbersintheinputarrayby2.Thevariable!

evalindexisaspecialvariableusedinblockevaluation.Anyothervariablenamewillnotwork!

Toapplytheexpressionisasfollows:

!

!

newarray=!

!

arrayname.evaluate(!

expressionvar)

Thiscreatesanarraycalled!

!

newarraycontainingthenumbersoftheoriginalarraymultipliedby2.Theoriginalarraycanalsobemodifiedusingthismethod:

!

!

arrayname=!

!

arrayname.evaluate(!

expressionvar)

Herearesomesimpleexamples

!

text='thisisalineoftext'

!

myarray=!

text.split()

Thiscreatesanarraycalled!

!

myarraywithsixelements

!

myarray[1]=‘this’

!

myarray[2]=‘is’

!

myarray[3]=‘a’

!

myarray[4]=‘line’

!

myarray[5]=‘of’

!

myarray[6]=‘text’

Nowwecandefinesomeblocks

!

extractchar1=objectblock('subs(!

myarray[!

evalindex],1,1)')

!

new=!

myarray.evaluate(!

extractchar1)

Thisextractsthefirstcharacterofeachwordintoandarraycalled!

new

givingthefollowing:

!

new[1]=‘t’

!

new[2]=‘i’

!

new[3]=‘a’

!

new[4]=‘l’

!

new[5]=‘o’

!

new[6]=‘t’

!

extractchar1=objectblock('upcase(subs(!

myarray[!

evalindex],1,1))')

!

new=!

myarray.evaluate(!

!

extractchar1)

Thisdoesthesameasbefore,butalsochangestheletterstouppercase

!

new[1]=‘T’

!

new[2]=‘I’

!

new[3]=‘A’

!

new[4]=‘L’

!

new[5]=‘O’

!

new[6]=‘T’

!

extractchar1=objectblock('upcase(subs(!

myarray[!

evalindex],1,1))&|fred|')

!

new=!

myarray.evaluate(!

extractchar1)

Thisdoesasbefore,butusesthe&charactertoappendthestringfredtotheresult

!

new[1]=‘Tfred’

!

new[2]=‘Ifred’

!

new[3]=‘Afred’

!

new[4]=‘Lfred’

!

new[5]=‘Ofred’

!

new[6]=‘Tfred’

!

extractchar1=objectblock('!

!

t

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 人文社科 > 军事政治

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1