(Désolé, je peux lire un peu de français, mais je ne peux pas écrire Hourra pour Google Translate \o/)
Hi!
You can create functions, but it is... ugly. In newer versions of Grammer, it is easier, though.
Salut!
Vous pouvez créer des fonctions, mais c'est ... moche. Dans les nouvelles versions de Grammer, c'est plus facile, cependant.
You can also call a subroutine, and give parameters:
Vous pouvez également appeler un sous-programme et donner des paramètres:
- Code: Tout sélectionner
:prgm(<func>,<param1>,<param2>,...
However, your function needs to manually parse the parameters and store them to variables.
Cependant, votre fonction doit analyser manuellement les paramètres et les stocker dans des variables.
- Code: Tout sélectionner
:ParamA,B,C,...
In Grammer, all variables are "global" (like in TI-BASIC). However, you can define "local" variables for snippets of code:
Dans Grammer, toutes les variables sont "globales" (comme dans TI-BASIC). Cependant, vous pouvez définir des variables "locales" pour les extraits de code:
- Code: Tout sélectionner
:▶Nom(x,y,z
:<<do stuff>>
:End
Putting it all together:
Mettre tous ensemble:
- Code: Tout sélectionner
:.0:Return
:
://Find the function and store its pointer to F
:Lbl "Func→F
:
://Call the function
:prgm(F,1,3
:
://display
:ClrDraw
:Text('0,0,X
:DispGraph
:
:Stop
:
://Start the function
:.Func
://Save the global vars
:▶Nom(A,B
:
://parse the function parameters
:ParamA,B
:
://Do something, leaving the result in X
:A+B→X
:
://End the ▶Nom( block
:End
:
://End the function
:End
Note: Grammer has a token hook that will change the names of some tokens
Remarque: Grammer a un "token hook" qui changera les noms de certains tokens:
- Code: Tout sélectionner
▶Nom( ==> Local
Param ==> StackOp
prgm ==> call
DispGraph ==> DispBuf