@@ -31,10 +31,13 @@ Blockly.Msg.RENAME_VARIABLE_TITLE = "Renommer toutes les variables '%1' en :";
3131Blockly . MicroAlg = new Blockly . Generator ( 'MicroAlg' ) ;
3232Blockly . MicroAlg . INDENT = ' ' ;
3333Blockly . MicroAlg . addReservedWords (
34- '=, =/, <, <=, >, >=, ' +
35- 'Affecter_a, Afficher, Aide, Bloc, Booleen?, Concatener, ' +
36- 'Demander, Faire, Faux, Faux?, Initialiser, Nombre, Nombre?, ' +
37- 'Rien, Si, Tant_que, Texte, Texte?, Type, Vrai, Vrai?' ) ;
34+ 'Affecter_a, Afficher, Aide, Ajouter_a, Alors, Booleen?, Concatener, ' +
35+ 'Definir, Demander, En_position, Entier@, Et, Exemples_de, ' +
36+ 'Faire, Faux, Faux?, Initialiser, Initialiser@, ' +
37+ 'Liste, Liste?, Longueur, Nieme, Nieme@, Nombre, Nombre?, Non, Ou, ' +
38+ 'Queue, Retirer_de, Retourner, Rien, Si, Sinon, ' +
39+ 'Tant_que, Tester, Tete, Texte, Texte?, Type, ' +
40+ 'Vide?, Vrai, Vrai?' ) ;
3841
3942// La suite, jusqu’au commentaire de fin, n’a pas été modifiée.
4043
@@ -396,6 +399,37 @@ Blockly.MicroAlg['demander'] = function(block) {
396399 return '(Demander)' ;
397400} ;
398401
402+ // Bloc Entier@
403+ Blockly . Blocks [ 'entier_pseudo_aleatoire' ] = {
404+ init : function ( ) {
405+ this . setHelpUrl ( malg_url + '#cmd-Entier@' ) ;
406+ this . setColour ( 250 ) ;
407+ this . appendValueInput ( 'MIN' )
408+ . setCheck ( 'Number' )
409+ . appendField ( 'Entier@' ) ;
410+ this . appendValueInput ( 'MAX' )
411+ . setCheck ( 'Number' ) ;
412+ this . setInputsInline ( true ) ;
413+ this . setOutput ( true , 'Number' ) ;
414+ this . setTooltip ( 'Nombre pseudo-aléatoire entre les valeurs fournies.' ) ;
415+ }
416+ } ;
417+
418+ // Gen Entier@
419+ Blockly . MicroAlg [ 'entier_pseudo_aleatoire' ] = function ( block ) {
420+ var min = Blockly . MicroAlg . statementToCode ( block , 'MIN' ) || '' ;
421+ var max = Blockly . MicroAlg . statementToCode ( block , 'MAX' ) || '' ;
422+ if ( min + max === '' ) return '(Entier@)' ;
423+ var num_lines = ( min + max ) . split ( '\n' ) . length ;
424+ if ( num_lines == 1 ) {
425+ // Prevent indentation if we only have one line.
426+ return '(Entier@ ' + min . substring ( Blockly . MicroAlg . INDENT . length ) +
427+ ' ' + max . substring ( Blockly . MicroAlg . INDENT . length ) + ')' ;
428+ } else {
429+ return '(Entier@\n' + min + '\n' + max + '\n)' ;
430+ }
431+ } ;
432+
399433// Bloc Faire
400434// Gen Faire
401435// Bloc Initialiser
0 commit comments