Scripting

# Generated by documentation/scripting/multi_wirl.pl

.------.
| box1 |<-----------------------------------.
'------'                                    |
    |                                   .------.
    |                                   | box3 |
    |                                   '------'
    |                                       ^
    |                                       |
    |               .------.                |
    '-------------->| box2 |----------------'
                    '------'


     __________
     \         \
      \  line 1 \
       ) line 2  )
      /  line 3 /
     /_________/

Executing your scripts

Executing your scripts

transform JSON, via Data::TreeDumper, to Asciio script

The *json_dtd_to_asciio_script' script is installed with Asciio. It will read a JSON stream from stdin.

It takes the following arguments:

  • title
  • x position
  • y position
  • 'box', if you want the data to be boxed
  • start_level, 0/1: 0 meanss no start tree grlyph
<coordinates_json ./script/json_dtd_to_asciio_script '' 10 10 box 0 | stdin_to_asciio 

Simplified scripting interface

The simplified scripting interface is an API which hides some of the scripting details for you.

Examples of scripts, using both the simplified API and full API, can be found in the documentation/scripting directory of the distribution.

Simplified scripting API

Create a new Perl script

Crate a file and add these lines

use strict; use warnings;

use App::Asciio::Scripting ;

This will set some sanity checks on your code and load the simplified scripting interface.

Adding boxes


add 'box1', new_box(TEXT_ONLY =>'box1'),  0,  2 ;
add 'box2', new_box(TEXT_ONLY =>'box2'), 20, 10 ;
add 'box3', new_box(TEXT_ONLY =>'box3'), 40,  5 ;

The simplified scripting interface lets you name your object so you can later connect them together.

Adding connections

connect_elements 'box1', 'box2', 'down' ;
connect_elements 'box2', 'box3' ;
connect_elements 'box3', 'box1', 'up' ;

You can hint Asciio about the direction of your arrows.

Canonizing connections

Asciio tries to route the arrows properly, this is done automatically in the UIs but you need to do it manually in scripts.


optimize ;

Printing and saving the result

save_to "from_script.asciio" ;

ascii_out ;

You can save your work to an asciio file or print it out

Adding multi-wirl arrows

You can write more advanced script where you route multi sections arrows around your elements.

     |
     |
     |
     |
     |
     '----.
          |
          '----.
               |
               |
               |
               |
               |
               |
            <--'

You'll also need to use the right module; in fact you have access to everything that's in Asciio from your scrips, it's just a little bit more work than using the simplified interface.

# documentation/scripting/multi_wirl.pl

use strict; use warnings;

use App::Asciio::Scripting ;

#-----------------------------------------------------------------------------

add 'multi_wirl', new_wirl_arrow([5, 5, 'downright'], [10, 7, 'downright'], [7, 14, 'downleft']), 5, 5 ;

ascii_out ;

Full example

You can find more examples in the documentation/scripting/ library of the project.

#  documentation/scripting/multi_wirl.pl

use strict; use warnings;

use App::Asciio::Scripting ;

#-----------------------------------------------------------------------------

add 'text1', new_text(TEXT_ONLY =>'text'),  22,  20 ;

add 'box1', new_box(TEXT_ONLY =>'box1'),  0,  2 ;
add 'box2', new_box(TEXT_ONLY =>'box2'), 20, 10 ;
add 'box3', new_box(TEXT_ONLY =>'box3'), 40,  5 ;

connect_elements 'box1', 'box2', 'down' ;
connect_elements 'box2', 'box3' ;
connect_elements 'box3', 'box1', 'up' ;
connect_elements 'box2', 'text1' ;

my $process = add_type 'process', 'Asciio/Boxes/process', 5, 15 ;
$process->set_text("line 1\nline 2\nline 3") ;

optimize ;

save_to "from_script.asciio" ;

ascii_out ;