Sasume (./89) :
(sauf qu'ensuite, comme ton tableau est un tableau de char j'imagine, tu vas devoir caster key en char)
Et c'est justement sur ça que je m'interroge

Sasume (./89) :
(sauf qu'ensuite, comme ton tableau est un tableau de char j'imagine, tu vas devoir caster key en char)
Thibaut (./96) :
Ouaip, mais ça produit des caractères horribles et non désirés sur l'écran. Il faut peut-être préférer un test à un simple transtypage. Si le code renvoyé dépasse 255, on ajoute rien à la chaîne.
#include <tigcclib.h> #define RETURN_VALUE void _main(void) { while (GetArgType (top_estack) != END_TAG) { top_estack = next_expression_index (top_estack); top_estack--; } int i = 0; if(speek(0x32)==80 && speek(0x33)==79) { i++; } push_shortint(i); }
FireHunter (./98) :
J'ai cru bien comprendre cette page, mais j'ai dû me gourer vu que ça renvoie rien du tout ^^. Je commence en C sur Ti, j'suis un peu largué :x
Now about problems. Everything works fine in AMS 1.xx, but AMS 2.xx forbids the use of ASM programs in expressions. So, in the above example, 'add(2,3)' will work perfectly, but '5+add(2,3)' or even 'add(2,3)->a' will not. This stupidity makes returning values mostly useless. What to do? Unfortunately, I can't do nothing from the TIGCC itself, because an ASM program will not be executed at all if AMS 2.xx detects its presence in an expression. However, there is a solution: it is possible to make a resident program which will intercept such "stupid" behaviour of AMS 2.xx and to allow executing ASM programs in expressions. Such interception is already implemented in the latest versions of DoorsOS, Universal OS, PreOS and KerNO (but not in TeOS). So, if you have installed a fresh release of DoorsOS, Universal OS, PreOS or KerNO, everything will work OK even on AMS 2.xx. There is also a TSR called IPR which intercepts only this error and the "ASAP or Exec string too long" error available at Cyril Pascal's (Paxal's) web page for those who don't want to install a full-featured kernel. But for HW2 calculators, the HW2 AMS 2 TSR support (h220xTSR) needs to be installed before IPR. This does not mean that your program must be compiled in "Doors" mode: it may be a "nostub" program, but DoorsOS, Universal OS, PreOs, KerNO or IPR must be present on the calculator (to intercept stupid behavior of AMS 2.xx). To conclude: if you have AMS 2.xx and if you want to use "returning a value" feature, you must have installed DoorsOS, Universal OS, PreOs, KerNO or IPR. If you are a programmer, please note this fact in the documentation of any program which uses this feature!
Now about problems. Everything works fine in AMS 1.xx, but AMS 2.xx forbids the use of ASM programs in expressions. So, in the above example, 'add(2,3)' will work perfectly, but '5+add(2,3)' or even 'add(2,3)->a' will not. This stupidity makes returning values mostly useless. What to do? Unfortunately, I can't do nothing from the TIGCC itself, because an ASM program will not be executed at all if AMS 2.xx detects its presence in an expression. However, there is a solution: it is possible to make a resident program which will intercept such "stupid" behaviour of AMS 2.xx and to allow executing ASM programs in expressions. Such interception is already implemented in the latest versions of DoorsOS, Universal OS, PreOS and KerNO (but not in TeOS). So, if you have installed a fresh release of DoorsOS, Universal OS, PreOS or KerNO, everything will work OK even on AMS 2.xx. There is also a TSR called IPR which intercepts only this error and the "ASAP or Exec string too long" error available at Cyril Pascal's (Paxal's) web page for those who don't want to install a full-featured kernel. But for HW2 calculators, the HW2 AMS 2 TSR support (h220xTSR) needs to be installed before IPR. This does not mean that your program must be compiled in "Doors" mode: it may be a "nostub" program, but DoorsOS, Universal OS, PreOs, KerNO or IPR must be present on the calculator (to intercept stupid behavior of AMS 2.xx). To conclude: if you have AMS 2.xx and if you want to use "returning a value" feature, you must have installed DoorsOS, Universal OS, PreOs, KerNO or IPR. If you are a programmer, please note this fact in the documentation of any program which uses this feature!
Folco (./105) :
SymFindPtr( SYMSTR (preos))
Enfait, la vat, ça va vraiment pas chercher loin une fois qu'on a fait quelques manipulations.
Kevin Kofler (./106) :
Tu utilises RETURN_VALUE avec un nom de variable. Tu ne peux pas utiliser le RETURN_VALUE style fonction TI-BASIC dans une chaîne Exec (parce qu'Exec est une instruction, pas une fonction).
FireHunter (./109) :
J'ai tenté, mais ça retourne rien quand même, aucune variable n'est créée :'(
Je reregarderais en maths aussi
Kevin Kofler (./111) :FireHunter (./109) :
J'ai tenté, mais ça retourne rien quand même, aucune variable n'est créée :'(
Peut-être que GTC ne gère pas cette fonctionnalité.Je reregarderais en maths aussi
Tu ferais mieux d'écouter en cours de Mathématiques, c'est une matière importante!
FireHunter (./113) :
D'ailleurs, je sors de mon DS de maths, et je sens bien le 15/20 \o/
Thibaut (./114) :
Il doit y avoir une erreur dans ton code FireHunter
Thibaut (./118) :
Je ne vois pas de retour de variable dans son code,
ni de chaîne exec.
Je vois pas contre une double decrementation du pointeur de pile, qui pose à coup sur problème
while (GetArgType (top_estack) != END_TAG) { // On saute l'argument courant jusqu'à tomber sur l'END_TAG. top_estack = next_expression_index (top_estack); } // APRÈS la boucle (!), on saute le END_TAG. (Il n'y en a qu'un!) top_estack--;