| |
The @library and @uselibraryfile commands allow more than one script file to be used during compilation. The file to be used must begin with an @library keyword which gives the library a name. To use the library script the @uselibraryfile keyword is used to include the library file at that point in the script. Note that if you want to jump between files at runtime use the @include and @run commands.
The @library command gives the library file a unique name that is independent of the file name of the script. This is required so that the compiler can ignore subsequent calls to the same library script and prevent accidental circular calls. Because of this requirement the @library command must always be the first command line in a script file (including implicit host command lines).
The syntax for @library is :
@library library-nameEg. In the file mymaths.cmd.
! This library file mymaths.cmd contains simple maths functions ! Note that @library must be the first command line in the script @library mymathsfunctions @function boolean is_even(integer num) @begin @set is_even = (num % 2 = 0) @end @function boolean is_odd(integer num) @begin @set is_odd = not is_even(num) @endThe @library command may only appear once in a file, and when used it must be the first command line in the file.
Different files with the same library name are considered to be the same library by the OVM compiler.
The best use for library files is to store commonly used variables, procedures, functions, and subroutines.
Library files can still be used as ordinary scripts (if appropriate).
When you want to use a library file you tell the OVM compiler the filename (not the library name) to use with the @uselibraryfile command.
! Library file is used / compiled here @uselibraryfile 'mymaths.cmd' @integer somenum = random(100) @if is_even(somenum) then @comment(somenum," is an even number")Although you can use the @uselibraryfile command within a @begin - @end block this does not allow you to use the same library again in a different place. But it will limit the visibility (scope) of the contents of the library file.
You can only use any given library file once in a compile. The compiler will issue a warning if an attempt has been made to use a library more than once.
Note. Any errors or warnings generated while compiling the library file appear against the line number of the library file.
| |
| 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. |