Home

META SCRIPTS Table of Contents

image

Contents

1. REPEAT This is a looping construct Le it gives you the opportunity to loop through a set of commands until a specified condition is met UNTIL The expression must be in round brackets Le and must evaluate to true T non zero orfalse F zero You may use several lines for clarity You must use curly braces to block multiple statements There are two forms of this statement Form 1 Form example REPEAT action REPEAT LET FW109 SV FW109 SV 1 UNTIL lt expr gt UNTIL FW109 PV gt 120 Form 2 Form example REPEAT Exercise valve LET tm 0 Zactlong s REPEAT UNTIL lt exprn gt IF FC109 MV lt 20 LET FCI09 MVe100 ELSE LET FC109 MV 20 SLEEP 120 tm tm 2 UNTIL tm gt 10 UM ENG 3 1 0 10 47 SLdIXOS VLAN Meta Scripts WHILE Table 33 The WHILE Command Rev 3 WHILE format form This is a looping construct similar to the RE that the condition is evaluated at the start of the loop The expression must be in round brackets Le lt exprn gt and must evaluate to true T non zero or false F zero You may use several lines for clarity You must use curly braces to block multiple statements Format WHILE lt exprn gt lt multiple commands gt iP example WHILE FM109 PV lt 120 EAT UNTIL With the exception FM109 SV FM109 SV 41 LET S
2. LOOP This command enables you to work through a database or a view of a database and THROUGH process the records Generally you would create a view of the database and filter it if necessary before running this command so that only the selected records are processed Arguments entity The database entity or view of the database lt entity gt meta script statements The statements in between the curly brackets that are executed for all the records in the view form example Form LOOP THROUGH lt entity gt LOOP THROUGH BATCH9 lt meta script statements gt IF ABS BATCH9 MSRT BATCHY BORT lt 3 359 LET BATCH9 OFFSPEC T LSE LET BATCH9 OFFSPEC F This example goes through a database and sets the field OFFSPEC true if the difference between the required ratio RQRT and the measured ratio MSRT is greater than 3 5 UM ENG 3 1 0 10 61 SLdIXOS VLAN Meta Scripts Rev 3 Table 50 The LOOP THROUGH Command Example 2 example2 CREATE VIEW BATCHSELECT AS SELECT FROM BATCH9 WHERE DT gt fromDate AND DT lt toDate ORDER BY DT PRINTLN Offspec batches for selected period LOOP THROUGH BATCHSELECT IF BATCHSELECT OFFSPEC PRINTLN iBatchSelect DT 1 BATCHSELECT RIMS BATCHSELECT RTRQ BATCHSELECT BATCH
3. This second example first creates a view of only the data that corresponds to the period of interest Le between the dates fromDate and toDate It then loops through the database and prints out a very simple report of the of f spec records that include the date deviation from spec and the Batch number UM ENG 3 1 0 10 62 Meta Scripts Rev 3 CREATE VIEW and DROP VIEW Table 51 The CREATE VIEW and DROP VIEW Command Statement Description CREATE VIEW and DROP VIEW The CREATE VIEW command creates a view of a database entity The view is a subset of the database that you may have applied filtering and sorting to The created view can be used in every respect like the database entity itself The DROP VIEW command simply drops the view and frees up the memory This is a command that allows for more efficient usage of the memory The DROP VIEW command only works on view entities and dbf entities NOTE Original CREATE VIEW View of the Database Entity Entity Selects fields filters orders Example Example BATCH9 5 BATVU This view is probably the most important of the SQL like instructions and it is worth while getting to know it well format example CREATE VIEW lt viewName gt AS SELECT lt selectSpec gt Choose the fields you wish to view FROM lt entity gt WHERE lt filterExprn gt Filter out t
4. oplogFilter T IF filterSectionFlag LET plogrilter If the SECTION checkbox is depressed then add a section component to the filter string Note that the AND means FilterSection both criteria must be satisfied CREATE VIEW OPVIEW AS oplogFilter AND SECTION o SELECT You could add further components to the filter string as desired FROM OPLOG WHERE oplogFilter ORDER BY OPDATE OPTIME I Now that the filter string has been created by the preceding code it can be used easily within the WHERE clause UM ENG 3 1 0 10 66 Meta Scripts Rev 3 Table 55 The CREATE VIEW and DROP VIEW Command Statement Description Example 5 This view displays only those records that are associated with a given value One to Many View example CREATE VIEW CUSTVIEW AS An entity called SELECT BATCH has been FROM BATCH9 created which looks at the batch9 dbf WHERE CUSTOMER CUSTOMER NAME database The WHERE clause filters out only those batches from the BATCH O database that are associated with the customer currently being pointed at in the customer database CUSTOMER BATCHI9 NAME field of database CUSTOMER CUSTOMER field of database BATCH9 custView This can be used to dynamically
5. DAYOQ DAY tstamp DAY 22 If no argument is specified this function returns the current day of the month value 1 31 Ifa timestamp argument is specified then it returns the day of the month component of the timestamp DAYS m DAYS duration DAYS 12 Duration of 12 days If the DAYS function is supplied a single numeric argument it will return a time duration based on the number of days specified by the argument The argument may include a fractional value This is converted to the appropriate time units and rounded to the nearest millisecond If the argument supplied is a time duration value then the function returns a numerical value which is the number of days in the time duration argument DMYc tstamp DMY NOW 18 10 92 Returns a string representation of the timestamp specified as an argument in DD MM YY format DOW tstamp DOW OW DATE 1993 9 18 Sunday D 1 7 Saturday Returns a numeric representation of the day of the week of the given time stamp value provided as an argument If no argument is supplied then the current day of the week number is returned DOY tstamp DOY DATE 1993 6 3 215 Returns a numeric representation of UM ENG 3 1 0 10 96 Meta Scripts Rev 3 Function Example Comment DOY the day of the year of the given time stamp value provided as an argument If no argument is supp
6. the parent tree Global and Local Variables How it works The system uses the following algorithm to determine whether to use a LOCAL or GLOBAL variable i Whenever a variable is encountered in a meta script a search is made back up the meta script and into the parent windows for a declaration ii The system uses the first declaration it finds I e if a LOCAL declaration is found that will be used if a Global declaration then that variable will be used iii If there are no declarations in the meta script or the parents of the meta scripts then the variable will be deemed LOCAL to that meta script iv The exception is that if the defaultGlobal argument is used in the start up command in which case ALL variables are deemed GLOBAL Clearly from the above it is possible to have several LOCAL variables of the same name in different meta scripts and one GLOBAL variable Technical Note If you specify LOCAL variables in the INIT EARLY or INIT LATE meta scripts then since these meta scripts are the first meta scripts encountered in a graphic the variables will be available to all the meta scripts and children windows by inheritance See the note on the next page about suggested rules for using GLOBAL and LOCAL variables UM ENG 3 1 0 10 19 SLdIXOS VLAN Meta Scripts Rev 3 GLOBAL LOCAL and not specified variables Suggested Rules We advise using the following rules to choose whether to u
7. HEP 1 BREAK Table 34 The BREAK Command BREAK The BREAK statement is used to abandon the current looping construct and go to the next sequential statement The BREAK command can be used with both the REPEAT UNTILand also the WHILE construct format Format example WHILE exprn gt WHILE FC109 1S CAS lt program statements gt LET FCLO9 8V FC109 MV 2 gt IF lt exprn gt BREAK IF L109 PV gt 90 BREAK lt progr SLEEP 17 FC109 LS MAN FC109 MV 0 UM ENG 3 1 0 10 48 Meta Scripts Rev 3 CONTINUE Table 35 The CONTINUE Command CONTINUE The CONTINUE statement is used to skip the remaining statements in the block but to still continue the looping from the top Like the BREAK command the CONTINUE command can be used in both the REPEAT and WHILE constructs format Format example WHILE lt exprn gt WHILE BATVU RECNO lt 400 i Saccilons gt FETCH NEXT OF BATVU IF lt exprn gt CONTINUE PRINTLN BATVU CUSTOMER actions IF BATVU DEV limit CONTINUE PRINTLN Bad Batch RETURN Table 36 The RETURN Command RETURN This statement is used to stop the execution of the program so as to return control to the calling program possibly with an optional return val
8. lt entity gt lt entity gt OF OF We Fr entity entity search Expo CREATE VIEW EATE VIEW lt viewName gt AS R H R FR OM lt entity gt RE lt filter LECT lt selectSpec gt Exprpy DER by orde alternative OM FILE eril PSpec gt ly eName gt LOOP THROUGH LOOP THROUGH lt entity gt lt meta script Statements gt Note lt entity gt can be an entity or a view CREATE TABLE VARIABLE CREATE TABLE VARIABLI lt tableName gt FIELDS lt fieldNamel gt lt fldFormatl gt lt fieldName2 gt fldFormat2 fieldNameN lt fldFormatN gt CREATE HISTORICAL VIEW er WI WH AN LECT ldNamel E HISTORICAL Vil sentityl attrel ldName2 ieldNameN ERE TIME D TIME entityl attrl lt attrN entityN gt TH duration period hForm gt etartlstanp lt lt endTstamp gt EW lt tableName gt UM ENG 3 1 0 ERR lt entity gt B returns the error number Q if success DBERRSTR entity returns an error message PROCESSINGVARIABLE empty if success 10 53 SLdIXOS VLAN Meta Scripts INSERT Rev 3 Table 42 The INSERT Command IN
9. ORDER BY lt orderSpec gt This specifies the order in which the records or rows are sorted in the database Once again it must be a string that the RDBMS understands The default is ascending order Simple example form example CREATE VIEW lt viewName gt AS CREATE VIEW NUBATCH AS SELECT SelectSpec SELECT DT MSG FROM entity FROM BATCH9 WHERE lt filter Exprn gt ORDER BY lt orderSpec gt This example creates a simple view that only contains the fields columns DT and MSG It does not use the optional WHERE and ORDER BY clauses UM ENG 3 1 0 10 64 Meta Scripts Rev 3 Table 53 The CREATE VIEW and DROP VIEW Command Statement Description Example 2 example CREATE VIEW OPLOG AS SELECT Select all columns in the FROM OPLOG table WHERE DTOS DT gt Create a string from the dBase STR NOW DAYS 30 field DT MMDD Note DTOS is a dBase function DATI GI CETT Create a date string Add the string CCY YMMDD to corresponding to the date 30 complete the required string that is days previous to the current sent to the RDBMS date Refer to the DATESTR tstamp format expression description in the TIME amp DATE expressions section The above WHERE clause once executed would create the string WHERE DTOS DT gt
10. Where the meta script is to run in the background E g for simulators For text based reports For complex database manipulation scripts such as environmental programs etc NOTE The mshe11 program like all Macro View programs must be started from the configuration directory This is usually set up through the MACRODIR environment variable Starting the mshell or wmshell There are two ways you can use the mshe11 and wmshe1l i ii UM ENG 3 1 0 Interactive mode for UNIX Enter the meta script commands directly onto the screen To execute the program hit the CNTRL D keys together when the program is fully entered E g cd MACRODIR This is normally set to the configuration directory mshell 1 This will give you a flashing cursor from where you can type in meta script commands PRINTLN NOWO CNTRL D Tue 23rd Sept 8 45am Hitting the ENTER key will return you back to the command line prompt Background mode for UNIX In the mshe11 command specify the filename of the meta script file to be executed I e mshell fileName amp this will start the mshe11 program and execute it in the background Interactive mode for NT Enter the meta script commands directly onto the screen To execute the program hit the ENTER Key when the program is fully entered E g cd 7MACRODIR This is normally set to the configuration directory wmshell 1 This will give you a flashing cursor from where yo
11. actions TERMINATE UN lt exprn gt SLEEP lt exprn gt ET tagName gt RUN lt expr gt Terminates the program that is running the meta SEript TERMINATE RUN lt exprn gt BEGIN SCRIP Bourne shell script END SCRIPT UM ENG 3 1 0 10 44 Meta Scripts IF ELSE Rev 3 Table 30 The IF ELSE Command IF ELSE The IF ELSE control statement provides the ability to choose a set of program statements to execute depending upon the result of an expression evaluation If the expression evaluates to non zero i e TRUE then the set of program statements associated with the IF are executed otherwise the set of program statements associated with the ELSE are executed The ELSE is optional format The expression to be evaluated must be in round brackets It must evaluate to T i e non zero or F i e zero The IF part of the statement is executed when the expression is true and the ELSE part if present is executed when the expression is false The curly brackets or braces must enclose groups of statements in a block to be executed There are various forms of the IF ELSE statement as shown below Form 1 form examples IF
12. ABS EndTime startTime 05 00 00 Returns the absolute value of a time duration Time duration s can have a negative component E g 5 hours back in time This version of the ABS function removes the negative association with the time duration value and returns the result BETWEEN tI t2 t3 BETWEEN dl d2 d3 BETWEEN StartTime Now EndTime I e true Returns an indication of whether Now is between the startTime and the endTime This is equivalent to t1 gt t2 AND tl t3 A similar form of functionality is applied when all arguments are time duration s CDOW timestamp CDOW CDOW DATE 1993 8 18 Wednesday Returns a string representation of the day of the week of the given time stamp value provided as an argument If no argument is provided then the current day of the week is returned CMONTH timestamp CMONTH CMONTH NOW October Returns a string representation of the month name of the time stamp argument If no argument is specified then the current month is returned CVTDATE datestr CVTDATE 19910212 02 12 92 Converts a string argument representing a point in time to a time stamp based on the default format string specified by the SET DATE FORMAT TO command CVTDATE timestr format CVTDATE 19910212 CCYYMMDD Feb 12th 199 Converts a string the first argument representing a po
13. Table 71 String Related Functions Function Example Comment ALLTRIM string ALLTRIM Hello Strips both leading and trailing spaces Hello from a string and returns the result ASC string ASC ABCDE Returns the ASCII code for the first 65 character found in the string AT s1 s2 number AT AUT Going to AUTO This function searches for string s1 AT s1 s2 10 within string s2 If it finds an occurrence it returns the character position of string s1 within s2 The optional numeric argument identifies which occurrence of s1 in s2 is required e g the first second third etc occurrence CHR number CHR 66 Returns a single character string where p the character used is based on the ASCII character equivalent of the number passed as an argument ISALPHA string ISALPHA AUT Returns true if all of the characters in 1 the string are alphabetic characters I e a z or A Z Spaces are ignored Le LEUE ISLOWER string ISLOWER AUT Returns true if all of the characters in 0 the string are lower case alphabetic characters Spaces are ignored lop false ISNULL ent attr ISNULL LDB VL1 Will return a 1 true value only if the entity attribute holds a null field This is useful for reports Refer to LET on pagel8 ISNUMERIC string ISNUMERIC AUT Returns true if all of the characters in 0 the string are valid numeric characters E g 0 9 E Spaces
14. lt exprn gt lt action gt IF L109 PV gt 80 LET FW109 SV 0 IF lt exprn gt IF L109 PV gt 80 Form 2 f zactions ET FW109 LS MAN ET FW109 MV 0 i IF FW109 MV 20 LET Form 3 Lee ee aes a MV 100 l BEE vm ELSE LET FW109 MV 0 Form 4 IF lt exprn gt IF AccessLevel 80 lt actions gt DELETE FROM OPLOG WHERE CURRENT FETCH LAST OF OPLOG ELS H i SE lt actions gt ET errMsg No authority DISPLAY WINDOW errpop UM ENG 3 1 0 10 45 SIdRDS VLAN Meta Scripts Table 31 The IF ELSE Command Rev 3 multiple lines You may use multiple lines in the expression to improve clarity example IF L109 PV gt 90 AND FM109 LS MAN AND FM109 MV 30 INSERT INTO OPLOG FIELDS TM COMMENT VALUES NOW PANIC opening up FM109 LET FM109 MV 100 nested IF You may nest the IF statements Remember to use the braces to establish the correct grouping of the statements I e format IF lt exprnl gt IF lt exprn2 gt lt multiple actions gt ET S E multiple actions ELSE lt multiple actions gt NOTE Multiple Actions after an IF must be inside a set of braces indenting n Indenting is highly recommended to show the blocked structure clearly UM ENG 3 1 0 10 46 Meta Scripts REPEAT UNTIL Table 32 The REPEAT UNTIL Command Rev 3
15. If no argument is specified then this HOUR tstamp 9 function returns the current hour value 1 24 If a timestamp UM ENG 3 1 0 10 97 SLdIXOS VLAN Meta Scripts Rev 3 Function Example Comment argument is specified then it returns the hour component of the timestamp HOURS h HOURS duration HOURS 15 15200200 000 HOURS 34 09 03230200 VUH If the HOURS function is supplied a single numeric argument it will return a time duration based on the number of hours specified by the argument The argument may include a fractional value This is converted to the appropriate time units and rounded to the nearest millisecond If the argument supplied is a time duration then the return value is numeric and indicates the number of hours in the time duration argument MDY tstamp MDY NOW IDJTB O3 Returns a string representation of the timestamp specified as an argument in MM DD YY format MINUTE Q MINUTE tstamp MINUTE If no argument is specified this function returns the current minute value 0 59 If a timestamp argument is specified then it returns the minute component of the timestamp MINUTES m MINUTES duration MINUTES 12229 007123715 000 If the MINUTES function is supplied a single numeric argument it will return a time duration based on the number of minutes specified by the argument The argument may
16. example using arguments Refer to the second example in the Trigger widget of the graphics sections example using the in built functions example n END PutText Sl my Button DISPLAY WINDOW voy dgdate Paste FRAM E 8000 100 0 EARCH TO SEND SetProgram n Hi 0 18000 19000 RELA IIVE TO SCR TO n myB tton en EEN In the INIT program the meta script sends a message PutText with the label of the button Search as an argument This is sent to an object called myButton Now a meta script program is sent to the same key Note the use of n to get a line feed UM ENG 3 1 0 10 35 SLdIXOS VLAN Meta Scripts Rev 3 Table 22 The SEND lt Message gt TO Command example using example metafile object In a text button action program enter SEND Display schemat statl1 TO plant StatusDisplay The program associated with the button called OK in the metafile causes a file called statl to be displayed in the display area called StatusDisplay This display area is in the window called plant which must already be visible example using example Bell This makes the computer beep SEND Bell TO MetaFile example SEND Bell 50 500 1000 TO Metarile The general format is SEND Bell TO MetaFile SEND Bell volume TO MetaFile SEND Be
17. lt lt endTstamp gt DATE DATESTR DURATION DURATIONSTR NOW TIME SET DATE suy hy TI ESTR FORMAT TO MMIDDIYYT UM ENG 3 1 0 10 9 SLdIXOS VLAN Meta Scripts Rev 3 10 4 Designing Meta Scripts When designing your meta scripts you should follow the normal guidelines that you would use for any programming language In particular First decide on the structure of the meta scripts and how these meta scripts are to achieve the desired functionality Make the meta script as clear and simple as possible Avoid clever programming The program should be readable and understandable if read over the telephone Use variable names that are easily understood A well chosen variable name is often more valuable than a comment We strongly advise that you keep the size of the meta scripts to less than 10 lines Longer programs are better done when the customer has more experience or has attended the advanced programming class If you are having problems debugging the meta script we recommend you use the meta script tracer described in the graphics chapter This tool provides a clear indication of what is happening in the meta script 10 5 Entering and Executing the Meta Scripts The executable file which is used to execute meta script commands is called mshell in the UNIX system and wmshell exe in the Windows NT system There are a number of ways
18. the last database command used on the database entity called OPLOG UM ENG 3 1 0 10 77 SLdIXOS VLAN Meta Scripts Table 65 The DBERR and DBERRSTR Command Rev 3 FETCH NEXT OF OPLOG IF OPLOG DBERR SqlAtBottom PRINTLN You have reached the bottom of the log database n In this example we are looking specifically for the end of the file message Note that you can operator example example INSERT INTO OPLOG This returns a code that is non zero if FIELDS DT TM ENTRY the last command VALUES DATESTR NOW in this case the TIMESTR NOW INSERT command just performed on entryValue the entity OPLOG was not successful IF OPLOG DBERR 4 OO PRINTIN This returns a non Error adding record empty string if the INSERT command to operator logs database n wis Hot successtul OPLOG DBERRSTR This message will be printed out Example 2 example use the numeric code 20 or the name of the variable SqlAtBottom in the IF statement UM ENG 3 1 0 10 78 Meta Scripts Rev 3 DB Error Codes and Strings Table 66 DB Error Codes and Strings 0 SqlSuccess The success indicator code 1 SqlError A general error indication In this case the error situation is not associated with a particular error number The error description can be obtained via the DBERRSTRO functio
19. 0 Rev 3 The INSERT Command 10 55 The UPDATE Command 10 56 The DELETE Command 10 57 The FETCH Command 10 58 The FETCH Command 10 59 The FETCH Command 10 60 The LOOP THROUGH Command 10 61 The LOOP THROUGH Command 10 62 The CREATE VIEW and DROP VIEW Command 10 63 The CREATE VIEW and DROP VIEW Command 10 64 The CREATE VIEW and DROP VIEW Command 10 65 The CREATE VIEW and DROP VIEW Command 10 66 The CREATE VIEW and DROP VIEW Command 10 67 The CREATE VIEW and DROP VIEW Command 10 68 The CREATE VIEW FROM FILE lt filename gt Command 10 69 The CREATE TABLE VARIABLE Command 10 71 The CREATE TABLE VARIABLE Command 10 72 The CREATE HISTORICAL VIEW Command 10 73 The CREATE HISTORICAL VIEW Command 10 74 The CREATE HISTORICAL VIEW Command 10 75 The CREATE HISTORICAL VIEW Command 10 76 The DBERR and DBERRSTR Command 10 77 The DBERR and DBERRSTR Command 10 78 DB Error Codes and Strings 10 79 Operators 10 81 Operators 10 82 Special MacroView Functions 10 83 Miscellaneous Functions 10 84 String Related Functions 10 86 Trigonometric Functions 10 89 Binary Arithmetic Functions 10 90 Date and Time Functions 10 94 Date and Time Operators 10 101 Date and Time Related Set Actions 10 103 Time Stamp and Duration Format String Options 10 103 10 4 Meta Scripts Rev 3 10 10 1 10 2 Meta Scripts Meta scripts are programs that are written in the meta script language and are run from within the MacroView environment This is the preferred prog
20. 19940623 Example 3 example CREATE VIEW ALARMS AS SELECT FROM ALARMDB 4 amp 4 Create a view called ALARMS WHERE ACKN F OR from the entity ALARMDB NORMAL F ORDER BY DI PRIORITY View only the alarms that are either unacknowledged or have not returned to normal Order the view by DT primary order amp PRIORITY secondary order I e The view is broken up into days and within each day the alarm priorities are high priority first UM ENG 3 1 0 10 65 SLdIXOS VLAN Meta Scripts Rev 3 Table 54 The CREATE VIEW and DROP VIEW Command Statement Description Example 4 In this example a filter pop up window within a graphic is used to interactively create a filtered view The window could look like this below more complex 3 FILTER filterDateFlag DATE 19980728 filterDate SELECTION POWER filterSection CANCEL This triggers the metascript filterSectionFlag The following meta script would be executed once the OK button is pressed example IF filterDateFlags _ If the filterDateFlag check box is depressed create a DATE component to LET oplogFilter the filter string OPDATE CTOD filterDate ELSE Otherwise just set the date component of the string to true This will show all dates
21. 83 SLdIXOS VLAN Meta Scripts Miscellaneous Functions Rev 3 Table 70 Miscellaneous Functions Function Example Comment ABS number ABS 13 4 34 6 21 2 Absolute of a real number I e remove negative sign information if present BETWEEN x x1 x2 BETWEEN 5 0 10 1 I e true Returns an indication of whether the first argument x is within the range specified by the second and third arguments x1 and x2 I e x gt x1 AND x lt x2 Note that the arguments must be all of the same value type but can be numbers strings time stamps or time duration s CEILING number CEILING 12 37 Returns the smallest integer that is 13 greater than or equal to the numeric argument GETEN V string GETENV MACRODIR This function returns a string that is the value of the environment variable FLASH number FLASH 10 This function cyclically returns the Returns 16 then specified number and then zero then 10 then 0 etc continuously The cycle period is designed for use in graphic displays where graphics need to flash to illustrate a state FLOOR number FLOOR 12 37 Returns the largest integer that is less 12 than or equal to the numeric argument INT number INT 12 37 Returns the integer component of a 12 number MIN x y MIN 12 7 26 5 3 Returns the minimum value in a series 5 3 of numbers MAX
22. Navigator you can call up the internal alarm summary which will show these messages mshell meta shell and wmshell exe Documentation The next sections provide a more formal overview of the meta script language The sections include e Variables The rules associated with choosing variable names UM ENG 3 1 0 10 12 Meta Scripts e Action statements Rev 3 Statements that do something E g LET PRI NT Program control D ISPLAY WINDOWetc Where you can select which parts of the script are executed E g IF ELSE statements e Database Functions These are SQL like statements that enable you to easily work with databases E g INSERT FETCH CREATE VIEW e Historical Views Enable you to treat historical data as if it were in a database Operators amp Functions These manipulate the values Examples include Operators Functions String Functions Trigonometric Binary e Date amp Time Functions lt gt AND NOT OR ABSQ INTQ RANDO VALO CHRQ SUBSTR SINO COSOQ TANO BITO BINANDO BINORO Functions that relate to the manipulation of date and time information E g DATE TIME NOW DURATIONetc UM ENG 3 1 0 10 13 SLdIXOS VLAN Meta Scripts Rev 3 10 6 Variables The table below is a summary of the various types of variables available for use in the Macro View system
23. SetUpdateRate 200 TO MetaFile The forms editor and entering the update rate in the header form Refer to the graphics chapter for more details The start up command with the updateRate seconds command line parameter UPDATE 2 5 grouped with itself will set the update rate of the metafile to 2 5 seconds UM ENG 3 1 0 10 37 SLdIXOS VLAN Meta Scripts Rev 3 Table 24 The SEND lt Message gt TO Command Example using Focus example This program asks the Display manager to place the Focus on an object called pageInput The user s keystrokes will be sent to the target object without having to manually position the cursor SEND Focus TO pageInput Note This is an extremely useful command for busy input screens Note The user can always move the focus from object to object using the TAB forward and shift TAB backward keys For more information on Focus see the section Focus Issues in the Graphics chapter Example using DisableClose example This program prevents the user from closing the window using the Window Manager pulldown menu located in the SEND DisableClose TO border of the window MetaFile example SEND EnableClose TO EnableClose re allows the pulldown MetaFile close option Note This may not work with all window managers Example using Update example This program forces a dynamic update of all the variable
24. These are discussed in more detail in Table3 Variable Definitions on page10 Variable types summary Table 3 Variable types summary Variable Type Example Descriptions User Variables temp These variables may be created and used freely in meta numDays scripts There are LOCAL and GLOBAL variables See Global and Local Variables on pagel3 System Variables HalfGreen These variables are reserved by the system and have specific meanings as discussed in the section System UserName Variables on pagel2 SetRequest ENTITY ATTRIBUTE FIC100 PV These variables are linked to the field via the entity ATTRIBUTE ENTITY PV FIC100 definitions Their content varies in sympathy with the field variables The preferred format is See Note ENTITY ATTRIBUTE All entities and attributes should be upper case Table Variables LABDATA These are tables that exist in memory but not on the disk They are generally created for convenience at the start of the program and discarded once the program is over NOTE Support for the form ATTRIBUTE ENTITY will be discontinued sometime in the future We strongly encourage users to adopt the ENTITY ATTRIBUTE format for this reason UM ENG 3 1 0 10 14 Meta Scripts Rev 3 Variable Definitions Table 4 Variable Definitions Variable Description USER VARIABLES Format Scope Restric
25. WITH period duration hForm WHERE TIME gt AND TIME Historical Data lt Startistanp gt lt endTstamp gt E gt A B ae xpo i Attr1 entityl FieldName2 Attr2 entity2 FieldNamel period duration hForm FieldNameN Statement Description CREATE The CREATE HISTORICAL VIEWcommand creates a view of the MacroView HISTORICAL historical database VIEW The VIEW can be used in the same way as any database view or entity Le it can be used in chart and browse widgets in meta scripts etc Back d The Macro View historic database structure is a proprietary structure designed to a aio optimize the disk utilization for large amounts of historic data It also incorporates an in built archival feature For more information on the history capabilities refer to the chapter on History in the Engineering Manual Format format A tte NT Aw eie NTV lt startTsta lt endTstamp UM ENG 3 1 0 10 73 SLdIXOS VLAN Meta Scripts Table 61 The CREATE HISTORICAL VIEW Command Rev 3 arguments tableName This is the name of the table You may use this name in the same way as you would use a view or a database entity It must be uppercase letters fieldName 1 amp fieldNameN These are the field or column names that are to be created in the table to hold the historic data They could be
26. are ignored log false ISUPPER string ISUPPER AUT Returns true if all of the characters in 1 I e true the string are upper case alphabetic characters Spaces are ignored LEFT string n EFT ABCDE 2 AB Returns the n left most characters in the string LEN string EN ABCDE Returns the character length of the string passed as an argument UM ENG 3 1 0 10 86 Meta Scripts Rev 3 Function Example Comment LET ent attr NULL ET LDB VI NULL Sets the value of the Entity Attribute to null LOWER string OWER ABCDE Returns a string with all lower case abcde characters in it based upon the string passed as an argument LTRIM strin LTRIM Hello Strips leading spaces from a string and 8 p 8 Sp 8 Hello returns the results PROPER string PROPER fred bloggs Returns a string with the first character Ered Bloggs of every word capitalized based upon the string passed as an argument Non alphabetical characters are not affected PAD string length PAD Production 15 PAD Report 0 Production Report Spaces will be added to the first argument to make the length of the string equal to the length specified in the second argument RAT s1 s2 number RAT AUT Going to AUTO This function operates in a similar way to the AT function e
27. attributes Any database entity always has two special attributes i RECCOUNT This variable always contains the number of records in the database ii RECNO This variable always contains the number of the currently selected record in the database UM ENG 3 1 0 10 68 Meta Scripts Rev 3 CREATE VIEW FROM FILE lt filename gt Table 57 The CREATE VIEW FROM FILE lt filename gt Command Statement Description CREATE VIEW FROM FILE lt filename gt format arguments The CREATE VIEW FROM FILE fileName command is identical to the CREATE VIEW FROM lt entity gt command with the exception that an Entity is not required The command is particularly useful where files are being created regularly for example as history files and you do not wish to add new entities to the entities database format CREATE VIEW lt viewName gt AS SELECT lt selectSpec gt FROM FILE lt fileName gt WHERE lt filterExprn gt ORDER BY lt orderSpec gt optional fileName This is the name of the database The file name must be a string and it may be direct or in relation to the MACRODIR environment variable For example u macro archive hist4 dbf or archive hist4 dbf Other arguments All the other arguments are identical to the standard CREATE VIEW FROM entity command example e
28. example ATTRIBUTE The have the highest precedence and are evaluated left to right prior to the remainder of the expression You may only use the curly brackets inside the double quotes They are unaffected by single quotes LET attrSet TYPE TypeStr AND This results in a print out of a string like Level 36 9432 Note that there will not be a line feed after this statement has been printed The next print string will start on the same line UPPER SetRequest UM ENG 3 1 0 10 30 Meta Scripts Rev 3 Table 16 The SET PRINTER TO Command example example This results in a string like PRINTLN LEVEL 36 94 being printed ll ce E PRINTLN means a new line will be started with the next print statement example example PRINTLN BATCH SET PRINTER TO lp NET Requir PRINTLN PRNTLN BAVIEW BAT BATVIEW RI BATVIEW RI Note The printout would look like this e i WEN I Measured LOOP THROUGH batView 4 Yeng RO t MS The printer will send it output to the device called n Ip First a title is printed The X characters cause a tab of 5 characters to be made between the words You can also use n for the newline character The program loops through the database and prints a line for each record The values are once again separated by the tab marks BATCH Require
29. include a fractional value This is converted to the appropriate time units and rounded to the nearest millisecond If the function is supplied with a time duration value as an argument then a numeric value is returned which is the number of minutes in the time duration argument MONTH MONTH tstamp MONTH If no argument is specified this function returns the current month number 1 12 If a timestamp argument is specified then it returns the month component of the timestamp MONTHS m UM ENG 3 1 0 MONTHS 3 If the MONTHS function is 10 98 Meta Scripts Rev 3 Function Example Comment MONTHS duration Duration of 3 months supplied a single numeric argument it will return a time duration based on the number of months specified by the argument If the function is supplied with a time duration value as an argument then a numeric value is returned which is the number of months in the time duration argument NOWO NOW October 2344 1993 Returns a timestamp value containing the current time down to a millisecond resolution Note that the accuracy of the time measurement is typically only accurate to 1 60th or 1 50th of a second if taken from the local system clock SECOND SECOND If no argument is specified this SECOND tstamp 44 function returns the current second value 0 59 If a timestamp argument is specified then it returns the seconds an
30. macro config for SCO UNIX systems and C users macro config for NT systems UM ENG 3 1 0 10 25 SIdRDS VLAN Meta Scripts Rev 3 Table 11 The DISPLAY Command arguments lt file gt lt file gt This is a metafile name You may include an absolute path name or a path name relative to the directory of the parent window You may use an expression that evaluates to a metafile name but it must evaluate to a string FRAME xl yl lt x2 gt lt y2 gt FRAME These are the top left co ordinates lt x1 gt lt y1 gt and the bottom right co ordinates lt x2 gt lt y2 gt They use VDC co ordinates i e the top left hand corner is 0 0 and the bottom right hand corner is 32767 32767 Note If the new window is modal it will be centered Refer to header object in the Graphics Chapter Form 1 form example DISPLAY lt file gt DISPLAY tb schem This example simply replaces the existing screen with the screen defined by the metafile tb schem Form 2 form example DISPLAY WINDOW file DISPLAY WINDOW hlppmp43 A pop up window called hlppmp43 appears over the existing window open file error If the file specified cannot be found xops3 will look for a file called openerr dgt to display instead This openerr dgt can be used to display an error message indicating that a file could not be found UM ENG 3 1 0 10 26 Meta Scripts Rev 3 Table 12 The DISPLAY Command F
31. section OPERATORS OR NOT lt gt i o4 gt f Sa 8 AND OPERATORS and FUNCTIONS ABS INT OS RAND SORT MISCELLANEOUS FLASH BETWEE FLOOR MAX ERSION ROUND SOWAV VERSION c LIF ISALPHA ASG AT ISLOWI ISUPPER LOWE STRING FUNCTIONS PROFI RIG SPACI SUBST TRIGONOMETRIC BINAND BINNOT BINOR BINXOR BLL BINARY UM ENG 3 1 0 10 80 Meta Scripts Rev 3 Operators Table 67 Operators Type Symbol Example Result Precedence Comment Exponentiation or LIC100 PV 2 201 64 7 Note The use of the carat may conflict with AutoSketch when used in AutoSketch drawings Divide LIC100 PV 2 71 6 Multiply LIC100 PV 2 284 6 Remainder E LIC100 PV 2 0 1 6 Subtract FIC100 PV 4 6 5 LIC100 P Add FICLOO PY Y 48 8 5 BLIOIDQ PW Concatenate I STATUS STAT 5 Combines two character TICIO 08 US viles AUT Concatenate II ALM LM A 5 Subtracts two character values Equal to E PMP43 PV 1 4 A true expression returns a 1 a false expression return a 0 Not equal to lt gt or LIC100 PV 14 4 Less Than LIC100 PV lt 14 0 4 Greater Than gt LIC100 PV214 1 4 Less Than or lt LI
32. to be used e g Jan Feb Dec HIM The month number padded with zeros to take up 2 character Yes Yes positions SM The month number Note a suffix of month s is always No Yes included DDDD i Whenever four D s are grouped together it indicates that the Yes No full day of the week name is to be used e g Monday Tuesday etc DDL Indicates that the 3 character abbreviation for day of the week Yes No UM ENG 3 1 0 10 103 SLdIXOS VLAN Meta Scripts Rev 3 name is to be used e g Mon Tue etc pes Indicates that the day of the month number is to be used but Yes No suffixed with the appropriate English suffix for that number e g Ist 2nd 3rd 4th etc Hb The day of the month number padded with zeros to take up 2 Yes Yes character positions zu The day of the month number Note a suffix of day s is No Yes always included an 24 hour clock hour indication padded with zeros to take up Yes Yes two character positions If more than 99 hours are relevant then more character positions are used up The situation of having more than 24 hours can happen with duration s 12 hour clock hour indication padded with zeros to take up Yes No two character positions 3H The hour number Note that a suffix of hour s is always No Yes included ind The minute indication padded with zeros to take up two Yes Yes charact
33. By referencing the ENTITY ATTR ENTITY ATTR N to get the data from the current record or N records back from the current e With the FETCH command Le using FETCH FIRST LAST PREVIOUSOr NEXT commands e Other Database commands Such as DELETE UPDATE INSERT and LOOP THROUGH List of the Table The table variable only exists for the life of the session Le because the Variable information is not stored in a file on the hard disk once the program is exited the data is lost Restrictions You cannot Use the WHERE clause in FETCH UPDATE and DELETE commands you will get an SqlNotCapable error if you use the DBERR return value e Create a view of a table variable Change the format of a table variable without issuing a new CREATE TABLE VARIABLE Typical use The table variable is typically used as a buffer to view information once it has been collected For example if you read data out of a text list you can put it in a table variable and use the browse widget to view it UM ENG 3 1 0 10 72 Meta Scripts CREATE HISTORICAL VIEW Table 60 The CREATE HISTORICAL VIEW Command Rev 3 CREATE HISTORICAL VIEW lt tableName gt AS SELECT fieldNamel lt fieldName2 gt lt fieldNameN gt entityl attrl entityZ attr2 entityN attrN
34. C100 PV lt 1 4 Equal To d Greater Than or gt LIC100 PV gt 0 4 Equal to Ta UM ENG 3 1 0 10 81 SLdIXOS VLAN Meta Scripts Rev 3 Table 68 Operators Fame Ro S E102 Pv value of 4 Creates a string whose Gua Back L109 PV numeric value is equal to P DBrACKES the value of the or Braces entity attribute or variable Refer to the note below Contain S CD ABCD 4 Returns true if first string is contained in second string AND AND PMP43 PV 0 3 You must have a space in AND nee PV front of and following the AND OR i Pado PES M ji 2 You must have a space in OR Aiii front of and following the OR NOT NOT oie 0 1 You must have a space in NOT neve front of and following the NOT The evaluation of string variables can be simplified with the curly bracket braces notation Le and Thecurly brackets show parts of the expression that must be evaluated first Use the curly brackets to evaluate the variables or entity attributes in a string first For example LET attrSet TYPE TypeStr AND ATTRIBUTE UPPER SetRequest The have the highest precedence and are evaluated left to right prior to the remainder of the expression You may only use the curly Brackets inside the double quotes If the curly brackets are encountered outside strings they are used to block statements for IF statements for ex
35. ES These variables are actually more similar to VIEWS than to user variables or entity attribute variables In effect they are tables that exist in memory I e not on the disk They are generally created at the start of a program used as a database within the program and then discarded when the program is exited Table variables are discussed in more detail in the section Database Functions on page48 UM ENG 3 1 0 10 16 Meta Scripts 10 7 System Variables Rev 3 The table below summarizes the System Variables that are automatically available when you start MacroView The first letter of the system variables and variables used by MacroView applications like the Navigator are capitalized to distinguish them from the user variables To avoid a clash with a system variable ensure that your variables start with a lower case letter Table 5 System Variables Name Value Description Black 0 The color index representing the color black White 1 The color index representing the color white HalfRed 2 The color index representing the half red color HalfGreen 3 The color index representing the half green color HalfBlue 4 The color index representing the half blue color Half Yellow 5 The color index representing the half yellow color HalfCyan 6 The color index representing the half cyan color HalfMagenta 7 The color index representin
36. ION SLALCTIICIIE Sacer eee oe ooa iiit iM tA oo DON LU I A UR ID A LII eM 10 21 ji M 10 22 SET ATTRIBUTE Comtnand tta 10 23 EXEBECUTE 5 2n Noti titii lec e IRE ees 10 23 DISPLAY 6 b5G bibe ECCE efe fete fede i Glebe hefelefate A A tr Rede 10 25 SET PRINTER TO 5s eee ee he eee 10 28 PRINT and PRINTEN 3 iioii e oeid esee eese eiecit 10 29 EXIT WINDONW t RGHHHUUUUGUNNSHRHNGHEHGUOHIUNNGRRNSHENGUO 10 32 EXPE e eoo E ee c e Uu MM M ags cas 10 32 SEND mniessage TO 5 essdeseeieed st cce siete ee d sd c eed e edd d deeds dde de 10 32 SET PROM ATTRIBUTE ri e E GU eee See ea 10 39 SET HORM AU onere tet ttti e tdt uta We utet 10 40 UM ENG 3 1 0 Rev 3 10 1 SIdRDS VLAN Meta Scripts Rev 3 SET POINTBR 52525222 penenesbeenessesnenanieen ssssnesnsssdn 10 42 SET MAXIMUM PROGRAM TIME e ee E ee tu 10 43 1010 C ontrol Statements 7 2 9 5 9 1 erste teos eee ueste toe eee Nene ae E PURSE e NAR ARTES S EE NES SR PEERS EE ES 10 44 IRVELS Bent GGG CG S ES 10 45 REPEAT UNTI ueRBRRRBRHRR RU ei ieee eee 10 47 hair 10 48 BREAK uU NO UU ESRSURHSUEHIUTREHRRNEUHUEURUINHASNUSREHO Nan 10 48 CONTINUE ete eC e Dass MM Md MD M RD RID MODA EAEC e 10 49 RETURN 2ninininsseherRheueeee e uae 10 49 RUNG RR 10 50 MiB M UP 10 51 TERMINATE 3 1r docere iih o die c o o o e Ho ee ted 10 52 LOOP THROUGH
37. Meta Scripts 10 10 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 Table of Contents Meta SCHIBIS adea eiie e EE NR cues wavs sess cick vues calc EQ NN Ern EUN qr e E TR ERE IER 10 5 AIL About Meta SCHptS nitore eret e teet E EE tee ee E voids 10 5 Meta Sept Str ct re coo eme eee et ere e A eet ete ee eet e s 10 5 Components of a Meta Scripta eeeessececeessnnseeecesneecsessaeeceesseeecesseseeceestaeeesessaeeseesaaeees 10 7 Most Common Meta Script Tools eee tek e eee 10 8 Most common meta Script tools 22 1 ric ree tee tees a EET e dede eee dee 10 9 Designing M t ScCEIpiS 4 ii oos eed ettet tet tio oie oed Patre di etie tid 10 10 Entering and Executing the Meta Scripts nennen 10 10 Mshell meta shell and wmshell cccccccccsssssseccceeeeceesesseecceceeeeaauseeeeceeeeeeauaaeseeeeeeeeeaaa 10 11 Error Handling ttc E 10 12 P OCUIMEM CATON MEE uc EEOAE Poteet dee dete OAI EE EO EEE TOUA EEEE 10 12 V riabl es iie edes des eesteeceeeedesdd eetee eb eed ee ddee eee e deeds dd e ede ee eed eed eee ee ees 10 14 Variable types Summary zi iie e Ud e Aa 10 14 Vatlable Defifitiots 5 52 52 5 0 0o iio ioco iie ice iie ioc iei 10 15 Systemi Variables ECTS 10 17 Globaland Eocal Varia DES eS RSS EN O Ae ESSEEN S 10 18 Global and Local Variables How it works eese 10 19 GLOBAL LOCAL and not specified variables Suggested Rules 10 20 ACT
38. NXOR 37 15 Performed a binary XOR operation on 42 a series of integer arguments BIT bit integer BIT 3 37 Returns the value of the specified bit 1 number in the specified integer The least significant bit is considered bit 1 UM ENG 3 1 0 10 90 Meta Scripts 10 13 Time and Date Functions Time and Date manipulations are extremely important in the SCADA Process Control and Manufacturing Industries To support this requirement the meta script language offers a variety of functions and operators that are specific to time date and duration manipulation These functions are shown in the diagram below and discussed in more detail in the remainder of this section TIME and DATE FUNCTIONS Rev 3 TIME and DATE OPERATORS Divide Multiply Remainder Subtract Add Equal to lt gt or Not equalto lt Less than gt Greater than lt Less than or equal gt Greater than or equal TIME and DATE FUNCTIONS EEN URATION CDOW CVTTIM DAYS DURATION MDY MONTHS TIM F a DMY MIN NOW DAT DURAT U TIONSTR B TIME and DATE FORMAT TO Month MMMM MMM Hour Minute Second iii id Millisec UM ENG 3 1 0 10 91 SLdIXOS VLAN Meta Scripts Rev 3 Time Date and Duration Concepts In addition to strings a
39. ODUTS FILE exprn APPEND TO FILE lt xprn gt INPUT OF FILE lt xprn gt SET PRINTER SEND message TO object il DATE FORMA O Gxprn SEND message TO metafile DURATION FORMAT TO lt exprn gt SEND message TO 1 TIME FORMA O lt EXPRN gt lt metafile object gt ET MAXIMUM PROGRAM TIME TO max ET MAXIMUM PROGRAM TIMI Q NFINITE REAK CONTINUE These are discussed in more detail in the flow control section UM ENG 3 1 0 10 21 SLdIXOS VLAN Meta Scripts LET Also see SET ATTRIBUTE Command on the next page Table 7 The LET Command Rev 3 LET The LET statement assigns a value to a variable or the attribute of an entity The attribute of an entity There are various forms of the LET statement as shown below Format 1 form example LET LET FW109 PV 350 lt ent gt lt attrib gt lt exprn gt LET FW109 LS MAN The LET statement simply calculates 7 the expression and assigns it to the LEO EWS hee GRE entity attr pair LET FA109 SV ratio FWIOS PV example Format 2 form HET daterlaq ri LET variable exprn LET maxNumBatches 200 The LET statement simply calculates the
40. R TO The standard output of xops3 STDOUT This is typically a console or terminal X window 2 Spooling format Output goes to device sue Ses A Meets The spooling device called lt exprn gt example SET PRINTER TO lp The output is sent to the printer spooler called Ip 3 File format Output goes to SET PRINTER TO A file called lt exprn gt FILE exprn SEI PRINTER TO The end of the file called lt exprn gt APPEND TO FILE lt exprn gt The output is written to a file called examples postMtm in the directory report SET PRINTER TO FILE report postMtm SET PRINTER TO APPEND to The output is added to the end of the file FILE messages eventLog eventLog in the messages directory UM ENG 3 1 0 10 28 Meta Scripts Rev 3 Table 14 The SET PRINTER TO Command 4 Program input Note Note Note format SET PRINTER TO INPUT OF lt exprn gt examples SET PRINTER TO INPUT OF mail macro In all of the above statements lt exprn gt must evaluate to a string In the case of the spooling device format the program input format and the display window format the printer output is only actually sent when the meta script is completed For examples of how the SET PRINTER TO statement is used with the PRINT and PRINTLN statement refer to the next section on the PRINT statement O
41. SERT Format Arguments Note on Dbase The INSERT command enables you to append a record to a database and optionally set the values of the fields There are two forms of this command You can add a blank record form 1 You can add a record and set the values of the specified fields form 2 entity An entity configured as a database entity attr The field names in the database Le attxr1 attr2 etc expr Valid expressions that evaluate to the required values to go into the specified fields The INSERT command is styled around the SQL version which dBase users INSERT regard as an append and not the dBase version There is no equivalent to the dBase INSERT which does actually insert a record rather than appending it Form 1 form example INSERT INTO lt entity gt INSERT INTO OPLOG This example simply appends a blank record at the end of the database entity OPLOG UM ENG 3 1 0 10 54 Meta Scripts Table 43 The INSERT Command Rev 3 Form 2 form INSERT INTO lt entity gt FIELDS dtbtrl ettrz abtrn VALUES exprl expr2 exprn This example appends a record at the end of the database entity LABLOG and sets the values of the fields DT and TM to the current date and time It also sets the fields LEVEL and FLOW to the values of the PV of L109 and FM109 respectively example INSERT FIELDS INTO LABLOG DT XM E
42. TCH9 This moves you to the first record in the database form example FETCH FIRST OF entity FETCH FIRST OF BARCH9 WHERE WHERE ssecarchbxprn CUSTOMER AMALG This moves to the first record in the database where the field CUSTOMER has been set to AMALG FETCH LAST form example OF FETCH LAST OF entity FETCH LAST OF BATCH9 This moves you to the last record in the database form example FETCH LAST OF entity FETCH LAST OF BATCH9 WHERE WHERE scarchExprn CUSTOMER AMALG This moves to the last record in the database where the field CUSTOMER has been set to AMALG UM ENG 3 1 0 10 59 SLdIXOS VLAN Meta Scripts Rev 3 Table 48 The FETCH Command Statement Description FETCH ABSOLUTE form example FETCH ABSOLUTE lt record FETCH ABSOLUTE STATE PV OF number gt OF lt DBASE4 STATEDB entity gt This positions the current record point for a DBASE data source to the absolute record number A typical application of the FETCH ABSOLUTE command is described in the following scenario A PLC contains a logical state machine program for controlling the startup and shutdown process for a complex piece of machinery An entity STATE is configured in Macro View which reflects the current state number of the startup shutdown sequence within the PLC STATE PV In MacroView a DBASEA file is used to store the text descriptions of the various
43. Table 76 Date and Time Related Set Actions The display format of any date values used in the system can be modified from within the meta script The expression reference must result in a string that contains combinations of the specification string listed in the next table NOS ee a ee IMP wees The display format of any time values used in the system can be modified from within the meta script The expression reference must result in a string that contains combinations of the specification string listed in the next table ene ue PEN eee MP The display format of any time values used in the system can be modified from within the meta script The expression reference must result in a string that contains combinations of the specification string listed in the next table Time Stamp and Duration Format String Options Table 77 Time Stamp and Duration Format String Options e Century number Yes No TE Year number within the century padded with zeros if Yes Yes necessary to take up 2 character positions TE The number of years in the time stamp or duration Note that No Yes a suffix of year s is always included MMMM i Whenever four M s are grouped together it indicates that the Yes No full month name is to be used e g January February December MMM Indicates that the 3 character abbreviation for month name is Yes No
44. Tstamp gt and lt endTstamp gt must be expressions that result in time stamp strings Refer to the section Time and Date Functions on page88 You can use various forms of this expression Le WHERE TIME gt lt startTstamp gt AND TIME lt lt endTstamp gt WHERE TIME gt lt startTstamp gt The system will assume that the end point is Now and will allow the table to grow as time progresses WHERE TIME endTstamp The system will provide a start time for you If there is no WHERE clause the system will choose a start time and will use NOW as the end time Note You cannot use the general form of the WHERE clause with historical views UM ENG 3 1 0 10 75 SLdIXOS VLAN Meta Scripts Table 63 The CREATE HISTORICAL VIEW Command Rev 3 example example z Creates a view AS SELECT LEVEL L109 PV Creates fields RECNO WATER FW109 PV DT TM LEVEL CAUSTIC FC109 PV WATER amp CATISTIC WITH SECONDS 15 SAMPLES WHERE TIME gt NOW HOURS 15 The earliest record will be 15 hours ago The latest record will be now The view will dynamically update every 15 seconds Uses You may use the table In a browse or chart widget In a real time graphic using the
45. VEL FLOW VALUES DATE TIME L109 PV FM109 PV Formatting options You may freely organize the command across multiple lines so as to improve the readability of the command i e the following two statements are equally valid statement 1 INSERT INTO OPLOG FIELDS TM COMMENT VALUES NOW Problems in Area 6 statement 2 INSERT TM COMMENT VALUES NOW INTO OPLOG FIELDS Problems in Area 6 UM ENG 3 1 0 10 55 SLdIXOS VLAN Meta Scripts Rev 3 UPDATE Table 44 The UPDATE Command UPDATE This command enables you to write into multiple fields of a database entity or a view of the database entity You can write into the fields of the current record form 1 dicc entity The data base entity Arguments attr The attributes i e field names that are to be modified Le attri attr2 etc expr Expressions that evaluate to the values to be placed in the fields Form 1 form example UPDATE entity LET ratio FC109 SUM FM109 SUM SET attrl exprl UPDATE BATCH9 attr2 expr2 SET END TM NOW WT TOT FW109 SUM attrN exprnN Cs TO FCLOS SUM RAT MS ratio This example first calculates the ratio of caustic to total addition to a mixing tank It then writes the mixing end time total water total caustic and the meas
46. W DURATION 8 0 0 Oo tees UM ENG 3 1 0 10 101 SLdIXOS VLAN Equal to Meta Scripts Rev 3 Type Symbol Precedence Comments and Example TIME 2 9 13 HOURS 3 18 09 15 Le 6 09 15pm the previous day HOURS 8 MINUTES 45 SECONDS 12 07 14 48 Add i 5 The time date version of the addition operator works tl d1 t2 with both time stamps and time durations Most di tl t2 combinations are allowed except for adding two time dl d2 d3 stamps The result of time date addition is a time stamp in all cases except when both operands are time durations NOW DURATION 8 0 0 22 15519 Le 10 16 19pm the same day TIME 2 9 15 HOURS S 10 09 15 Le 10 09 15pm the same day HOURS 8 MINUTES 45 SECONDS 12 08 15 12 Equal to 4 The time date version of the equality operator works tl 2 with both time stamps and time duration but the type d1 d2 of each operand must be the same The equality operator returns a numeric value I e 0 for false non zero for true Not equal to d OF J4 See equality operator comment Less Than 4 See equality operator comment Greater Than 4 See equality operator comment Less Than or Equal a 4 See equality operator comment To Greater Than or di 4 See equality operator comment UM ENG 3 1 0 10 102 Meta Scripts Rev 3 Date and Time Related Set Actions
47. ample UM ENG 3 1 0 10 82 Meta Scripts Special MacroView functions Rev 3 Table 69 Special MacroView Functions Function Example Comment RAMPDELTA ent attr RAMPDELTA L109 SV Returns the ramp delta for an attribute I e how much the attribute may be incremented with the up and down keys CONFIRMSET ent attr CONFIRMS ET LI0S S5y Returns a 1 if the entity attribute has the confirm flag set true This will usually mean that when in the Navigator a message is sent to the operator asking for confirmation that an attribute must be set LOGSET ent attr LOGSET L109 SV Returns a 1 if the entity attribute has the log set flag set true This will usually mean that a message is written to the messages database indicating that the variable has been changed ENTEXISTS ENTEXISTS LC110 Returns a 1 if the entity VIEW or table exists ATTREXISTS ATTREXISTS LC110 PV Returns a 1 if the attribute of the exists ATTREXISTS LC110 attrName entity exists Note You may use the Wildcard in any of the expressions For example in a group display you may refer to RAMPDELTA PV Here the refers to the default entity within the metafile being executed See S1 UM EN END SetDefaultl Entity TO lt display area In display area section of graphics chapter G 3 1 0 10
48. atements format format The timeout period is set to the number SET MAXIMUM PROGRAM TIME of seconds specified by lt exprn gt TO lt exprn gt MES Sere Renee oan The timeout interrupting mechanism is TO INFINITE disabled Default This will depend on the environment For the operations program it is 10 seconds example example If the program time exceeds 20 seconds the program will be aborted SET MAXIMUM PROGRAM TIME TO 20 UM ENG 3 1 0 10 43 SIdRDS VLAN Meta Scripts Rev 3 10 10 Control Statements These statements affect the flow of the program Le they determine whether a particular block of code will be executed based on the prevailing conditions The diagram below is a summary of the main control statements available in the meta script language The tables on the next page discuss these statements in more detail PROGRAM CONTROL IF exprn acti IF lt exprn gt lt acti IF exprn ones on gt IF lt exprn gt ELSE lt action gt tions cactlonso IF ELSE E lt action gt E exprn Evens lt actions gt UNTIL lt exprn gt Fr REPEAT UNTIL E lt exprn gt E lt exprn gt RETURN Lions lt actions gt URN lt exprn gt TF lt exprn gt CONTINUI y lt exprn gt CONTINUE EIg8s
49. ble format string structures are listed in the Table Time Stamp and Duration Format String tstamp format Options WOY timestamp SOSTIENE EUREN m d Returns the week number in the WOYO 43 A year of the timestamp passed as an argument If no argument is supplied then the functions returns the current week number within the year Note the first week of the year is week 1 YEARO SEM If no argument is specified this YEAR timestamp vane function returns the current year If a timestamp argument is specified then it returns the year component of the timestamp YEARS h l BER yaan If the YEARS function is supplied a YEARS duration single numeric argument it will return a time duration based on the number of years specified by the argument If the function is supplied with a time duration value as an argument then a numeric value is returned which is the number of years in the time duration argument UM ENG 3 1 0 10 100 Meta Scripts Date and Time Operators Rev 3 Table 75 Date and Time Operators Type Symbol Precedence Comments and Example Divide duration number duration1 duration2 6 The time date version of the divide operator must either have a divisor which is a time duration and a denominator which is a number or have both divisor and denominator being time durations The result of the operation is a time duration in the former case an
50. ble to represent the number given the character width specified STUFF s1 n1 s2 n2 STUFF s1 nl s2 STUFF Going AUT 7 Automatic Going Automatic This function replaces a section of one string s1 with another string s2 The argument n1 is the starting point for replacement The argument n2 is optional and identifies the number of characters to replace If not specified the length of string s2 is used as a default SUBSTR str offset num n UBSTR ABCDE 2 3 BCD Returns a substring of the string str The substring is taken as the num characters starting at the offset position UPPER string UPPER abcDe Returns a string with all upper case ABCDE characters in it based upon the string passed as an argument VAL string VALI 27 5 Returns a numeric value based upon a 237 5 string passed as an argument Note that if a nonsense string is passed then the return value will be a zero UM ENG 3 1 0 10 88 Meta Scripts Rev 3 Trigonometric Hyperbolic and Logarithmic Functions Table 72 Trigonometric Functions Function Example Comment ACOS x ACOS 0 87 Arc cosine with result in units of 29 541361 degrees ASIN x ASIN 0 5 Arc sine with result in units of degrees 29 041361 ATAN x ATAN 0 58 Arc tangent with result in units of 30 113733 degrees COS x COS 30 Trigonometric cosine with argument in 0 87 uni
51. ctly reference an entity All subsequent uses of the name will result in indirect access to the specified entity format format SET POINT Creates an alias that can be substituted in a generic program at a later stage ER lt pointerName gt TO lt entityName gt arguments lt pointerName gt The alias to be used in a later program lt entityName gt This is a string expression that resolves to an entity name example example LET X 110 First create the aliases that are to be used later in a generic meta script example using a string expression SET POINTER Y TO FIC X prt rptimns PRINTLN Y PVj Now use the aliases in the meta script sub routine prt rep ms SET POINTER LVLCTRL TO LC controllerNumber Meta script commands can now be used referring to LVLCTRL as a variable name UM ENG 3 1 0 10 42 Meta Scripts Rev 3 SET MAXIMUM PROGRAM TIME Table 29 The SET MAXIMUM PROGRAM TIME Command SET MAXIMUM This command sets the maximum time the meta script program should take to PROGRAM complete If the program takes longer than the time you specify then it is aborted TIME Because of efficiency reasons the check is only carried out on commands that could result in the program getting into an infinite loop Le SLEEP FOR DO WHILE and LOOP THROUGH St
52. d a number in the latter Time stamps can not be used with division operators HOURS 5 6 00 50 00 Le 50 minutes DAYS 3 MI 432 Le 432 10 minute periods in 3 days NUTES 10 Multiply duration number number duration The time date version of the multiplication operator must multiply a number and a time duration together Time stamps can not be used with multiplication operators The result of the operation is a time duration 3 125 HOURS 2 DO IESQgO Le 6 hours and 15 minutes Remainder duration numberd 1 d2 oe The time date version of the remainder operator works with similar forms of operands as the division operator does If the first operator is a duration and the second a number then the result is a time duration If both operands are time durations then the result is a number HOURS 2 7 00 00 04 Le 4 seconds DURATION 2 OO es Le Le 1 minute and 12 seconds l3 22 MI NUTES 6 Subtract tl t2 dl t1 d1 t2 d1 d2 d3 The time date version of the subtraction works with both time stamps and time durations Most combinations are allowed except for a request to subtract a time stamp from a duration The result of time date subtractions is a time duration when both operands are time stamps or when both operands are time durations The result is a time stamp if the first operand is a time stamp and the second a duration NO
53. d Measured 1 12 3 12 4 2 12 5 12 5 3 9 0 8 9 4 21 3 21 7 etc UM ENG 3 1 0 10 31 SLdIXOS VLAN Meta Scripts Rev 3 EXIT WINDOW Table 17 EXIT WINDOW Command EXIT WINDOW The exit window causes the currently active window to terminate It is typically used with the pop up windows on the OK or CANCEL buttons Note that this will not work from within a DISPLAY AREA EXIT Table 18 The EXIT Command EXIT The EXIT object is run whenever a metafile window terminates The forms editor can not be used to create this object It must be created in the CAD diagram as follows e Type the modifier EXIT in the graphic area e Add the meta script commands terminated by the semicolon e Group the EXIT modifier and all the text that makes up the program e Convert the CAD diagram using the Convert3 program SEND lt message gt TO Table 19 The SEND message TO Command SEND message TO Messages are used as a means of communicating between different objects and different windows From a meta script you can send a message to e A window application e Another object in the same window e Another object in a different window To be successful the receiving object or window must have a matching label or ID and must also be able to understand the message This understanding may already be built into the object or window or it must be specified in a TRIGGER p
54. d milliseconds component of the timestamp The milliseconds are returned as the decimal part of the seconds value SECONDS 1 253 ae SECONDS m vrbem ur rd If the SECONDS function is SECONDS duration supplied a single numeric argument it will return a time duration based on the number of minutes specified by the argument The argument may include a fractional value This is rounded to the nearest millisecond If the function is supplied with a time duration value as an argument then a numeric value is returned which is the number of seconds in the time duration argument TIME B R 44 Returns a string which contains a SUBSTR TIME 1 5 representation of the current time 09 34 The format is based on the SET TIME FORMAT TO command TIMESTR tstamp Snares ee This TIMESTR function Oct l5 1993 implementation requires a single time stamp its argument It returns a string representation of the time stamp based on the default format UM ENG 3 1 0 10 99 SLdIXOS VLAN Meta Scripts Rev 3 Function Example Comment strings specified by SET TIME FORMAT TO command TIMESTR TIMESTR NOW MMM DD CCYY The TIMESTR function requires a Oct 18 1993 time stamp as its first argument and then a formatting string as the second argument It returns a string representation of the time stamp based on the format strings The availa
55. e LET statement does not wait for the command to complete before continuing to the next statement It is important to note that it may take some finite time for the write to field variables to take place Where it is important to wait until the action has completed just set up a loop that reads the value back until it sees that the change has been made or just use the SLEEP command EXECUTE Table 9 The EXECUTE Command EXECUTE The EXECUTE statement takes a string expression resolves it and executes it as a meta script command In another variation of this statement you can assign a value to a variable when a string is executed There two forms of the EXECUTE statement as shown below Format 1 form example EXECUTE string expression ET x LET a The execute command simply executes EXECUTE x 3 the string that follows the command UM ENG 3 1 0 10 23 SLdIXOS VLAN Meta Scripts Rev 3 Format 2 Statement form Advanced Note form 2 example LET maxNumBatches EXECUTE LET variableName EXECUTE lt string expression gt RETURN total x In the second variation the string must return a value which is assigned to the variable Note Because it is a meta script command the expression must be ended with a semi colon Note also that you do not use brackets in the
56. entity attr format but not the attr n entity format With the FETCH FIRST LAST NEXT and PREVIOUS commands But not FETCH WHERE With the LOOP THROUGH command Restrictions You may not Use DELETE UPDATE and INSERT commands Use the WHERE clause in FETCH commands Missing data Use the CREATE VIEW on a historical table The HISTORICAL VIEW will always include a record for every configured time period If the data is not present the HISTORICAL VIEW will include a blank record UM ENG 3 1 0 10 76 Meta Scripts Rev 3 DBERR and DBERRSTR Table 64 The DBERR and DBERRSTR Command DBERR and DBERRSTR Format arguments These commands are used to inform you if an error occurred in any of the database commands DBERR returns a numeric code associated with the kind of error and DBERRSTR returns a string that describes the error In each case there is a code or a string associated with the last command associated with a database entity view table variable or historical view If there was no error a zero is returned for the code and an empty string for the DBERRSTR entity DBERR lt entity gt DBERRSTR For a list of error codes refer to the table DB Error Codes and Strings on page75 entity The returned error code or string refers to the last command associated with this entity view or table variable E g OPLOG DBERR will return a code that relates to the success or failure of
57. er positions qi The minute number Note that a suffix of minute s is No Yes always included aS The second indication without milliseconds padded with Yes Yes zeros to take up two character positions s The seconds indication Note that a suffix of second s is Yes Yes always included ai The number of milliseconds indication with zero padding to Yes Yes take up 3 character positions EN The number of hundredths of a second with zero padding to Yes Yes take up 2 character positions Note that the millisecond value is rounded off to the nearest hundredth of a second j The number of tenths of a second Note that the millisecond Yes Yes value is rounded off to the nearest tenth of a second 2L The number of milliseconds Note that a suffix of No Yes millisecond s is always included oe The am or pm indication Yes No Pm PM UM ENG 3 1 0 10 104
58. expression and assigns it to the variable Format 3 form example LET attr entity LET TM BATCH9 6 45 i o quA LET SV FIC100 0 This is just an alternative way that you can specify the attribute entity pair Note Support for this format will be discontinued some time in the future We strongly recommend you use the first format Write Delay Note Implications nae The LET statement does not wait for the command to complete before continuing to the next statement It is important to note that it may take some finite time for the write to field variables to take place Where it is important to wait until the action has completed just set up a loop that reads the value back until it sees that the change has been made or just use the SLEEP command UM ENG 3 1 0 10 22 Meta Scripts Rev 3 SET ATTRIBUTE Command Also see LET on page 10 22 Table 8 The LET Command SET ATTRIBUTE The SET ATTRIBUTE statement assigns a value to an attribute string format form SET ATTRIBUTE lt ent gt lt attrib gt TO lt exprn gt In the example above the expression lt ent att rib gt must resolve to an ent attr or variable name The SET ATTRIBUTE statement allows you to indirectly set the value of an attribute to a variable examples SET ATTRIBUTE SPentity SV TO calcSetPoint userAllowance SET ATTRIBUTE attrName TO 15 0 Write Delay Note Implications Th
59. f the components of a typical functional program Variables May include real time variables like FW109 LS or program variables like excdnce Database Commands SQL like commands that can be used to store data retrieve data and filter data either from databases or from historical data Time amp Date Functions A series of important time amp date functions like DATE TIME NOW DURATION etc UM ENG 3 1 0 Opacity Control Statements These affect the flow of the program In this case the actions are only to be carried out if the Boiler is on line Examples of this type of statement include IF ELSE REPEAT UNTIL amp WHILE Actions Statements that do something These may set a value print information send a message display a window etc Operator amp Functions These are used to manipulate information and include operators like AND OR NOT as well as functions like ABS STRO VALO and RANDO 10 7 SLdIXOS VLAN Meta Scripts Rev 3 10 3 Most Common Meta Script Tools The diagram Most Common meta script tools on page5 provides further insight into the meta script language Here we have grouped the most common and useful commands from the various statement types In addition to those listed below there are a large number of extra features and tools that can be employed to provide even more powerful meta scripts If you are just starting with meta scripts we do howe
60. g the half magenta color Grey Gray 8 The color index representing the color grey DarkGrey Gray 9 The color index representing the color dark grey Red 10 The color index representing the color red Green 11 The color index representing the color green Blue 12 The color index representing the color blue Yellow 13 The color index representing the color yellow Cyan 14 The color index representing the color cyan Magenta 15 The color index representing the color magenta UserAccessLevel 0 99 Access level assigned to this user from the users configuration ConsoleAccessLevel 0 99 Access level assigned to this console from consoles configuration AccessLevel 0 99 The access level of this console and user combination ConsoleName The name of this console ConsoleT ype The type of console e g UNIX Systemld The host name of this Macro View system PortName The name of the device that connects the user to the system UserName The name of the user running this application SetRequest Used internally in object to hold requested value until Validation UM ENG 3 1 0 10 17 SLdIXOS VLAN Meta Scripts Rev 3 Program returns 10 8 Global and Local Variables You may define variables to be Local or Global The table below summarizes the differences in functionality between these two types of variable Table 6 Global and Local Variables GLOBAL Definition Global Variables are available to all appl
61. gt TO Command 10 34 Table 21 The SEND lt Message gt TO Command 10 35 Table 22 The SEND lt Message gt TO Command 10 36 Table 23 The SEND lt Message gt TO Command 10 37 Table 24 The SEND lt Message gt TO Command 10 38 Table 25 The SET FROM ATTRIBUTE Command 10 39 Table 26 The SET FORMAT Command 10 40 Table 27 The SET FORMAT Command 10 41 Table 28 The SET POINTER Command 10 42 Table 29 The SET MAXIMUM PROGRAM TIME Command 10 43 Table 30 The IF ELSE Command 10 45 Table 31 The IF ELSE Command 10 46 Table 32 The REPEAT UNTIL Command 10 47 Table 33 The WHILE Command 10 48 Table 34 The BREAK Command 10 48 Table 35 The CONTINUE Command 10 49 Table 36 The RETURN Command 10 49 Table 37 The RUN Command 10 50 Table 38 The RUN Command 10 51 Table 39 The SLEEP Command 10 51 Table 40 The TERMINATE Command 10 52 Table 41 The LOOP THROUGH Command 10 52 Table 42 The INSERT Command 10 54 UM ENG 3 1 0 10 3 SIdRDS VLAN Meta Scripts Table 43 Table 44 Table 45 Table 46 Table 47 Table 48 Table 49 Table 50 Table 51 Table 52 Table 53 Table 54 Table 55 Table 56 Table 57 Table 58 Table 59 Table 60 Table 61 Table 62 Table 63 Table 64 Table 65 Table 66 Table 67 Table 68 Table 69 Table 70 Table 71 Table 72 Table 73 Table 74 Table 75 Table 76 Table 77 UM ENG 3 1
62. he records of interest ORDER BY lt orderSpec gt Order the records DROP VIEW lt viewName gt This line is optional and drops the view DROP VIEW TEMP_SEARCH_VIEW UM ENG 3 1 0 10 63 SLdIXOS VLAN Meta Scripts Rev 3 Table 52 The CREATE VIEW and DROP VIEW Command arguments viewName This is the name of the new view It can be used just like a database entity or a variable once the view has been created For example you can use it to display a browse widget or to print out only certain fields of a database SELECT lt selectSpec gt Use this to choose which fields or columns you want in the view This is usually a list of the fields separated by commas For all fields use SELECT WHERE lt fil terExprn gt This is used to choose the records or rows that are to be included in the view The system will evaluate the expression for each record and if the result is true the record will be included in the view Note that the ilterExprn must be a string that is understood by the RDBMS Note For dBase WHERE statements the matching of strings will be satisfied if there is a partial match E g Fetch first of ENTITIES WHERE ENTITY LCl110 will match with the entity name LC110B To avoid this you must pad out the WHERE clause with a space Le WHERE ENTITY LC110
63. iables are linked to the real time data via their entity definitions Their content varies in sympathy with the real time values E g FIC100 PV LAB1 DT This is the preferred format for referencing real time and database type UM ENG 3 1 0 10 15 SLdIXOS VLAN Meta Scripts Rev 3 ENT ATTR OFFSET ATTRIBUTE ENTITY format values This format is used for database entities or views of database entities It enables you to get information from a record that is a number of records away from the current record LAB1 DT 3 means return the DT field of the record 3 records back from the current record in the database entity LAB1 LAB1 DT 3 means return the DT field of the record 3 records forward from the current record Note that this format doesn t work with TABLE variables or Historical views NOTE Support for the form ATTRIBUTE ENTITY will be discontinued sometime in the future We strongly encourage users to adopt the ENTITY ATTRIBUTE format for this reason E g PV FIC100 DT LAB1 DT 3 LAB1 Take care in choosing the attribute name that it doesn t clash with any of the function names For example if you chose the name DATE as the column name of a database entity RESULTS then the system would assume that DATE RESULTS was the function DATE rather than the attribute DATE In cases like these it is preferable to use the entity attribute format TABLE VARIABL
64. ications in the currently running operational program The GLOBAL statement defines them E g Example GLOBAL myApplicationStatus Usage Avoid using the global statement wherever possible It is just possible that someone else could choose the same Global name that you have chosen resulting in confusion and interaction with their program Use GLOBAL variables only for variables which must be accessed across all windows and meta script programs Optional To be backward compatible with previous versions that did not support start up LOCAL and GLOBAL variables you may start off the operational program using the defaultGlobal argument This will treat all variables as GLOBAL unless explicitly defined as LOCAL LOCAL Definition Local variables are available to the current window and any children of that window l e the variable will be available to DISPLAY Using the AREAS meta scripts called from a window etc LOCAL command LOCAL phasel Example Wherever possible use local variables Note that if the LOCAL command is encountered the system will not look in the parent for the same variable Variables are LOCAL if i They are defined LOCAL using the LOCAL declaration Usage ii They have no declaration in the meta script but the search up the parent tree encounters a LOCAL declaration ii They encounter no GLOBAL or LOCAL declarations at all up UM ENG 3 1 0 10 18 Meta Scripts Rev 3
65. int in time to a date 1 e timestamp based on a format string the second argument CVTDURATION dipole ue E Converts a string the first timestr aa argument to a duration of time based on the default format string specified in the SET DURATION FORMAT TO VTDURATION eee eee eres Converts a string the first timestr format HH mm ss IZ2 52210000 argument to a duration of time UM ENG 3 1 0 10 94 Meta Scripts Rev 3 Function Example Comment based on a format string the second argument CVTTIME timestr format CVTTIME 19910212 CCYYMMDD Feb 12th 1991 Converts a string the first argument representing a point in time to a time stamp based on a format string the second argument CVTTIME timestr CVTTIME I9910212 02 12 92 Converts a string argument representing a point in time to a time stamp based on the default format string specified by the SET TIME CONVERSION FORMAT TO command DATEQ DATE 1992 07 09 SUBSTR DATE amp 5 07 09 Returns a string which contains a representation of the current date The format is based on the SET DATE FORMAT TO command DATE y m d DATE 1993 5 2 May 2nd 1993 When the DATE function is supplied 3 numeric arguments it uses these arguments to return a timestamp value which is used in Version 3 to rep
66. ions to return values usable within the Meta script language Note that the standard output of the shell command is returned Example 2 LET FileList RUN 1s If the script is likely to take a significant time to execute you might want to show the clock cursor by sending the BeginWait and EndWait messages to MetaFile Refer to the examples in SEND message TO on page29 UM ENG 3 1 0 10 50 Meta Scripts Table 38 The RUN Command Rev 3 Format 3 RUN lt exprn gt BEGIN SCRIPT lt script contents gt END SCRIPT The third format enables a script to be embedded in the meta script This avoids any administration overheads in maintaining separate script files Note that the script must be a Bourne shell script Note to that lt exprn gt is an optional expression of string format that may include arguments This format is not supported under MacroView for Windows NT RUN we Example 3 BEGIN SCRIPT sendmsg 4 13 Report complete END SCRIPT RUN nw Note Example No arguments RUN varNamel varName2 Arguments Arguments that can be referenced as 1 and 2 in the script that follows SLEEP Table 39 The SLEEP Command SLEEP The sleep command suspends execution of the meta script for a number of seconds before continuing Format SLEEP exprn Wait 3 seconds example SLEEP 3 UM ENG 3 1 0 10 51 SLdIXOS VLAN Meta Scri
67. lied then the current day of the year number is returned The first day of the year is day 1 DURATION h m s 20 42 63 221 71221221 When the DURATION function is supplied 3 numeric arguments it uses these arguments to return a time duration value The three arguments represent the hours minutes and seconds specifications respectively The decimal places that may be present in the hours and minutes specifications are ignored while in the seconds specification they are used for millisecond specification The minutes values must be limited to between 0 and 59 inclusive The seconds value must be limited to between 0 000 and 59 999 The hours value must simply be a positive number DURATIONSTR dI m SURE NUS This DURATIONSTR function implementation requires a time duration as its argument It returns a string representation of the time duration based on the default format strings specified by the SET DURATION FORMAT TO commands DURATIONSTR NOW URATIONSTR LABDATA TM HH mm ss The DURATIONSTR function duration format 120 56 02 requires a time duration as its first EM argument and then a formatting string as the second argument It returns a string representation of the time stamp or time duration based on the format strings The available format string structures are listed in the table Time Stamp and Duration Format String Options on page106 HOUR HOUR
68. ll volume duration TO MetaFrile SEND Bell volume duration pitch TO MetaFile Where volume is in 96 100 is the loudest duration is in milliseconds and pitch is in Hertz UM ENG 3 1 0 10 36 Meta Scripts Rev 3 Table 23 The SEND lt Message gt TO Command example using BeginWait and EndWait example This program makes the cursor change into a clock to signify that the processor SEND BeginWait TO MetaFile may take time to complete the operation example This program turns the cursor back to the S Note If two BeginWait messages are sent then it will take two EndWait messages to clear the clock cursor Also note that Metafile is not a file name but the string MetaFile original cursor from the clock indicating END EndWait TO MetaFile that the delay is over example using SetUpdateRate rate example S This program changes the update rate of the dynamic values in the metafile Le it overrides the default value set in the start up command The rate is measured in one hundredths of a second I e the example above sets the update rate to 2 seconds Note You can also set the update rate for each metafile using i ii iii The UPDATE modifier grouped with itself in the CAD diagram E g Note If you enter the update rate in the file header it overrides the update rate in the command line for that meta file END
69. lliseconds UM ENG 3 1 0 10 92 Meta Scripts As another example you can print out a period or duration using PRINTLN Heating period was DURATIONSTR NOW This function converts the duration data to a string for the print statement Combining Different Formats The duration is calculated by subtracting two time stamp data values heatPeriod HH mm ss The format of the string is specified here This will result in something like 4 21 05 for 4 hours 21 minutes 5 seconds Rev 3 Note You can also specify the format of the duration printout using the SET DURATION FORMAT command described in the section of this chapter section Using the functions below you can combine different formats in expressions There are however definite rules that relate to how these expressions are used For example It is possible to subtract one fime stamp from a second time stamp to produce a duration However adding two fime stamps together is meaningless and is not allowed It is most important to be aware of the format of the data Le is it a string numeric time stamp or a duration The next tables summarize the various functions operators and formats relating to fime and date manipulation UM ENG 3 1 0 10 93 SLdIXOS VLAN Meta Scripts DATE and TIME Functions Table 74 Date and Time Functions Rev 3 Function Example Comment ABS duration
70. n 1 SglNotAvailable The functionality requested is not available from the entity referred to E g inserting a row into a PLC entity 10 SqINoFile The database or table specified in the command does not exist 11 SqlNoPermission The user does not have the appropriate permission level to perform the database command 20 SglAtBottom A fetch next command was issued and it couldn t be satisfied because the system is at the last record 21 SqlAtTop A fetch previous command was issued and it couldn t be satisfied because the system is at the first record 30 SqlUniqueKey The database operation could not be performed because it would violate the configured requirement that a particular key i e indexed field was unique 40 SqlLocked The database operation could not be performed because a lock was present on the database in question and was not released within the internal time out period 50 SglLimit The database operation could not be performed because an internal limit was reached E g maximum number of records for this database was reached UM ENG 3 1 0 10 79 SLdIXOS VLAN Meta Scripts 10 12 Operators and Functions Rev 3 The meta script language supports a rich set of operators and functions which can be used within the commands and expressions The summary below shows the functions used most often in bold The functions have been separated in the same order as the tables in this
71. names such as FLOW SPEED TIM create them dynamically using the EX ECUT E command entityl attrl amp entityN attrN These are the attributes of entities that have been stored in the historical database You must configure the historian to collect this information Refer to the History chapter in the Engineering Manual E or you could UM ENG 3 1 0 10 74 Meta Scripts Rev 3 Table 62 The CREATE HISTORICAL VIEW Command Format Format Example 1 Example 2 Example 3 The resulting table will also contain an additional column the first column called TM This will represent the actual point in time that the historical data represents It will be of the time stamp form as specified in the SET FORMAT TO command WITH lt period gt lt duration gt lt hForm gt For example WITH MINUTES 1 AVERAGESor WITH SECONDS 6 SAMPLESor WITH HOURS 8 MAXIMUMSetc You can only specify lt period gt lt duration gt lt hForm gt combinations that have been specified in the historical specification configuration Refer to the History chapter in the Engineering Manual Note that period duration and lt hForm gt can all be expressions WHERE TIME gt lt startTstamp gt AND TIME lt lt endTstamp gt The optional WHERE clause specifies the range in time of the resulting view Both lt start
72. nd normal numeric data handling there are two additional data formats available that are specific to time and date manipulation These data formats are discussed below i Time Stamp Format Data in the time stamp format refers to a particular instant in time E g 8 32pm on Friday 12th June The meta script stores the time stamp down to the millisecond resolution You can use the time stamp data in the various functions discussed in the tables in this section For example the function NOW returns a time stamp relating to the current time down to the millisecond resolution A further example PRINTLN Timeout is at Note You can also specify the format of the time printout using the SET TIME FORMAT command described in the section of this chapter section 10 9 TIMESTR NOW MINUTES 3 Convert the time Create a time stamp for Note For operating system reasons stamp to a string to the moment in time that you cannot specify a time stamp be printed out is 3 minutes from now before 1970 ii Duration Format In contrast to the time stamp format which represents an instant in time the duration format represents a period of time once again down to the millisecond in resolution You can use the duration format in the functions discussed in the tables in this section For example HOURS 3 5 Will return a duration down to the millisecond resolution I e 03 30 00 000 3 hours 5 30 minutes 0 seconds 0 mi
73. ndows I e you can only send messages between windows that have the same base parent You cannot send messages from one UNIX program to another Arguments SEES This is the string that is sent to the object or window It can be a simple string like RESET or it can contain arguments If it contains arguments the general form is messageString argl arg2 argN The receiving object must understand the message and any arguments that are delivered object This is a string containing the object label or ID The label must be specified using the ID modifier or entered in the Object Name field in the Graphic Object Editor lt metafile gt This is a string containing the metafile name of the receiving window note Message String and Object may contain spaces UM ENG 3 1 0 10 34 Meta Scripts Table 21 The SEND lt Message gt TO Command Rev 3 example RESET In a text button enter SEND AUT TO RESET In a text button enter UTNECIRL SE ND EMPTY Cont In the above example two separate buttons send messages to a Trigger object called Tank Cont There are actions AUT and EMPTY in Tank Cont that match the messages in Q Tank example AUT Action FW1 0 9 LS FM109 LS EMPTY Action FW109 MV 0 FA109 MV 20 FA109 LS AUT FM109 MV 100 AUT n A AUT
74. number An integer VARCHAR a string Format 1 forml example CREATE TABLE VARIABLE CREATE TABLE VARIABLE lt tableName gt FIELDS LABDATA FIELDS fieldNamelfieldFormatl TM VARCHAR fieldName2fieldFormat2 PH NUMBER SAMPLE1 NUMBER PERIOD NUMBER fieldNameNfieldFormatN COMMENT VARCHAR This example creates a table variable whose fields are TM Characters PH SAMPLE1 Numbers SAMPLE2 A number PERIOD A number COMMENT A variable sized character buffer I e a string The table is empty Le it has no records when it is first created You can use the INSERT INTO entity command to add records to it UM ENG 3 1 0 10 71 SLdIXOS VLAN Meta Scripts Rev 3 Table 59 The CREATE TABLE VARIABLE Command format 2 form2 example CREATE TABLE VARIABLE CREATE TABLE VARIABLE lt tableName gt LABDATA OF fieldFormat OF NUMBER SIZE lt number of fields gt SIZE 100 This example creates a table variable which has numeric fields ATIRI to ATTIRIOQG For the type you can use the standard types of field I e These are the format specifications of the new fields They can be either of the following forms NUMBER A number An integer VARCHAR A string Use You can use the table variable like any other view or entity Le In graphics e With a chart or browse widget e In meta scripts amp graphics e
75. orm 3 form example DISPLAY WINDOW lt file gt DISPLAY WINDOW waterpid FRAME lt xl gt ul lt H2 gt lt a gt FRAME 16000 16000 32000 32000 RELATIVE TO SCREEN RELATIVE TO SCREEN 0 0 32767 0 The pop up window will appear approximately in the lower right quarter of the screen irrespective of the position of the parent window Parent Window 16000 16000 waterpid 32000 32000 0 32767 32767 32767 Form 4 form example DISPLAY WINDOW lt file gt DISPLAY WINDOW iconbar ERAME xl lt yl gt x year FRAME 20000 0 22000 25000 The pop up window will be positioned relative to the origin of the parent window by the amounts given in the window FRAME command Parent Pop up Window UM ENG 3 1 0 10 27 SLdIXOS VLAN Meta Scripts Rev 3 SET PRINTER TO Table 13 The SET PRINTER TO Command SET PRINTER The SET PRINTER TO command is used to set up the name of the device that the TO next PRINT or PRINTLN statements see the next section PRINT and PRINTLN on page26 are to send their output to Once the device is defined the outputs of the subsequent print statements go to that device until the next SET PRINTER TO statement There are five main kinds of SET PRINTER TO statements 1 STDOUT Format Output goes to This is the default SET PRINTE
76. p format for subsequent print statements argument lt exprn gt The expression must evaluate to one of the string formats that are given in the table Time Date amp Duration Formats in the section Date and Time Handling example example SET DATE FORMAT TO This will have a print out that looks like Ddd MMMM CCYY this PRINTLN Today is SRCBOTRINGN MEE Today is 2nd August 1994 example example This will result in the following print SET TIME FORMAT TO out hh mm AM PRINILN It is now It is now 05 33 PM TIMESTR NOW UM ENG 3 1 0 10 40 Meta Scripts Rev 3 Table 27 The SET FORMAT Command example example SET DURATION FORMAT TO o Q 9 9 4 SH m 6S 1 PRINTLN Time to changeover is Mn DURATIONSTR TIME 8 0 0 NOW This example will give a print out like Time to change over is 2 hours 3 minutes 5 seconds 123 milliseconds embedded formats You can also embed the format within some commands without using the SET FORMAT command E g PRINTLN TIMESTR NOW MMM DD YY will result in Oct 15 94 note For additional date time and duration commands refer to the chapter on Date and Time handling UM ENG 3 1 0 10 41 SLdIXOS VLAN Meta Scripts SET POINTER Rev 3 Table 28 The SET POINTER Command SET POINTER The SET PO INTER command creates an alias which is used to indire
77. possible states and referenced in Macro View as a DBASEA entity STATEDB This database has a text field TEXT which describes the current state The record number of the database corresponds to the state number within the PLC On a MacroView schematic the following Textual Update MAT Text modifier could be used to display a textual description of the current state of the PLC startup shutdown sequence FETCH ABSOLUTE STATE PV OF STATEDB RETURN PLC State STATEDB TEXT Important Note The above example uses a DBASEA entity to access the required database In this case when the value of STATE PV 1 the record pointer is set to 1 in the data base which is the first record in the database When STATE PV 2 the pointer is set to record 2 etc If you are referring to a VIEW rather than a DBASE4 entity the first record in the VIEW is actually record 0 zero So when the value of STATE PV 1 the pointer will be set to record number 2 in the database FETCH RELATIVE form example Hy ETCH RELATIVE offset OF FETCH RELATIVE STATE PV OF lt DBASE4 entity gt STATEDB This will move the current record number relative to its current position and will accept a positive or a negative number UM ENG 3 1 0 10 60 Meta Scripts Rev 3 LOOP THROUGH Table 49 The LOOP THROUGH Command
78. pts Rev 3 TERMINATE Table 40 The TERMINATE Command TERMINATE The terminate command terminates e The meta script itself and e The program that is running the meta script The program that is running the meta script must have the ability to recognize the Restricti estrictions terminate signal for this to be effective Format TERMINATE example TERMINATE LOOP THROUGH Table 41 The LOOP THROUGH Command LOOP The LOOP THROUGH command is a flow control command that is specific to THROUGH database and is therefore discussed in more detail in the database section UM ENG 3 1 0 10 52 Meta Scripts 10 11 Database Functions Rev 3 These statements are SQL like statements that enable you to work with databases The diagram below is a summary of the database statements available in the meta script language The tables on the next pages discuss these commands in more detail INSERT IN e FI at VA ERT INTO Elia es SERT INTO Btltuye ELDS attri EXE 2 UES exprl exprz 4 UPDATE UPDATE S a lt entity gt ET attrl exprl LEtrZ Bexpra g ETE FROM Eibyo RE CURRENT DELETE ETE ALL FROM ELE yo CH FIRST QE i JAY QR CH PREVIOUS EVIOUS WHERE Exprn gt EXT OF EXT OF
79. ramming method in MacroView The next chapter Programs describes other programming tools that are now used less often All About Meta Scripts The meta script language consists of commands that have been tailored to be most useful in the process control and SCADA environment The following meta script features are considered most important Integration into Macro View The programs may be embedded in the Macro View graphics structure You may perform useful tasks without having to leave the Macro View environment e Real time and Historical Functions You may access manipulate and control real time and historic data using the meta script commands e Database Functions There is a set of powerful SQL like database commands that enable such tasks as filtering searching appending records etc Graphical Functions You may embed the meta scripts in the CAD diagrams to perform custom presentation tasks such as setting the colour of objects based on real time data Engineering Language Above all the meta scripts language is ideally suited for engineers It is possible to achieve extremely useful functions quickly without the need for extensive programming training Unlike programming languages like C and Fortran a useful control function can be achieved with as few as 2 or 3 statements Meta Script Structure The best way to learn about meta scripts is to look at an actual example The example on the next page shows
80. resent both a date and a point in time The three arguments represent the year month and day of the month specifications respectively The decimal places that may be present in the arguments are ignored The year value must be greater than 1970 The month value must be between 1 and 12 inclusive The day value s limits vary depending on which month and year is specified The hour minute and second values of the resulting timestamp are set to Zero i e 12am in the morning DATESTR tstamp DATESTR NOW Oot lap 1393 This DATESTR function implementation requires a single timestamp its argument It returns a string representation of the time stamp based on the default format strings specified by SET DATE UM ENG 3 1 0 10 95 SLdIXOS VLAN Meta Scripts Rev 3 Function Example Comment FORMAT TO command DATESTR tstamp format DATESTR NOW MMM DD QELI Ut 18 Lees The DATESTR function requires a time stamp as its first argument and then a formatting string as the second argument It returns a string representation of the timestamp based on the format strings The available format string structures are listed in the table Time Stamp and Duration Format String Options It is actually equivalent to the TIMESTR function with two arguments but has been made available if programmers wish to explicit differentiate between dates and times
81. rogram UM ENG 3 1 0 10 32 Meta Scripts Rev 3 END lt message gt TC Metafile window D lt message gt TO lt metafile object END lt message gt TO lt metafile gt Objects must be labelled with ID or Object Name and must be able to understand the message NOTE There are a number of Dynamic Graphic Objects DGO s used throughout the MacroView system some of these are specific to the standard MacroView Navigator package whilst others are embedded within the operations program xops3 itself The MacroView Navigator contains a number of objects such as the MessageCenter trigger program etc which can be used to provide functionality Please refer to the Navigator User Manual U NAV 3 1 0 for a complete list of these and a description of their use UM ENG 3 1 0 10 33 SLdIXOS VLAN Meta Scripts Rev 3 Table 20 The SEND lt Message gt TO Command format There are four main formats that can be used with the SEND lt message gt TO command format Message goes to SEND lt message gt TO lt object gt An object in the same window SEND lt message gt TO metafilerobject An object in the window lt metafile gt SEND lt message gt TO lt metafile gt SEND lt message gt TO MetaFile A window called lt metafile gt Note that you cannot send messages between windows that have been created from different base wi
82. s on the screen regardless of the current window update T 4 We SEND Update TO MetaFile rate UM ENG 3 1 0 10 38 Meta Scripts Rev 3 SET FROM ATTRIBUTE Table 25 The SET FROM ATTRIBUTE Command SET FROM The SET FROM ATTRIBUTE command is used to access an Entity attribute ATTRIBUTE where the entity and or attribute is specified in another variable format format SET lt stringVar gt FROM ATTRIBUTE dentitsVari attrUarl Where entVarisa string variable containing a valid entity name and attrVar is a string variable example containing a valid attribute name for the entity type SET selectTag FROM ATTRIBUTE LOl10 PpV This is used typically in Action programs associated with double clicking on a Browse Box UM ENG 3 1 0 10 39 SLdIXOS VLAN Meta Scripts SET FORMAT Rev 3 Table 26 The SET FORMAT Command SET FORMAT The SET FORMAT command is used to set up the time date and duration formats for subsequent print statement Refer to the Time Date section There are three main commands format format en ere Pee an eer Sets the date format for subsequent print statements SET DURATION FORMAT T gt z ace VOTER Sets the time duration format for subsequent print statements S TIME FORMAT TO gt en Sets the time stam
83. se GLOBAL or LOCAL variables Only use GLOBAL if the variables are to be used by other applications Use LOCAL if the variable has no use outside this meta script Do not specify LOCAL or GLOBAL if a search through the parent is required Refer to the diagram below Example using LOCAL and GLOBAL Variables TEXT BUTTON LOCAL y LET y HIGH LOCAL x LET x y ALARM RETURN 1 LET x y ALARM Uses local x not global x as previously defined as LOCAL x UM ENG 3 1 0 INIT EARLY PROGRAM GLOBAL x LET x 23 TEXTUAL UPDATE LOCAL y LET y x 2 RETURN y LET y x 2 Will use x from INIT EARLY PROGRAM as x LOCAL GLOBAL is not specified 10 20 Meta Scripts Rev 3 10 9 Action Statement Action statements are statements that do something For example LET PRINT etc The diagram below is a summary of the main action statements These statements are discussed in more detail in the next pages of this section DISPLAY lt tile gt varName lt exprn gt DISPLAY WINDOW lt file gt ent attr exprn DISPLAY WINDOW file FRAME xl yl x25 4 y2 RELATIVE TO SCREEN attr entity lt exprn gt ECUTE string expression DISPLAY EXIT WINDOW EXIT D lt exprn gt 1 IO lt exprn gt TLN lt exprn gt SID
84. second form example ET calcCircum RETURN 3 14151927 diameter ET diameter 2 4 ET circumference EXECUTE calcCircum A view on a table variable may not be created for the first time from within an execute command UM ENG 3 1 0 10 24 Meta Scripts Rev 3 DISPLAY Table 10 The DISPLAY Command Statement Description DISPLAY The DISPLAY command causes the operations program i e xops3 to display a window There are two major variants of this command DISPLAY lt exprn gt Which replaces the window being shown DISPLAY WINDOW lt exprn gt Which causes a new window to appear on top of the parent window As the examples show below you have control of the position and size of the new window Refer to the diagram below Before Before DISPLAY Metafile 1 DISPLAY Metafile 1 Command Command DISPLAY metafile 2 DISPLAY WINDOW metafile 2 Before DISPLAY Command Before Metafile 2 DISPLAY Metafile 2 Command The new display replaces the You have control of the size old display and position of the new window Note It is important that you use the correct pathname for the metafile being used in these commands If these commands are used within the Macro View Navigator it should be remembered that the Navigator is started from the MACRODIR directory this is normally set to the configuration directory E g u
85. selected This must evaluate to a string that is passed to the RDBMS which is used as the expression to get the record of interest Form 1 form example FETCH FIRST OF entity FETCH FIRST OF OPLOG FETCH LAST OF entity FETCH LAST OF OPLOG The examples above move to the first record and last record of the database entity OPLOG respectively Next form form example FETCH NEXT OF entity FETCH NEXT OF OPLOG This moves you to the next record in the database form example FETCH NEXT OF entity FETCH NEXT OF OPLOG WHERE WHERE lt searchExprn gt AREA POWER This moves to the next record in the database where the field AREA has been set to POWER UM ENG 3 1 0 10 58 Meta Scripts Table 47 The FETCH Command Rev 3 FETCH form example PREVIOUS FETCH PREVIOUS OF FETCH PREVIOUS OF BATCHS lt entity gt This moves you to the previous record in the database form example FETCH PREVIOUS OF entity FETCH PREVIOUS OF BARCH9 WHERE WHERE lt searchExprn gt CUSTOMER AMALG This moves back in the database until it reads a record where the field CUSTOMER has been set to AMALG FETCH FIRST form example OF FETCH FIRST OF entity FETCH FIRST OF BA
86. si deu 10 52 LOTT Database Functions neue 10 53 TINSER Trace naheueuneene E NRRGGRSEOGaagdaagaadaeddaagquagaqaaadagequdadqan 10 54 UPDATE cue ee Thiel D UI m M M MI IM LE 10 56 DBLEETE snsssesnesssppseedezedadaddededieieid dicis edic dieddieiesiates 10 57 EETCT Lie eee 10 58 LOOP THROUGH 5 5 5 eeposest enet eoe eite shat ch cash tee eene aste haee eet d eb pee iisen 10 61 CREATE VIEW and DROP VIEW 2 nieto tesi epa eet ee e ue dae 10 63 CREATE VIEW FROM FILE filename essere neret 10 69 CREATE TABLE VARIABELE x tritici ccce eese eee desees cedet 10 71 CREATE HISTORICAL VIEW 226 unnaantaunuau gau a an HSOHUUdadaas 10 73 DBERR andjDBERRS TR A E E O EE E II T sanders ious 10 77 DB Error Codes and Strings eeeessseesseeeeeeeeeeeeeee eene nennen enne nnne eene 10 79 10 12 Operators and Functions cereo reete eee ete ede ete une te exte demens 10 80 Operators t oho oe eet et eB 10 81 Special Macro View functions eese eoni Nee eee eee enne nnne ettet tenens sese tete aene esed e sega 10 83 Miscellaneous Eunctions 2 seu naa WR 10 84 String Related Punctons ic otii nee 10 86 Trigonometric Hyperbolic and Logarithmic Functions eeeeeeeenn 10 89 Binary Arithmetic Functions 0 mne SAGA EE tete 10 90 10 13 Time and Date Functions 20 0 eee cceccnceccccceeeeeennneeeeceeeeseeennaaeeeeeeeeseeesaaeeeeeeeeseeeeeaaeeeeeees 10 91 UM ENG 3 1 0 10 2 Meta Scripts Re
87. that you can enter and execute the meta scripts as the table below indicates Table 2 Methods to enter Meta Script Environment Entering the Meta Script Starting the Meta Script The version III graphics Type the meta script into the Graphic Typically the meta script is environment Object Editor started from a button or is Note see the graphics section executed continuously while the display is active From the Unix prompt A UNIX script can be initiated from the UNIX prompt or from the alarm manager for example You can create the meta script with any text editor and save it in a file in the UNIX system You can start the execution of the meta script by using the mshell command Le mshell lt scriptname gt From a DOS prompt in Windows NT A DOS batch file can be initiated from the DOS command line or from the Alarm manager for example You can create the meta script with any text editor and save it in a file in the NT system You can start the execution of the meta script by using the wmshell command Le wmshell lt scriptname gt UM ENG 3 1 0 10 10 Meta Scripts Rev 3 Mshell meta shell and wmshell The mshell and wmshell exe are programs for UNIX and NT systems respectively which can be used to run a meta script without starting the operation program xops3 Use It is generally used where no direct graphical output is required E g i ii iii
88. the major components of a typical meta script This meta script is executed when the opacity exceeds the regulation limit It carries out the following functions Table 1 Example Structural Components Function Introduction Type of Instruction Checks to see if the boiler is on line oe Control Statement UM ENG 3 1 0 10 5 SLdIXOS VLAN Meta Scripts Rev 3 Sets a valve in manual and shuts it LET Action Calculates the exceedance variable E Operator Prints a message to Standard Output PRINT Action INSERTS a record in a database and INSERT Data base Command updates the record date and time DATE TIME b Date amp Time functions It is important to understand the different types of instructions because the documentation is organized according to these functions Le There is a section on Control Statements a section on Actions etc UM ENG 3 1 0 10 6 Meta Scripts Components of a Meta Script Comments Rev 3 Precede the comment with a double forward slash Reaction to an opacity exceedance BOILERI ET FW109 ET FW109 ET excdnce RI INSERT INTO FIELDS DT TM EXCXE VALUES DATE TIME Exceedance gon Stack 1 Example This meta script is started off from an alarm It contains all o
89. tion convention These variables may be used freely in meta scripts You may make the variables any length although we recommend a length of less than 20 characters There are LOCAL and GLOBAL Variables See the next sections on when to use LOCAL and GLOBAL variables LOCAL variables are available for use by the window and it s children GLOBAL variables are available in every application used by that operational program You may not choose a variable name that is the same as a system variable name e g Black By convention variables Start with a lower case letter Have an uppercase letter at the start of a new word within the variable e g numBatch and Where the word is too long abbreviations are created by eliminating the vowels in the word E g for testbed control tstBdCtrl temp tankAlarm floMax opctyLm Note That there is no maximum size of variables SYSTEM VARIABLES Convention Restriction Examples These variables are reserved by the system and have specific meanings as discussed in the next table System Variables By convention system variables start with a capital letter E g Black UserName You may not write to system variables You may not create your own variables with the same name as a system variable HalfMagenta ConsoleType For a full list of user accessible system names Refer to Tablel System Variables on pagel2 ENTITY ATTRIBUTE format These var
90. ts of degrees SIN x SIN 30 Trigonometric sine with argument in 0 5 units of degrees TAN x TAN 30 Trigonometric tangent with argument in 0 58 units of degrees DTOR x DTOR 60 Degrees to Radians conversion 1 04720 function The trigonometric functions work in degrees as a match to most user s requirements The degrees radians conversion functions provides a convenient means of converting between the two PIO PI Returns a value for p to 12 decimal 3 1415927 etc places RTOD x RTOD Radians to Degrees conversion 1 04719 60 function COSH x COSH 1 5 Hyperbolic cosine 2 3524 SINH x SINH 1 Hyperbolic sine l 1752 TANH x TANH 3 6 Hyperbolic tangent 0 9985 EXP x Exe vj Exponential power Sa 053 LOG x LOG 12 Logarithm base e 2 4849 LOG10 x OSL Log Logarithm base 10 1 0792 UM ENG 3 1 0 10 89 SLdIXOS VLAN Meta Scripts Binary Arithmetic Functions Rev 3 Table 73 Binary Arithmetic Functions BINAND y BINAND 37 15 Performs a binary AND operation on a 5 series of integer arguments BINNOT x BINNOT 37 Performed a binary NOT operation on 38 an integer The NOT calculation is performed with reference to a 32 bit word regardless of the word size of the hardware platform being used BINOR x y BINOR 37 15 Performed a binary OR operation on a 47 series of integer arguments BINXOR x y BI
91. u can type in meta script commands PRINTLN NOWO ENTER Tue 23rd Sept 8 45am Hitting the ENTER key again will return you back to the command line prompt 10 11 SLdIXOS VLAN Meta Scripts Rev 3 mshell and wmshell arguments There are various arguments that can be used in the mshell command line both interactive and background modes Le e init varl xxx var2 xxx This allows various variables to be set to initialized values E g mshell init lineStatus Healthy ptr LABELI ENTITY1 LABEL2 ENTITY2 This allows various pointers to be set to Entity names E g mshell ptr LABEL1 FIC100 v This displays all the available options Error Handling All Macro View errors that occur are logged in a dedicated table variable called ERRLOG The ERRLOG table variable has four attributes called TM DT MSG and CODE All of the attributes are strings with the exception of the CODE which is numeric The table is limited to 1024 entries You can trap for an occurrence of an error using the following command ON ERROR RUN lt metascript gt Where met ascript is a meta script that evaluates to an ascii string The string defines a meta script filename which is executed when the error is trapped Typically the meta script program would 1 Examine the contents of the current record in the ERRLOG table variable and ii Cause some graceful shutdown of the program Alternatively if you are using the
92. ue The return statement is often used in returning results such as colors in graphic meta scripts format Format example RETURN RETURN E RETURN lt exprn gt RETURN HalfCyan UM ENG 3 1 0 10 49 SLdIXOS VLAN Meta Scripts RUN Rev 3 Table 37 The RUN Command RUN This statement enables you to run an external program from within the meta script The script is executed in the background There are three possible formats as shown below Format 1 RUN lt exprn gt This statement enables you to run an external program from within the meta script The script is executed in the background The expression must return a string that consists of the name of a program plus any arguments if required RUN rm f u macro config temp dbf UNIX examples RUN usr openwin bin textedit etc hosts amp UNIX RUN beep RUN exercise FW109 MV RUN C Program Files Windows NT Accessories wordpad exe NT Format 2 pus This statement enables you to run a UNIX Bourne shell script from within the meta script LET lt tagName gt RUN command string In this version the script is executed in the foreground I e the meta script will wait till the program returns a value The tagname can be a variable or an entity attribute pair The expression must return a string that consists of the name of a Bourne shell program plus any arguments if required This allows a UNIX applicat
93. update a Batch browse widget as the customer browse widget is stepped through Only those records that have the same customer name as the current record in the CUSTOMER database are shown Special notes on Views You may use VIEWS in exactly the same way you would use attributes and entities Le once you have created a view and given it a viewName you can use the attributes Le fields or columns in value updates bars pies edit areas etc Graphics Use You can browse a VIEW in exactly the same way as a database entity Browse Use Use the FETCH command to position the current record in the view Note that the Fetch value used in the graphics i e bars values etc is the value at the current record UM ENG 3 1 0 10 67 SLdIXOS VLAN Meta Scripts Rev 3 Table 56 The CREATE VIEW and DROP VIEW Command Loop through The LOOP THROUGH command can be used with a view in the same way it is used with an entity Typically the CREATE VIEW command is first used to filter out only those records of interest before the LOOP THROUGH command is executed You can use entity attributeclauses within the WHERE string without explicitly converting them to strings This is true throughout the meta script language and is done for convenience Entity Variables in WHERE For example clauses WHERE RTRQ gt FA109 PV FW109 PV Special Note on Views and Record
94. ured ratio to the selected record of a database entity called BATCHO UM ENG 3 1 0 10 56 Meta Scripts DELETE Rev 3 Table 45 The DELETE Command DELETE This command enables you to delete selected records from a database entity or a view of a database entity e There are two forms of this command Format e You can delete the current record form 1 e You can delete all records form 2 entity Arguments The database entity Form 1 form example DELETE FROM lt entity gt DELETE FROM OPLOG WHERE CURRENT WHERE CURRENT Form 2 form example DELETE ALL FROM lt entity gt DELETE ALL FROM BATCH9 This example deletes all the records but not the database itself from the database entity BATCH9 UM ENG 3 1 0 10 57 SLdIXOS VLAN Meta Scripts FETCH Rev 3 Table 46 The FETCH Command FETCH This command fetches the selected record from the database entity In reality it moves to the selected record and makes it the current record Le It sets the RECNO attribute of the database to the selected record number Format As shown below there are various forms of this command to enable you to easily find the record of interest entity Arguments The database entity sarchExprne The expression that is used to search through the database to find the record to be
95. utput goes to The input of a program called lt exprn gt The outputs of the print statements are sent to the input of the program called mail The program sends a mail message to the user macro PRINT and PRINTLN Table 15 The SET PRINTER TO Command PRINT and PRINTLN argument These statements print information to the device that has been specified by the SET PRINTER TO statement format PRINT lt exprn gt PRINTLN lt exprn gt The expression must evaluate to a string The string is then sent to the selected print device There are a number of string related functions described later in this chapter that can be used to create the required content and format of the string Send the string lt exprn gt to the print device Send the string lt exprn gt to the print device and append a new line character UM ENG 3 1 0 10 29 SLdIXOS VLAN Meta Scripts Rev 3 example example PRINTLN This simply causes a new line character to be sent to the printer device example example PRINT Level LI109 PV3 Note See the section Operators and Functions on page76 on curly brackets The evaluation of string variables can be simplified with the curly bracket notation Le and The curly brackets show parts of the expression that must be evaluated first Use the curly brackets to evaluate the variables or entity attributes in a string first For
96. v 3 Time Date and Duration Concepts eeessseeesesseeeeeeeeeenre nennen enne enne nnne 10 92 Combining Different Formats oi uie eee eua 10 93 DATE and TIME Functions seseeseseeeeeeeeeeeee esee eene eee eennn nnns nnese ee enne nens nnee ennt 10 94 Date and Vime Operators d dod edebat eet dele fele el aa oeta pini 10 101 Date and Time Related Set Actions ccccccccccessesssnnecccceeeseeessnaaeeeceseeseeesnaaeeeceseeeeeeeaaaes 10 103 Time Stamp and Duration Format String Options eene 10 103 List of Tables Table 1 Example Structural Components 10 5 Table 2 Methods to enter Meta Script 10 10 Table 3 Variable types summary 10 14 Table 4 Variable Definitions 10 15 Table 5 System Variables 10 17 Table 6 Global and Local Variables 10 18 Table 7 The LET Command 10 22 Table 8 The LET Command 10 23 Table 9 The EXECUTE Command 10 23 Table 10 The DISPLAY Command 10 25 Table 11 The DISPLAY Command 10 26 Table 12 The DISPLAY Command 10 27 Table 13 The SET PRINTER TO Command 10 28 Table 14 The SET PRINTER TO Command 10 29 Table 15 The SET PRINTER TO Command 10 29 Table 16 The SET PRINTER TO Command 10 31 Table 17 EXIT WINDOW Command 10 32 Table 18 The EXIT Command 10 32 Table 19 The SEND lt message gt TO Command 10 32 Table 20 The SEND lt Message
97. ver recommend that you become thoroughly familiar with a limited number of commands such as those listed below before progressing with the much larger set of commands UM ENG 3 1 0 10 8 Meta Scripts Most common meta script tools Rev 3 ACTIONS varName lt exprn gt ent attr lt exprn gt DISPLAY WINDOW lt file gt PRINTLN lt exprn gt PROGRAM CONTROL IF condition aoctions IF ELSE accToms Condition ETURN actions actions DATABASE FUNCTIONS INSERT INTO lt entity gt FIELDS fieldl lt field2 gt VALUES lt valuel gt value2 FETCH NEXT OF entity WHERE lt exprn gt n fieldl exprl lt entity gt field2 expr2 p 4 VIEW lt viewName gt AS ROM ELECTI lt selectSpec gt lt entity gt HER E filterSpec RD R BY orderSpec OPERATORS FUN CTIONS ABS STR FLASH INT VAL RAND CHR SUBSTRIJ HISTORICAL VIEWS CRE AS field field WITH period WHE ATE HISTORICAL VIE lt tableName gt SELECT amel ent attrl ame2 gt ent attr2 gt lt duration gt lt hForm gt RE TIME gt lt stertistamp gt AND TIME
98. x y MAX 12 7 26 5 3 Returns the maximum value in a series 26 of numbers OSQ OS Returns the name of the operating SCO Unix system as a string OSVERSION OSVERSION Returns the version number of the 3 2 4 operating system as a string RAND range RAND 99 9 Returns a random number that lies 80 1 between 0 and the range specified ROUND num decimals ROUND 12 37 1 Returns the numeric argument UM ENG 3 1 0 10 84 Meta Scripts 12 4 rounded of to a certain number of decimal places SQRT x SQRT 9 Returns the square root of the numeric 3 argument SQWAVE x y SOWAVE 3 1 5 Returns a 1 for x seconds and a 0 for ed d dis y seconds repeatedly 0 for 1 5 seconds 1 for 3 seconds etc VERSION O VERSION Returns the Macro View version 3 0 4 number as a string DBERR lt entity gt DBERR OPLOG Returns the error number resulting DBERR lt view gt 21 from the execution of the last database command A zero is returned if no error occurred See the Database Functions on page48 for details DBERRSTR entity DBERRSTR OPLOG Returns the error description string DBERRSTR view OPLOG Error 10 resulting from the execution of the last Opening database database command This is an empty string if no error occurred See DBERR and DBERRSTR on page73 for details UM ENG 3 1 0 10 85 SLdIXOS VLAN Meta Scripts String Related Functions Rev 3
99. xample First create a string that LET fileName HIST uses the last characters as the month number I e STR MONTH Tabi APRIL is HIST4 CREATE VIEW CURMONTH AS SELECT FROM FILE hist fileName E Now use the string variable to access the current history file Refer to String Related Functions on page82 for an explanation of the STR command and Database Functions on page48 for information on the MONTH command UM ENG 3 1 0 10 69 SIdRDS VLAN Meta Scripts Rev 3 UM ENG 3 1 0 10 70 Meta Scripts Rev 3 CREATE TABLE VARIABLE Table 58 The CREATE TABLE VARIABLE Command CREATE TABLE The CREATE TABLE VARIABLI VARIABLE variable that has the same characteristics as a database This provides a convenient structure for storing and viewing e g using the browse widget tabular data that you don t want stored on the disk arguments tableName This is the name of the table You may use this name in the same way as a view or an entity It must be upper case fieldNamel amp fieldNameN These are the field or column names of the table variable They may be referenced as attributes in the normal way and they must be uppercase fieldFormatl amp fieldFormatN These are the format specifications of the new fields They can be either of the following forms NUMBER a
100. xcept that it 4 Hound searches starting from the end of the string s2 as opposed to the beginning REPLICATE string n REPLICATE AB 3 Returns a string that is a replication of ABABAB the string passed as an argument The string is replicated n times RIGHT string n RIGHT ABCDE 2 DE Returns the n right most characters in the string RTRIM string RTRIM Hello Strips trailing spaces from a string and Had returns the results SPACE number SPACE 5 Returns a string with the specified I e a string with 5 spaces number of spaces in it STR num width prec STR num width STR num SIR ULZ439 2 1 4 Converts the numeric value num into a string The string returned will have the specified width and the string representation will have prec decimal places The width and precision specifications are optional If the precision is not specified then the system will choose a precision to use If the width is not specified then however many characters are needed to represent the number by a UM ENG 3 1 0 10 87 SLdIXOS VLAN Meta Scripts Rev 3 string are used If the specified width is insufficient to represent the number then fewer decimal places will be used If the width is still insufficient when using no decimal places then the string will be filled with asterisks to indicate that it was not possi

Download Pdf Manuals

image

Related Search

Related Contents

Guide d`utilisation 4765 - Support  LG Electronics 37LH265H Flat Panel Television User Manual    N1000/N2000 Guida dell`Utente    Lib Titanium+ Ariston.indd  Panasonic WV-SW174W surveillance camera  SGT-8500 - Lanterna Led 3.7V (1800mA) - MN  User Manual  Media receiver Clarion FZ501E with Bluetooth  

Copyright © All rights reserved.
Failed to retrieve file