Previous SectionLine Types
Document HomeContents
ConstantsNext Section

Literals

A literal is a value that is explicitly typed out in the OVM script file.

Examples include : 10, -55, "Hello World", true.

Like variables, literals fall into the categories integer, boolean, and string.

Integer Literals

Integer literals in OVM follow the Ozterm convention of decimal, and hexadecimal notation. <> indicates optional, | indicates choice of.

Decimal number = <+|-><#>one or more decimal digits
Decimal digit = 0,1,2,3,4,5,6,7,8,9

Eg. 0, 1, -1, 100, -100, #255, -#255

Hexadecimal number = <+|->$one or more hexadecimal digits
Hexadecimal digit = 0,1,2,4,5,6,7,8,9,a,b,c,d,e,f,A,B,C,D,E,F

Eg. $0, $1, -$1, $64, -$64, $FF, -$FF

@integer fred       ! define an integer variable called fred
@set fred = 100     ! set fred's value to decimal 100

@integer mary = $FF ! define mary and set mary's value to hex FF (255)

Boolean Literals

There are 6 basic boolean literals in OVM. These are ‘true’, ‘false’, ‘on’, ‘off’, ‘ok’, and ‘fail’. The literals ‘true’, ‘on’, and ‘ok’ are equivalent, as are the literals ‘false’, ‘off’, and ‘fail’.

@boolean fred = true

Boolean literals should not be enclosed in quotes.

Although internally OVM treats booleans similarly to integers you cannot assign an integer value to a boolean, or a boolean value to an integer. You can easily test an integer value to generate a boolean result by using a comparison operator. To test a boolean value use an if ... then ... else construct.

@integer fred         ! define fred
@boolean mary         ! define mary

@set mary = 20 > 10   ! mary will be set to true

@if mary then
    @set fred = 100
@else
    @set fred = 50

String Literals

A string literal in OVM is any sequence of ASCII characters (up to a maximum length of 255 characters) enclosed in matching quotes. OVM supports single, double, and back quotes.

@string mary = 'Hi there'        ! single quotes
@string fred = "Hi there"        ! double quotes
@string jane = `Hi there`        ! back quotes

Quotes of any type can contain quotes of either of the other 2 types.

@string marysaid = 'Mary said "Hi there" to Fred'

Backquoted strings support the following escape sequences :

Escape Sequence Back quoted string stores

\\

single backslash character \

\t

tab character

\r

carriage return

\n

Newline

\e

ESC character

\b

Backspace character

\`

Backquote character `

\$XX

ASCII character represented by hexadecimal XX

@display(`\e[2J`) ! send VT100 clear screen sequence to screen

Attempting to use escape sequences with anything other than backquotes will result in the characters being stored as written. This is to maintain backwards compatibility with Ozterm scripts that do not support either backquotes or escape sequences.

@comment("This isn't \r\n what you wanted.")
@comment(`But this \r\n is`)


Previous SectionLine Types
Document HomeContents
ConstantsNext Section



This publication has been prepared and written by Telstra Corporation Limited (ACN 051 775 556), and is copyright. Other than for the purposes of and subject to the conditions prescribed under the Copyright Act, no part of it may in any form or by any means (electronic, mechanical, microcopying, photocopying, recording or otherwise) be reproduced, stored in a retrieval system or transmitted without prior written permission from the document controller. Product or company names are trademarks or registered trademarks of their respective holders.

Note for non-Telstra readers: The contents of this publication are subject to change without notice. All efforts have been made to ensure the accuracy of this publication. Notwithstanding, Telstra Corporation Limited does not assume responsibility for any errors nor for any consequences arising from any errors in this publication.