A Guide to Programming Janita

Version 2.4.0.5

Reviewed 12 March 2023

This document is a work-in-progress. We would like to hear from users and programmers who have ideas and suggestions. Please contact us at: www.april.se.

Contents

Application and Applet Programming Tips

The following information applies both when running Janita as an applet in a web browser and as an application.

ACL AniTa Command Language

ACL overview

ACL is a Command Language. It is a subset of and syntax compatible with the RCL Language implemented in some other products on the market.

ACL command string syntax:
ESC [ 2 4 y < c o m m a n d > CR

Example:

 In a UNIX script this might look like...

 echo "\033[24yFILESIZE c:/temp/somefile.txt\015"

AniTa for the Web implements the following commands:

 SET DISABLE-COMP-CODES YES|NO  Disable completion codes
 If completion codes are turned on, then "S<cr>" will be sent to the host after a succesful command, and "F<cr>" if it failed.
 FILESIZE <filespec>  Returns the size of the file in bytes followed by "<cr>"
   or -1<cr> if the file/directory does not exist,
   or -2<cr> if it is a directory
 DIR <filespec>  Returns the file names each followed by <cr> plus one extra <cr> at the end.
 ERASE <filespec>  Deletes file on client computer
  Returns F<CR> if failure, S<CR> if success
 CHDIR <path>  Change working directory
  Returns F<CR> if failure, S<CR> if success
 CD <path>  Same as CHDIR
  Returns F<CR> if failure, S<CR> if success
 COPY <srcfile> <destfile>  Copy binary from srcfile to destfile
  Returns F<CR> if failure, S<CR> if success
 APPEND <srcfile> <destfile>  Append binary from srcfile to destfile
  Returns F<CR> if failure, S<CR> if success
 MKDIR <directory name>  Create directory
  Returns F<CR> if failure, S<CR> if success
 MKDIRS <directory name>  Create nested directories
  Returns F<CR> if failure, S<CR> if success
 RMDIR  Removes a directory
  Returns F<CR> if failure, S<CR> if success

Version and Platform Information

To determine the version or platform information use the following escape sequences. The returned values are followed by a return (CR) character in order to simplify reading them into a program or script.

ESC [ 2 3 y or ESC [ 2 3 ; 0 y

This returns the Java version followed by the word Java. It always returns 4 numbers, appending zeros as appropriate. This is defined as System.getProperty("java.version").
For example: 1.4.0.0 Java or 1.4.1_01 Java
Note that AniTa for Windows returns the Windows version followed by Win32. For example: 4.10 192.0 Win32

ESC [ 2 3 ; 1 y

This returns the AniTa version. It always returns 3 numbers.
For example: 1.2.0

ESC [ 2 3 ; 2 y

This returns the AniTa version. It always returns 4 numbers.
For example: 1.2.0.1

ESC [ 2 3 ; 1 0 y

This returns the operating system name. This is defined as System.getProperty("os.name").
For example: Windows 98 or Linux

ESC [ 2 3 ; 1 1 y

This returns the operating system version. This is defined as System.getProperty("os.version").
For example: 4.10 or 2.4.20-8

ESC [ 2 3 ; 1 2 y

This returns the operating system architecture. This is defined as System.getProperty("os.arch").
For example: x86 or i386

Starting a Program on the Client

ESC [ 1 y COMMAND LINE ESC \

This runs the program specified.
For example: ESC [ 1 y N O T E P A D SP C : \ C O N F I G . S Y S ESC \

An example of a UNIX shell command that envokes a WINDOWS program that lists the PC c:\config.sys file:
echo "\033[1yNOTEPAD C:\0134CONFIG.SYS\033\0134\c"

An example of a UNIX shell command that envokes the WINDOWS FTP program together with a command file that will be automatically run:
echo "\033[1yftp -s:c:\commands.cfg\033\0134\c"

If the emulator could be running on different platforms, it might be necessary to run the ESC [ 2 3 ; 1 0 y command first in order to return the operating system name, and thus determine the exact command line to send to AniTa.

Note: also supported by AniTa for Windows

Set the Cursor Blink Rate

ESC [ 3 3 ; RATE y

This sets the cursor blink rate in milliseconds. It can be set to a value between 1 and 1000. Setting a value outside of this range disables blinking.
For example: ESC [ 3 3 ; 7 5 0 y

Note: also supported by AniTa for Windows

Show a Message Dialog Box

ESC [ 4 3 ; MESSAGE TYPE y MESSAGE TEXT | TITLE ESC \

This shows a message box.

The following numbers can be used for MESSAGE TYPE, to determine the type of icon displayed:

The MESSAGE TEXT and TITLE are seperated by a vertical bar character.

The default MESSAGE TYPE is 2.

For example: ESC [ 4 3 ; 1 y T h e SP o u t p u t SP f i l e SP w a s SP w r i t e SP p r o t e c t e d ! | S a v e SP E r r o r . . . ESC \

Prompt for Input with a Keyin Dialog Box

ESC [ 4 4 ; MESSAGE TYPE y MESSAGE TEXT | TITLE | APPEND TO SEND | DEFAULT VALUE | SEND ON CANCEL ESC \

This shows a keyin dialog box and allows the user to enter data.

The default MESSAGE TYPE is 1.

For example: ESC [ 4 4 ; 5 y E n t e r SP d a t a b a s e SP s e r v e r SP n a m e | C o n n e c t | < C R > | 1 0 . 0 . 0 . 6 | < E S C > C ESC \

Prompt for Input with a Yes/No Dialog Box

ESC [ 4 5 ; MESSAGE TYPE y MESSAGE TEXT | TITLE | SEND ON YES | SEND ON NO | SEND ON CANCEL | YES BUTTON TEXT | NO BUTTON TEXT ESC \

This shows a Yes/No dialog box and returns the user's choice.

The default MESSAGE TYPE is 5.

For example: ESC [ 4 5 y S t a r t SP t h e SP m o n t h SP e n d SP p r o c e s s i n g | B a t c h SP J o b . . . | Y < C R > | N < C R > | X < C R > | J a | N e i n ESC \

The BUTTON TEXTs default to "Yes" and "No" for the currently configured language. So on a German system, the following would give the same result as above:
ESC [ 4 5 y S t a r t SP t h e SP m o n t h SP e n d SP p r o c e s s i n g | B a t c h SP J o b . . . | Y < C R > | N < C R > | X < C R > ESC \

Mouse Support

The mouse can be configured to send a string to the host when it is clicked or dragged.

Different strings can be configured for single or double clicks with the right, left or middle buttons. The middle button is the wheel on some models. If the configured string is empty, the mouse will not send anything to the host.

If the mouse should send a string to the host on a drag then that string must include the %colup% and/or the %rowup% macros. The top left position of the drag is the location inside of the marked area. The bottom right position of the drag is always the location outside of marked area. Thus RIGHT = LEFT + WIDTH and BOTTOM = TOP + HEIGHT.

The keyboard shift state is that when the drag is completed.

The following Mouse Macros are supported

%col%
The position (column) on which the mouse was clicked.
%colup%
The position (column) on which the mouse was released. For a click this is the same as %col%. If the mouse is dragged then it will be different.
%row%
The position (row) on which the mouse was clicked.
%rowup%
The position (row) on which the mouse was released. For a click this is the same as %row%. If the mouse is dragged then it will be different.
%shiftstate%
The keyboard shift-state for the mouse event. Values are 1 (shift), 2 (ctrl) and 4 (alt). These are accumulative, thus shift plus alt would give 5.

Note: also supported by AniTa for Windows

Turning off a selected area

If you have used the mouse click-drag-and-release together with %colup% and %rowup% then after the sequence has been sent to the host the screen area will still contain the select rectangle.

It is possible to use the %clearselect% macro to turn off the selected area.
For example: ESC [ 3 1 y % C L E A R S E L E C T % ESC \

Terminal Printer Escape codes

Application Programming Tips

The following information only applies when running Janita as an application.

Set the TitleBar text

ESC [ 22 y TEXT ESC \

The host can set the unique part of the titlebar text.
For example: ESC [ 22 y A c c o u n t s SP P a y a b l e ESC \

An example of a UNIX shell command that does this:
echo "\033[22yFixed Assets\033\0134\c"

Note: also supported by AniTa for Windows

Web Browser (Applet) Programming Tips

The following information only applies when running Janita as an applet in a web browser.

Show a Different Web Page

To redirect the web broswer to another page when running as an applet use the following escape sequences.

Note that if you need to do this when running as an application and not as an applet then you will need to start the web browser as a seperate program. See the section: Starting a Program on the Client. You might first need to determine the platform and version in order to decide the name and path of the browser. See the section. Version and Platform Information.

ESC [ 4 1 y WEB PAGE ADDRESS ESC \

This causes the web browser to go to a new web page address.
For example: ESC [ 4 1 y h t t p : / / w w w . a p r i l . s e ESC \

ESC [ 4 2 y TARGET ESC \

This specifies the target for all subsequent web page addresses. If not specified the target is "_blank".
For example: ESC [ 4 2 y m a i n ESC \ ESC [ 4 1 y h t t p : / / w w w . a p r i l . s e ESC \

Show a Different Web Page on Exit

It is possible to automatically redirect the web browser to another web page when the janita applet exits. This is done using the AppletExit configuration option.

See the user's guide for more details.