Previous: ISL Overview Next: File ISL Tags Table of contents Images Frames Unidata's Integrated Data Viewer > Miscellaneous > IDV Scripting

7.1.1 Basic ISL Tags

<isl> Top level ISL tag
<isl
    debug="'true' or 'false'"
    offscreen="'true' or 'false'"
    loop="integer loop count"
    sleep="seconds to sleep" >

The isl tag is the top level tag. It acts just like the group tag but it can also hold a debug attribute which results in status messages being printed out. The offscreen attribute allows you to turn off off screen rendering (the default is to do offscreen rendering).


<group> Group a set of tags. Possibly loop.
<group
    loop="integer loop count"
    sleep="seconds to sleep after each loop iteration" >

The group tag holds a arbitrary number of children tags.


<property> Define a property
<property
    name="property name"
    value="property value"
    fromfile="filename to read contents from"
    global="true/false" >

You can define properties with the property tag. Any subsequent tag may have these property values substituted by using:

${propertyname}
e.g.:
   <property name="basedir" value="/some/directory"/>
   <property name="fromfile" fromfile="${islpath}/template.txt"/>
   <property name="imagetype" value="png"/>
   <image file="${basedir}/theimage.${imagetype}"/>
The state within an ISL is stack based - i.e., if you are in a group tag or calling a procedure (see below) the properties that are defined there are local to that group or procedure call. When you leave that group or procedure call any properties that are defined are removed. However, you can specify global="true" in the property tag and this will cause the property to be defined globally.

There are a set of predefined properties that can be used. As described above, if you are in a loop the property ${loopindex} will be set to the loop index. e.g.:

<isl loop="1000" sleep="3600">
   <bundle file="test${loopindex}.xidv"/>
</isl>
The set of date and time values for the current time are also available. The property names are those defined for the Java SimpleDateFormat class.

The time properties are:

${yyyy} Year
${yy} Last 2 yar digits
${M} month number
${MM} two character month number
${MMM} Short month name
${MMMMM} Full month name
${D} Day in year
${d} Day in month
${dd} two character day in month
${EEE} Day name
${H} 0 based hour in day (24 hour)
${HH} 0 based two character hour in day (24 hour)
${k} 1 based hour in day (24 hour)
${kk} 1 based two character hour in day (24 hour)
${K} Hour in am/pm (12 hour)
${KK} two character hour in am/pm
${a} am/pm
${mm} two character minute in hour
${s} second in minute
${ss} two character second in minute
${S} Millisecond
${Z} Timezone
${G} Era designator
You can also define a property with "now:<some date format>" in it. This takes the current time and formats it with the full date format. e.g.,:
  ${now:yyyy-MM-DD}
  ${now:yyyy_MM_DD:hh:mm}
You can also use "time:" to use the current animation time as the time to format:
  ${time:yyyy-MM-DD}
  ${time:yyyy_MM_DD:hh:mm}

<append> Append to a property
<append
    name="property name"
    value="property value"
    fromfile="filename to read contents from" >

This is just like the property tag but it appends the value.


<idvproperty> Define one of the IDV properties
<idvproperty
    name="property name"
    value="property value"
    fromfile="filename to read contents from"
    global="true/false" >

This allows you to set properties in the IDV that may affect image capture behavior, etc. For example, doing:

  <idvproperty name="idv.capture.sleep" value="1000"/>
sets the pause between each movie frame capture to be 1000 milliseconds.
<echo> Print a message
<echo
    message="text to print out" >

The echo tag allows you to print out a message. Here, for example, we are printing out the loop index and the date/time:

<isl loop="10" sleep="1">
    <echo message="Loop iteration: ${loopindex} at: ${yyyy}-${MM}-${dd} ${HH}:${mm}:${ss}"/>
    <echo>
The message can also be contained by the echo tag
    </echo>

</isl>
echo.isl

<import> Import another isl file
<import
    file="isl file" >

The import tag allows you to import another ISL file. For example, using the import tag here:

<isl>

    <import file="systemdefs.isl"/>

</isl>
import.isl
Where systemdefs.isl has:
<isl>
    <property name="prop1" value="somevalue"/>
    <property name="prop2" value="somevalue"/>
</isl>
systemdefs.isl
Will result in something like:
<isl>
    ...
    <group>
        <property name="prop1" value="somevalue"/>
        <property name="prop2" value="somevalue"/>
    </group>
    ...
</isl>
You could use the import, for example, as a way of having common property definitions (e.g., location of data, images, etc.) shared by a set of ISL files.
<procedure> Define an isl procedure
<procedure
    name="procedure name" >

The procedure tag allows you to define a "procedure" that can be called with the call tag.


<call> Call an isl procedure
<call
    name="procedure name to call" >

The call tag allows you to call a procedure. The attributes within the call tag are set as properties and can be referenced within the procedure tags. For example, here we have a procedure called "makeImage" It is called two times, passing in values for bundlefile and imagefile. As noted, you can also drop the call tag and use the procedure name as the tag name.

<isl>
    <procedure name="makeImage">
        <bundle file="${bundlefile}"/>
        <pause/>
        <image file="${imagefile}">
            <thumbnail width="25%"/>
        </image>
    </procedure>
    <call name="makeImage" bundlefile="test1.xidv" imagefile="test1.png"/>
    <call name="makeImage" bundlefile="test2.xidv" imagefile="test2.png"/>

