Declarations example

Examples of declarations in an ASL script.

Modules

The following example imports a generic module file named modg.gem, into namespace nsp:

modules { import <"C:\modg.gem"> into namespace nsp }

Constants

The following example defines the global constants debug, script_version, and pi.:

constants {

  debug := false

  script_version := "4.03"

  pi := 3.1415926

}

Variables

The following example declares the following variables:

  • cust_name, which must have a value, even if the value is a single character.
  • cust_address, which must have at least 10 characters.
  • aphone, which is checked by the function goodphone.
  • age, which must be a number between 15 and 70. Errors in the age display a custom error message.
  • prod_size, which is a numeric variable.

variables {

  cust_name : text(50) input { required }

  cust_address : text(90) input { required check text_length(address)>9 }

  aphone : text(20) input { check goodphone(aphone) }

                        comment { Phone numbers are not numbers! }

  age : number(2) input { check age>=15 and age<=70

                                   on error show "Age only between 15 and 70!" }

  prod_size : number := 10

}

Enumerations

The following example declares the enumeration cardinal_point and assigns the enumerator east to variable compass:

types {

  cardinal_point: enumeration {

    north { value 10 }

    south

    east

    west

} }

...

var compass: cardinal_point

compass := cardinal_point::east

Variable compass has value 12, because enumerator north is defined as being 10, then south is implicitly assigned to 11, east to 12 and west to 13.

User-defined types

The following example defines the types client_name_type, address_type, and zip_type:

types {

  client_name_type : text(40)

  address_type : text(80)

  zip_type : text(9) comment { 5+4 }

}

Campaign and workflow records

The following example declares campaign and workflow attributes, and shows how to read and assign values to the record fields:

campaign record {

  PromotionalColor : text(20)

  PromotionalBonus : number(10)

}

workflow record {

  Color : text(20)

  Points : number(10)

}

on start {

  if workflow.Color = campaign.PromotionalColor then {

    workflow.Points := workflow.Points + campaign.PromotionalBonus

  }

  goto node "START"

}

Contact profile extension records

The following example defines contact profile extension records for the directories Sales and Support, assigns new values to the fields of the variable Support, and declares a variable of type SalesRecord:

contact profile extensions {

  Sales record for directory "sales_dir" { vip: boolean }

  Support record for directory "support_dir" { userName: text

                                                credits: number }

}

...

var newExtension : SalesRecord

Support.credits := Support.credits - 1

newExtension.vip := true

Images

The following example declares the script images logo, on and off:

dependencies {

  image "logo" in file <"C:\Images\company.jpg">

  image "on" in file <"C:\Images\button-on.gif">

  image "off" in file <"C:\Images\button-off.gif">

}

The string literals enclosed in angle brackets plus double quotes (<"...">) avoid having to escape the backslash characters of the file names.

Background image

The following example displays a logo but replaces the white logo background with yellow:

node "MAIN" {

  background image "logo" {

    tile

    transparent color white

  }

  background color "Yellow"

}

Function keys

The following example declares an event handler for function key F5, which transfers control to node Orders, after assigning the destination variables with the values displayed on the corresponding node graphical elements:

function key 5 commit {

  goto node "Orders"

}

Group graphical elements

The following example groups a static text element with an input element:

group {

  static text {

    size 40,20 at 30,10

    label "Name:" { align right }

  }

  input for Name {

    size 80,20 at 30,70

} }