THE PROTOCOL ASTP

 

1. INTRODUCTION 

ASTP (AudeLA Scripting Transfer Protocol) is a protocol of communication that permits execution through the AudeLA system of Tcl scripts from any program (this one can be written in C, in Basic, in Java, etc.). 

This documentation applies therefore to the programmers. The ASTP protocol is simple to understand and to implement, also, even though you are not practiced in programming, you should not have much difficulty to benefit from advantages of AudeLA in your own realizations. For example, a practical idea  is to conceive the user-interface then in Visual Basic, an extremely intuitive and effective programming environment, to use AudeLA for everything that concerns the functions of calculation, the piloting of cameras, the management of an observatory, the Ethernet communication, etc. 

ASTP adds a considerable power to your processing and acquisition programs. Indeed, you cannot only throw some Tcl scripts (one of the available most powerful script languages today), but you benefit in addition to the numerous written function scripts to come from the AudeLA system (LIBTT, LIBMC, LIBQM,..). The diversity of these scripts permits to construct by you even an almost infinite number of macro-functions. You dream of a function that doesn't exist in any software: you have all the basis blocks to construct it very simply (a word processor such as WordPad is sufficient!). And if you lack a basis block, the AudeLA system is sufficiently open so that you can add this block there while using your preferred low-level language: C, C++, Pascal, etc. (for an introduction to the construction of an Audela library  click here). 
 

AudeLA, Tcl and ASTP permits to write the applications that exchange themselves very well between users, including on different exploitation systems (Windows, Linux, Unix, Mac, etc.). This easiness of exchange are not the least of the advantages of the system: that guarantee a continuous development, strong evolution and the constitution of a help network if you are in difficulty.