<!-- Note: you can also call the procedure directly with: -->
    <makeImage bundlefile="test2.xidv" imagefile="test2.png"/>

</isl>
procedure.isl

<jython> Evaluate some Jython
<jython
    code="inline jython code to evaluate"
    file="jython file to evaluate" >

The jython tag allows you to evaluate jython. The Jython is specified both in line as well as file based:

<isl>
   <jython file="somejython.py"/>

   <!-- Or: -->
   <jython code="some jython code"/>

   <!-- Or: -->
    <jython>
<![CDATA[
some jython code
]]>

    </jython>
</isl>
jython.isl
This Jython is evaluated by an interpreter that has all of the normal IDV Jython libraries. The global variable "idv" points to the IntegratedDataView. The global variable "ig" points to the instance of the ImageGenerator class that is running the ISL.

All attribute values can also be prefixed with "jython:". This allows you to write a snippet of jython code that will return an attribute value:

<isl loop="10">
   <echo message="jython:'number = ' + str(${loopindex}*50)"/>
</isl>
jythoninattr.isl

<stop> Stop all processing
The stop tag allows you to processing the ISL file and exit:
<stop/>

<trace> Turn on tracing and only show the given pattern
<trace
    pattern="The regular expression pattern to match trace output on. Use .* for all trace messages" >

The trace tag allows you to turn on tracing in the IDV:

<trace pattern="GeoGridDataSource.*"/>

<pause> Pause for some time
<pause
    seconds="number of seconds to pause"
    minutes="number of minutes to pause"
    hours="number of hours to pause"
    every="number of hours past midnight" >

The pause tag can have a number of attributes:
<pause/>
No arguments will pause until all displays have been created.
<pause seconds="10"/>
Pause for 10 seconds.
<pause minutes="5.5"/>
Pause for 5.5 minutes.
<pause hours="12.5"/>
Pause for 12.5 hours.
<pause every="1"/>
Pause until the next hour. The 'every' attribute means every N hours after midnight.
<pause every=".5"/>
Pause until the next hour or half hour.
<pause every="0.25"/>
Pause until the next 15 minute time. e.g., on the hour, quarter after, half past, etc.


<foreach> For each loop
<foreach
    value1="comma separated values"
    ...="..."
    valuen="comma separated values" >

The foreach tag allows you to iterate across a set of comma separated values.

<foreach fruit="apple,orange,banana" color="red,green,blue" ... valueN="...">
    ...
    Any ISL tags.  The property references ${fruit}, ${color}, etc., will be replaced
    the values above. e.g., First time in the loop ${fruit} will be replaced with 'apple',
    ${color} with 'red', etc.
    ...
</foreach>
For example, here we are generating three different image types:
<isl>
    <foreach suffix="png,jpg,gif">
        <echo message="Creating test.${suffix}"/>
        <image file="test.${suffix}"/>
    </foreach>
</isl>
foreach.isl
Another example is to read each line from a file using the foreach:
<isl>
  <foreach foo="file:file:${islpath}/test.txt" bar="apples,oranges,bananas,peach,grape">
       <echo message="value=${foo} fruit=${bar}"/>
  </foreach>
</isl>
foreachlineinafile.isl
hello
there
how
are
you
test.txt

<for> A for loop
<for
    start="start value"
    end="end value"
    increment="increment by value" >

The for tag allows you to have a for loop. The start, end and increment attributes define the value of the index property at each step in the loop. Here's an example:

  <for start="5" end="20" increment="2">
     <echo message="printing index ${index}"/>
  </for>

<exec> Execute a shell command
<exec
    command="some shell command to exec" >

The exec tag allows you to execute external programs. For example, if you were generating images on one machine and then need to scp them to your web server you could do:

<isl>
    <property name="imagefile" value="test.png"/>
    <group loop="1000" sleep="3600">
        <bundle file="test.xidv"/>
        <pause/>
        <image file="test.png"/>
        <exec command="scp ${imagefile} yourwebserver:/imagedir/${imagefile}"/>
    </group
</isl>
exec.isl

<if> An if statement
<if
    expr="jython expression to evaluate" >

The if tag allows you to have decision structures in your ISL. The form is:

<if expr="some jython expression">
    <then>
        ... The then block ...
    </then>
    <else>
        ... The optional else block ... 
    </else>
</if>
For example, say you only wanted to generate a particular image when the hour of the day is after 12 noon. One could just go:
<isl loop="1000" sleep="3600">
    <!-- Note the less than sign is escaped -->
    <if expr="${k}>12">
        <then>
            <echo message="Generating image at ${k}:${mm}"/>
            <image file="test.png"/>
        </then>
    </if>
    <!-- Or you can include the expression in a CDATA block:
         so you don't have to escape anything -->
    <if>
        <![CDATA[${k}>12]]>
        <then>
            <echo message="Generating image at ${k}:${mm}"/>
            <image file="test.png"/>
        </then>
    </if>
</isl>
if.isl

 


Previous: ISL Overview Next: File ISL Tags Table of contents Images Frames Unidata's Integrated Data Viewer > Miscellaneous > IDV Scripting