[RPL/2] library in interactive mode
BERTRAND Joël
joel.bertrand at systella.fr
Mar 28 Sep 20:18:59 CEST 2004
Olivier Garet a écrit :
> Hello
Hello Olivier,
> Thanks to Joel for writing this beautiful tool.
You're welcome.
> I wish to use rpl as a programming calculator, but I do not understand
> if it is possible to record some functions on files and use them in
> interactive mode. Is it possible ?
You can use two types of functions :
1/ half-compiled functions written in RPL/2, but you have to execute a
script :
#!/usr/local/bin/rpl -c
MAIN
<< "ma fonction" disp ... >>
#include "ma_bibliothèque_traitement_signal.rpl"
#include "calcul_matriciel.rpl"
Warning : don't forget that the first function will be the main program.
Thus, you have to put all #include intrinsics _after_ your main program.
2/ compiled functions by mkrplso in a shared object (.rplso) like :
#include <rplargs.h>
void
essai(struct_rpl_arguments *rpl_arguments)
{
struct_objet *s_objet;
printf("Ceci est une routine de test pour tester "
"un appel de bibliothèque\n");
(*rpl_arguments).l_base_pile_last =
sauvegarde_arguments(rpl_arguments, 2);
s_objet = malloc(sizeof(struct_objet));
strcpy((*s_objet).type, "INT");
(*s_objet).objet = malloc(sizeof(integer8));
(*((integer8 *) (*s_objet).objet)) = 1;
(*rpl_arguments).l_base_pile =
empilement_pile_operationnelle(rpl_arguments, s_objet);
/*
(*rpl_arguments).erreur = 1;
(*rpl_arguments).type_erreur = 'E';
(*rpl_arguments).message_erreur =
"Ceci n'est pas une erreur (Magritte) !\n";
*/
return;
}
and you can use this function with USE/REMOVE/EXTERNAL intrinsics.
At this time, there is not issue to use the interactif mode with
external functions written in RPL/2. In fact, when you start RPL/2 in
interactive mode, you launch a regular program (a loop like << do halt
until false end >>) in debug mode. But, if you try to write :
#!/usr/local/bin -c
PP
<< do halt until false end >>
add1
<< 1 + >>
and to execute, you will obtain a prompt, and it will be possible to
execute add1, but step by step (or with CONT intrinsic).
> Moreover, I found a difference between the behavior of "rpl -i" and
> the behavior of a HP28S calculator: variables which contain programs
> are not spontaneously evalued.
I know. There are some little differences between a regular HP-28S and
my RPL/2. Maybe you have seen that DISP doesn't take any line number...
The main difference is the distinction made between variables and
programs. A program is a function written in a text file. A variable is
an internal object and can contain a program (a RPN expression). A long
time ago, I have authorized the evaluation of all programs stored in a
variable it was impossible to put any RPN expressions in the stack.
> Example:
> << 1 + >> 'addi' sto 1 addi
>
> on an HP28S, you get 1: 2 .
On a calculator, there is no difference between interactive and script
mode. In RPL/2, you should write
PP
<< 1 addi clmf >>
addi
<< 1 + >>
> whereas with rpl -i, you get
> 2: 1
> 1: << 1 + >>
>
> Yep, with << 1 + >> 'addi' sto 1 addi eval , you get 2 also.
I have to upgrade the documentation, but I don't have time enough...
Any volunteer ? ;-)
Regards,
JKB
Plus d'informations sur la liste de diffusion RPL2