Let's underline that it is otherwise possible to exploit the power of AudeLA without writing the least line of code while using the dedicated programs, for example Aud'Ace (Aud'Ace is writed entirely in Tcl/Tk, see 

To be concrete we are going to describe in these pages how the ASTP protocol is implanted in the image processing software  IRIS.
 

2. THE PROTOCOL ASTP

The protocol between the client software (your software) and AudeLA is based on the exchange of files on the hard disk. The efficiency of the method in terms of communication speed is not exceptional, but against the technique is easy to implement, it is very portable and reliable. We should note that the relative slowness of the protocol (in the present version 1) is not a true handicap if one considers that ASTP permits to execute the powerful scripts that have a large autonomy in relation to the program calling. For example, you can start a script that pilots the telescope and the camera in unison in order to achieve a mosaic of a part of the sky, an operation that can take several score of minutes, that is to say that a lot longer length than the time of communication between the user and Audela. 

Here is the progress stage by stage of the execution of a script from the client software: 
 

2.1. Stage 1

The user of the software decides to run  a script since a command line, a menu, a dialog box... To this stage it is necessary that the user provided the name of the script file as well as the entry parameters of this script. Let's suppose for example that the wished operation either to add a constant to all pixels of a sequence of pictures. The script that achieves it has for name offset2.tcl. The script is programmed in such a way that it waits for three parameters. In the order: (1) the generic name of the pictures, (2) the constant to add to the pixels (a substraction if the constant is negative), (3) the number of pictures in the sequence. So for example one wishes to treat the I1, I2, I3  pictures, as there adding the constant 500, the 3 parameters will be respectively: 

I   500   3

When one uses IRIS a script is run from a command given on the console. The key word of the command is TCL. The syntax is: 

TCL  SCRIPT  ARG1  ARG2  ARG3  ARG4.... 

SCRIPT is the name of the Tcl file  (on the disk this file to still the .tcl extension but it is not necessary to specify this extension in command line) 

ARG1, ARG2,... are the arguments (or input parameters) of the function contained in the script file. IRIS (version 3) accepts until 12 parameters.

Thus, while taking our example of the calculation of the offset of a pictures sequence, the user will enter the following order: 

TCL  OFFSET2  I  500  3 
 

2.2. Stage 2

As soon as the user validated the order, the client software writes on the disk a file that is merely a small Tcl script. This file contains the functions that permit to synchronize the user with the Audela system, as well as the name of the script that one wishes to execute (the name of his file disk ) and the list of the parameters. This script that writes by the user is always called exchange.tcl in the ASTP protocol.
 

2.3. Stage 3

The client software executed under the shape of a shell programs it audela.exe. In other words, your program does an operation that consists in throwing a new program, here audela.exe. So audela.exe is executed as is, he throws the script Tcl audela.tcl automatically (this script it always finds in the same index that audela.exe, in general the index binwin if you installed in the Audelas rules). But here, the client software makes so that audela.exe throws the exchange.tcl script. So that so be it audela.exe can be thrown with a particular flag, the - File flag. In the case present audela.exe will be thrown of the following manner:

AUDELA   - FILE  EXCHANGE.TCL

2.4. Stage 4

Now, audela.exe took the hand. He/it throws the exchange.tcl script that executes itself then. Of the the beginning of exchange.tcl this one uses the service of the procedures that is in the astp.tcl script. This script is part of the protocol and must always be copied in the index of the hard disk that contains your own library of scripts. 

The role of exchange.tcl is essentially to recover the parameters entered then by the user to throw the script that is going to use them.

2.5. Stage 5

The user's script executes itself then. He/it can use the set of the libraries written for Audela. In our example it is the offset2.tcl script that executes itself to this stage. 

2.6. Stage 6

To the term of the execution of the user's script the hand is given back to exchange.tcl. This one writes then on the hard disk two files: 

(1) a result.txt file that possesses two lines of text. The first contains either the NOERROR text, either the ERROR text according to whether script of the user doesn't have or produced a mistake. The second line contains a text that can be exploited by the client software. In the case of IRIS this line is displayed in the console to the fence of the execution of the TCL order. 

(2) a signal.txt file that means to the user that the execution of the exchange.tcl script is finished. The existence of the signal.txt file (a file empties in fact) is supervised permanently by the client software in order to identify the end of execution of the script and so to be able to pass to something else. There is several ways to manage this waiting, for either example while using a simple infinite buckle that will stop at the time of the apparition of the signal.txt file, either while managing a mechanism of thread or timer that gives to the user the feeling to work with a multitask system (however it is necessary to underline that in the present version of ASTP it is delicate to exploit the multitask dimension of Audela, but this point is to the survey). 

2.7. Stage 7

The control comes back to the user. This one possibly displays the content of the file result.txt /or produces an error screen provoked at the time of the progress of the script. 

To note a particularity of ASTP: the exchange.tcl file exploits the picture situated in the users random-access memory (tampon picture principal) under the shape of a file picture disk having for #0.fit name. This file, in the FITS format, is a copy of the current picture in memory. It is exploited by exchange.tcl in order to reflect the operations of treatment pictures done in the user's script and that would apply normally to the picture in memory if a requirement of an internal function to the user. When the user takes the control, the #0.fit file can be reread, stocked in the tampon picture principal and displayed on the screen (it is that that makes IRIS). 

3. THE SCRIPT EXCHANGE.TCL

The listing shows the content typical of the exchange.tcl script below. This example treats the case of the use of the offset2.tcl script. 

#--- functions of initialization--- 
c:/script/astp.tcl source 
astp_create {: :buf::create "} 

#--- functions of Client transfer -> Tcl--- 
astp_buf_load {" 1 c:/iris/#0 "} 
astp_param_in {c:/iris / c:/audela3/binwin / i 500 3}

#--- function of execution--- 
astp_source {c:/script/offset2.tcl}

#--- functions of Tcl transfer -> User--- 
astp_result {c:/script/result.txt} 
astp_buf_save {" 1 c:/iris/#0 "}

#--- function of termination--- 
astp_delete {c:/script/signal.txt} 
exit

Here are the operations that exchange.tcl achieves.

First of all exchange.tcl loads the astp.tcl file, that contains the utilitarian procedures that manage the ASTP protocol. The path that permits to localize the astp.tcl file (in this example c:/script /) is defined by the user of your program (in IRIS, it this fact in the category Script path of it limps of Settings dialogue, to see farther). It is possible to put the scripts where good seems you, but it is important that your index of script contains the astp.tcl script. The installation of Audela placed a copy of this one in the subdirectory astp of the index of installation of Audela. For example, if the path of installation of Audela is c:\audela \, then a copy of astp is located in the index c:\audela\astp \.

A buffer picture is created then and the procedure astp_buf_load loads the file picture #0 in this buffer. The localization of the #0.fit file is defined in IRIS by the index of work (category Working path in it limps of Settings dialogue). In the example, the index of work is c:\iris \.

The procedure astp_param_in decodes the parameters given out by the client program. We have here 5 parameters. The two first are obligatory. The first is the path of the work index, the second is the path permitting to arrive to the audela.exe program and the Audelas bookstores (here c:\audela3\binwin \). To note that in these explanations we don't make a distinction between the character slash (/) and the anti - slash character (\), that are functionally equivalent. However the Tcl language only tolerates the slash (compatibility with the world UNIX), from where the manner to write the paths in exchange.tcl.

The procedure astp_source executes offset2.tcl script then (note that it is located in the index c:/script /).

Once the progress of the offset2.tcl script finished, exchange.tcl writes the file result (result.txt) on the disk and protects the content of the buffer picture in the #0.fit file.

Finally, the signal.txt file is created to indicate to the client program that the set of the procedure is finished (this file is located in the index containing the scripts. The order Tcl exit closes the Tcl session.

The copy of screen below watch the labels of Settings dialogue of corresponding IRIS to the parameters of our example. 






4. ASTP AND IRIS

We have since the call of a Tcl script in the software IRIS (from the version 3) this fact since the line orders whose syntax is: 

TCL  SCRIPT  ARG1  ARG2  ARG3.... 

SCRIPT is the name of a file of Tcl script

ARG1, ARG2,... are the arguments (or parameters of entry) of the function contained in the file of script. 

IRIS is written in C with the environment of Visual programming C++ 6.0 of Microsoft. The implementation of the ASTP protocol holds in only one routine that has for name exe__tcl. The complete code of this routine is given below. This code will be described step-by-step in the continuation. 

/ * * * * * * * * * * * * * * * * * * * * * * * * * * EXE_TCL * * * * * * * * * * * * * * * * * * * * * * * * * * * /
/ * Executes a script Tcl                                       * / 
/ *   nb_arg = number of arguments in the line of     order * / 
/ *   arg [] = picture of the                            S arguments * / 
/ *   text = message in return of the execution of the         script * / 
/ *   pParent = a structure that contains the destination of    * / 
/ *             display of a                         picture * / 
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / 
int exe_tcl(int *arg nb_arg,char [] ,char *text,CWnd *pParent) 

HWND HWND; 
*DEST,*FP LINE; 
int k,r,len; 
chariot audela_path[_MAX_PATH]; 
chariot script_path[_MAX_PATH]; 
chariot audela_file[_MAX_PATH]; 
chariot signal_file[_MAX_PATH]; 
chariot result_file[_MAX_PATH]; 
chariot exchange_file[_MAX_PATH]; 
chariot image_path[_MAX_PATH]; 
chariot binwin_path[_MAX_PATH]; 
chariot buf[_MAX_PATH]; 
chariot cmdline[128]; 
chariot param[256];

strcpy(audela_path,ini.audela_path);   / / path of the index audela 
strcpy(script_path,ini.script_path);   / / path of the index of the scripts 
sprintf(audela_file, " %sbinwin\\audela.exe",audela_path); / / complete path of audela.exe 
sprintf(exchange_file, " %sexchange.tcl",script_path); / / complete path of the exchange file 
sprintf(cmdline, " - File %s",exchange_file);   / / line of order of audela.exe 

/ / change the anti - slash in slash 
len=(int)strlen(audela_path); 
heart (k=0;k &ltlen;k++) 
    { 
   if (audela_path[k] == ' \ \ ') audela_path[k] = ' / '; 
   }

strcpy(image_path,ini.path); 
len=(int)strlen(ini.path); 
heart (k=0;k &ltlen;k++) 
    { 
   if (image_path[k] == ' \ \ ') image_path[k] = ' / '; 
   }

len=(int)strlen(script_path); 
heart (k=0;k &ltlen;k++) 
    { 
   if (script_path[k] == ' \ \ ') script_path[k] = ' / '; 
   }

sprintf(binwin_path, " %sbinwin / " ,audela_path);     / / path of the index binwin 
sprintf(signal_file, " %ssignal.txt",script_path);    / / complete path of the signal.txt file 
sprintf(result_file, " %sresult.txt",script_path);    / / complete path of the result.txt file 

/ / synthesis of the line of argument of the order 
strcpy(param,image_path);   / / the first parameter is always the path of the work index 
strcat(param,"); 
strcat(param,binwin_path); / / the second parameter is always the path of the index of the libraries 
strcat(param,"); 
heart (k=1;k &ltnb_arg;k++) 
    { 
   strcat(param,arg[k]); 
   strcat(param,"); 
   }

/ / created a new picture in memory if him there some to not already one 
yew (buffer[0] .pic==NULL) newimage(10,10);

/ / safeguard of the buffer memory 
yew (save_picture (" #0",0,0)==PB) return(PB); 

/ / writing of the exchange.tcl file 
yew ((dest=fopen(exchange_file, wb ")) ==NULL) 
    { 
   msg(get_msg(84)); 
   return(PB); 
   }

write_file (#--- functions of intialisation--- " ,dest); 
sprintf(buf, %sastp.tcl",script_path " source); 
write_file(buf,dest); 
write_file (" astp_create {\: :buf::create \} " ,dest); 
write_file (" ,dest);

write_file (#--- functions of Client transfer -> Tcl--- " ,dest); 
sprintf(buf, " astp_buf_load {\ " 1 %s#0 \} " ,image_path); 
write_file(buf,dest); 
sprintf(buf, " astp_param_in {%s} " ,param); 
write_file(buf,dest); 
write_file (" ,dest);

write_file (#--- function of execution--- " ,dest); 
sprintf(buf, " astp_source {%s%s.tcl} " ,script_path,arg[0]); 
write_file(buf,dest); 
write_file (" ,dest);

write_file (#--- functions of Tcl transfer -> User--- " ,dest); 
sprintf(buf, " astp_result {%s} " ,result_file); 
write_file(buf,dest); 
sprintf(buf, " astp_buf_save {\ " 1 %s#0 \} " ,image_path); 
write_file(buf,dest); 
write_file (" ,dest);

write_file (#--- function of termination--- " ,dest); 
sprintf(buf, " astp_delete {%s} " ,signal_file); 
write_file(buf,dest); 
write_file (" exit",dest);

fflush(dest); 
fclose(dest);

remove(signal_file);

hwnd=GetDesktopWindow (); 
r=(int)ShellExecute(hwnd, " open",audela_file,cmdline,NULL,SW_SHOWNORMAL); 
yew (r <=32) 
    { 
   msg(get_msg(93)); 
   return(PB); 
   }

do {} while(access(signal_file,1)==-1);

/ / loads the file picture of exchange in memory 
yew (load_picture (" #0",0,0,0)==PB) return(PB); 

/ / displays the picture 
view(pParent);

/ / reads the file result 
yew ((fp=fopen(result_file, rt ")) ==NULL) 
    { 
   msg(get_msg(52)); 
   return(PB); 
   }

/ / flag of mistake 
fgets(text,127,fp); 
len=strlen(text); 
yew (len&gt0) text[len-1] = ' \0 '; 
yew (strcmp(text, error ") ==0) 
    { 
    / / here, possible treatment of a mistake in the progress of the script 
   }

/ / reading of the line of parameters in return of the script 
fgets(text,127,fp); 
len=strlen(text); 
yew (len&gt0) text[len-1] = ' \0 ';

fclose(fp); 
return(OK); 
}

The first left from the code starts by declarations of variables. 

/ * * * * * * * * * * * * * * * * * * * * * * * * * * EXE_TCL * * * * * * * * * * * * * * * * * * * * * * * * * * * / 
/ * Executes a script Tcl                                       * / 
/ *   nb_arg = number of arguments in the line of     order * / 
/ *   arg [] = picture of the                            S arguments * / 
/ *   text = message in return of the execution of the         script * / 
/ *   pParent = a structure that contains the destination of    * / 
/ *            display of a                         picture * / 
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / 
int exe_tcl(int *arg nb_arg,char [] ,char *text,CWnd *pParent) 

HWND HWND; 
*DEST,*FP LINE; 
int k,r,len; 
chariot audela_path[_MAX_PATH]; 
chariot script_path[_MAX_PATH]; 
chariot audela_file[_MAX_PATH]; 
chariot signal_file[_MAX_PATH]; 
chariot result_file[_MAX_PATH]; 
chariot exchange_file[_MAX_PATH]; 
chariot image_path[_MAX_PATH]; 
chariot binwin_path[_MAX_PATH]; 
chariot buf[_MAX_PATH]; 
chariot cmdline[128]; 
chariot param[256];

 It is necessary to note the arguments of the function C exe_tcl:

  • nb_arg = number of parameters entered by the user following the TCL order. In the case of the example of the offset2.tcl script numbers it of argument is 4. 
  • arg [] = picture containing the arguments. In the case of the offset2.tcl script one will have arg[0]=offset2, arg[1]=I, arg[2]=500 and arg[3]=3 for example. Notice that arg[0] contains the name of the script always. 
  • text = a drawer who contains the line in return of the Tcl script that will be displayed on the screen (the console of IRIS). 
  • pParent = a drawer toward a structure clean to Windows that fix the context of display of the pictures. 

The following part of the code calculates the necessary index path to the working of the ASTP protocol. The variable ini.audela_path is internal to IRIS. She/it contains the path that brings to the audela.exe program. His/her/its content reflects the zone of dialogue precisely Audela script of it limps Settings of IRIS (applicable since the menu Spins this program). The variable internal ini.script_path designates the index in which is situated your library of script (this variable reflects the content of the text zone Script path of it limps of Settings dialogue). Finally the variable ini.path contains the path of the work index (zone of text Working path in it limps Settings).

strcpy(audela_path,ini.audela_path);   / / path of the index audela 
strcpy(script_path,ini.script_path);   / / path of the index of the scripts 
sprintf(audela_file, " %sbinwin\\audela.exe",audela_path); / / complete path of audela.exe 
sprintf(exchange_file, " %sexchange.tcl",script_path); / / complete path of the exchange file 
sprintf(cmdline, " - File %s",exchange_file);   / / line of order of audela.exe 

/ / change the anti - slash in slash 
len=(int)strlen(audela_path); 
heart (k=0;k &ltlen;k++) 
    { 
   if (audela_path[k] == ' \ \ ') audela_path[k] = ' / '; 
   }

strcpy(image_path,ini.path); 
len=(int)strlen(ini.path); 
heart (k=0;k &ltlen;k++) 
    { 
   if (image_path[k] == ' \ \ ') image_path[k] = ' / '; 
   }

len=(int)strlen(script_path); 
heart (k=0;k &ltlen;k++) 
    { 
   if (script_path[k] == ' \ \ ') script_path[k] = ' / '; 
   }

sprintf(binwin_path, " %sbinwin / " ,audela_path);     / / path of the index binwin 
sprintf(signal_file, " %ssignal.txt",script_path);    / / complete path of the signal.txt file 
sprintf(result_file, " %sresult.txt",script_path);    / / complete path of the result.txt file 

One notices that in this code the anti - slash of the paths is replaced often by slash, a necessary operation when the path is used to the very breast of the script (compatibility with the world UNIX). 

Comes then the generation of the line of argument of the function named Tcl. The first two argument of this line is always respectively the path designating the index of work (it is the index containing the pictures to treat) and the path of the index that contains the audela.exe program (as well as the scripts of extensions as libtt.dll or libqm.dll). One finds the arguments then actual of the script. In the example of the offset2.tcl script, this line of order would contain something as " c:/image / c:/audela/binwin / I 200 5 ". Note that the parameters must be separated by at least a space. 

/ / synthesis of the line of argument of the order 
strcpy(param,image_path);   / / the first parameter is always the path of the work index 
strcat(param,"); 
strcat(param,binwin_path);  / / the second parameter is always the path of the index of the libraries 
strcat(param,"); 
heart (k=1;k &ltnb_arg;k++) 
    { 
   strcat(param,arg[k]); 
   strcat(param,"); 
   }

In IRIS, if a picture is already in memory (it is displayed then also to the screen) it is protected on the disk under the #0.fit name (attention, you must have selected the FITS format in it tabs of Settings dialogue). If there are not any pictures in memory whereas you wish to execute a script, the operation is possible, but IRIS only created for you a minuscule picture containing that of the zeros with help the function interns IRIS newimage (arbitrarily this picture has a size of 10x10 pixels). The function save_picture, intern to IRIS, do the actual safeguard of the picture in memory in a FITS file.

/ / created a new picture in memory if him there some to not already one 
yew (buffer[0] .pic==NULL) newimage(10,10);

/ / safeguard of the buffer memory 
yew (save_picture (" #0",0,0)==PB) return(PB);

Comes then the writing lign offs after line of the file of exchange Tcl exchange.tcl (the function write_file is internal to IRIS and do the actual writing of a line in a file text). The function msg is internal to IRIS and return an adequate mistake message if a problem presents itself. 

/ / writing of the exchange.tcl file 
yew ((dest=fopen(exchange_file, wb ")) ==NULL) 
    { 
   msg(get_msg(84)); 
   return(PB); 
   }

write_file (#--- functions of intialisation--- " ,dest); 
sprintf(buf, %sastp.tcl",script_path " source); 
write_file(buf,dest); 
write_file (" astp_create {\: :buf::create \} " ,dest); 
write_file (" ,dest); 
.... 
.... 

Before starting the audela.exe program one erases the signal.txt file:

remove(signal_file);

The audela.exe program is executed then while using the ShellExecute function of the Windows API. The variable cmdline contains the argument of audela.exe.

hwnd=GetDesktopWindow (); 
r=(int)ShellExecute(hwnd, " open",audela_file,cmdline,NULL,SW_SHOWNORMAL); 
yew (r <=32) 
    { 
   msg(get_msg(93)); 
   return(PB); 
   }

IRIS then in waiting gets the writing of the signal.txt file by the exchange.tcl script. This buckle infinity is very poor because it blocks the working of IRIS so much that the progress of the script is not finished. It is  possible to make a better environment for Windows, but as is, the process functions. 

do {} while(access(signal_file,1)==-1);

Once the script finished its work, one loads in memory the content of the #0.fit file (function load_picture of IRIS), then one displays this picture (function view). 

/ / loads the file picture of exchange in memory 
yew (load_picture (" #0",0,0,0)==PB) return(PB); 

/ / displays the picture 
view(pParent);

The routine exe_tcl ends by the reading of the two lines that is in the result.txt file. A possible mistake at the time of the progress of the script is treated to this level. The second line is a text that is displayed on the console of IRIS (this text is possibly a message of mistake automatically generated by Tcl, what facilitates the rest the writing of the scripts considerably). 

5. EXAMPLES OF SCRIPTS

Here are some elementary scripts that can be called in the context of the ASTP protocol. 

5.1. Calculation of the Julian day

This small script returns in the console of IRIS the Julian day for one date entered by the user. This script uses the function qm_jd that is implemented in the LIBQM script.

#jd 
#------------ 

#Returns the Julian day of one date 
#Syntax: jd year month day 
#year = year of the date 
#month   = month of the date 
#day   = day of the date (can be a real) 
#

#--- conversion of the ASTPS parameters in clear language 
set $astp(p,1 working_path) 
set $astp(p,2 library_path) 
set year $astp(p,3) 
set month $astp(p,4) 
set day $astp(p,5)

#--- possible bookstore loading 
wrestling { 
load ${library_path}libqm 
}

#--- body of the script 
set has [qm_jd $annee $mois $jour]

#--- value back 
set result " Julian Day: $a "

The script starts while placing the parameters of entry in variables to the explicit names. The parameters are stocked automatically in a picture having for name astp (). Notice that the first two parameters contain the paths of the work index and the path of the index containing the script. 

The LIBQM.DLL script is charged then in memory. 

The function actual qm_jd is thrown then. The result returned in the variable has. The last line synthesizes a clear message that is sent to the user through the result.txt file. It is the content of this line that is displayed in the console. 

To use this tag copy the command in an index file of your choice (c:\script \ for example) also think about additionally adding to the astp.tcl file also. In  the made for example console (the first parameter of jd.tcl is the year, the second the month and finally the day): 

TCL JD 2000 10 13.566

The picture shows the console of IRIS below in this situation: 

5.2. Addition of a constant to a sequence of pictures 

Here is the content of the offset2.tcl script that already acted us as example. Here one uses an elementary function of the LIBQM script again: the function qm_offset that adds a constant to a picture situated in the definite buffer 0 by the Audela system.

#offset2 
#------- 
#Adds a constant to a sequence of pictures 
#Syntax: offset2 picture cst nb 
#picture = generic name of the pictures to treat 
#   cst = constant to add to every picture 
#    nb = number of pictures to treat 
#

#--- conversion of the ASTPS parameters in clear language 
set $astp(p,1 working_path) 
set $astp(p,2 library_path) 
set $astp(p,3 name) 
set offset $astp(p,4) 
set $astp(p,5 nbimages)

#--- loading of the bookstores 
wrestling { 
load ${library_path}libqm 
}

#--- body of the script 
heart {set k 1} {$k <= $nbimages} {k incr} { 
   loadima $working_path$name$k 
   qm_offset $offset 
   saveima $working_path$name$k 
   }

#--- parameter of exit 
set result " ok "

This script is very similar to jd.tcl.  One notes here in more that the management of the sequence of pictures is done by a clamp written in Tcl. It lets glimpse the manner of which it is possible to conceive complex scripts while using a simple word processor and a minimum of knowledge of the Tcl language. 

5.3. Addition of a constant to the picture in memory 

The following script is simple because it does the treatment on the picture in memory of the client software (while using the file #0.fit intermediate). 

#offset 
#---------------- 

#Adds a constant to the current picture 
#syntax: offset cst 
#cst = constant to add to the picture 
#

#--- conversion of the ASTPS parameters in clear language 
set $astp(p,1 working_path) 
set $astp(p,2 library_path) 
set $astp(p,3 cst)

#--- possible bookstore loading 
wrestling { 
load ${library_path}libqm 
}

#--- conversion of the ASTPS parameters in clear language 
$cst qm_offset

#--- value back 
set result " ok "

One can note that it is possible to use a function of calculation different of the one that is in LIBQM. For example, if you want to exploit the equivalent function in LIBTT, the script will be then: 

#offset 
#---------------- 

#Adds a constant to the current picture 
#syntax: offset cst 
#cst = constant to add to the picture 
#

#--- conversion of the ASTPS parameters in clear language 
set $astp(p,1 working_path) 
set $astp(p,2 library_path) 
set $astp(p,3 cst)

#--- conversion of the ASTPS parameters in clear language 
offset $cst

#--- value back 
set result " ok "

The offset procedure is defined in astp.tcl from the functions of basis of LIBTT. 

Seen since the interface of IRIS, this script executes itself of the following manner: 

6. DOWNLOADING

To download astp.tcl and the scripts of examples, click here. 

Click here for going to LIBQM page