• ACL, Arbortext’s Command Language, it is similar to Perl which is the programming language I prefer. See Part 1, Part 2 and Part 3.

    Arrays

    Arrays are special variables with multiple “compartments”. Each compartment holds a value. Arrays consist of names and indexes. ACL has two types of one-dimensional arrays:

    Normal arrays are indexed by integers subscripts.

    $array[1] = "tester";

    Associative arrays are indexed by arbitrary strings or keys.

    $array["tester"] = "debug";

    Declaring Arrays

    Arrays can be defined as local or global. Define them like a variable, ($) name, square brackets, semicolon. Arrays can be set to a dimension such as having ten values, $array[10].  The square brackets [ ] are used to address or retrieve the elements of an array.

    Accessing Array

    Accessing the keys of an array, use the for loop, as in: for (key in array).
    For example, the code below iterates over the two elements of the associative array color twice, once with Associative and once with Normal:

    #– Associative Array
    $color["red"] = "red";
    $color["blue"] = "blue";
    for ($hue in $color) {
     response("the color is " . $color[$hue]);
    }

    unsetvar color; #– the color array undeclared

    #– Normal Array
    $color[1] = "red";
    $color[2] = "blue";
    for ($hue in $color) {
     response($color[$hue]);
    }

    This entry was posted on Wednesday, November 4th, 2009 at 7:45 am and is filed under ACL, Arbortext Editor, Structured Authoring. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
  • 2 Comments

    Take a look at some of the responses we have had to this article.

    1. sudheer
      Jan 6th

      really great training session. The 4 parts were the introduction to variables, functions, arraays, local and global. It would be great if you can explain witt real time examples.

    2. Jan 7th

      thanks. I have placed some examples online, such as “Removing Unused Graphics” and “Wiki Help Files”, but I agree with you that I need to do more.

      d

  • Leave a Reply

    Let us know what you thought.

  • Name(required):

    Email(required):

    Website:

    Message: