FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC

Développement d'applications avec le langage Panoramic
 
AccueilAccueil  RechercherRechercher  Dernières imagesDernières images  S'enregistrerS'enregistrer  MembresMembres  Connexion  
Derniers sujets
» PANORAMIC V 1
Une calculette basique pour les enfants Emptypar Klaus Aujourd'hui à 9:53

» Je teste PANORAMIC V 1 beta 1
Une calculette basique pour les enfants Emptypar Klaus Aujourd'hui à 9:52

» bouton dans autre form que 0
Une calculette basique pour les enfants Emptypar leclode Hier à 13:59

» KGF_dll - nouvelles versions
Une calculette basique pour les enfants Emptypar Klaus Hier à 11:41

» Gestion d'un système client-serveur.
Une calculette basique pour les enfants Emptypar Klaus Hier à 10:23

» Editeur EliP 6 : Le Tiny éditeur avec 25 onglets de travail
Une calculette basique pour les enfants Emptypar Froggy One Jeu 2 Mai 2024 - 11:16

» @Jack
Une calculette basique pour les enfants Emptypar Jack Mar 30 Avr 2024 - 20:40

» trop de fichiers en cours
Une calculette basique pour les enfants Emptypar papydall Lun 29 Avr 2024 - 23:39

» Une calculatrice en une ligne de programme
Une calculette basique pour les enfants Emptypar jean_debord Dim 28 Avr 2024 - 8:47

» Form(résolu)
Une calculette basique pour les enfants Emptypar leclode Sam 27 Avr 2024 - 17:59

» Bataille navale SM
Une calculette basique pour les enfants Emptypar jjn4 Ven 26 Avr 2024 - 17:39

» Les maths du crocodile
Une calculette basique pour les enfants Emptypar jean_debord Jeu 25 Avr 2024 - 10:37

» Naissance de Crocodile Basic
Une calculette basique pour les enfants Emptypar jean_debord Jeu 25 Avr 2024 - 8:45

» Dessine-moi une galaxie
Une calculette basique pour les enfants Emptypar jjn4 Lun 22 Avr 2024 - 13:47

» Erreur END_SUB
Une calculette basique pour les enfants Emptypar jjn4 Lun 22 Avr 2024 - 13:43

Navigation
 Portail
 Index
 Membres
 Profil
 FAQ
 Rechercher
Rechercher
 
 

Résultats par :
 
Rechercher Recherche avancée
Mai 2024
LunMarMerJeuVenSamDim
  12345
6789101112
13141516171819
20212223242526
2728293031  
CalendrierCalendrier
-20%
Le deal à ne pas rater :
-20% Récupérateur à eau mural 300 litres (Anthracite)
79 € 99 €
Voir le deal

 

 Une calculette basique pour les enfants

Aller en bas 
+3
Minibug
Yannick
Jean Claude
7 participants
AuteurMessage
Jean Claude

Jean Claude


Nombre de messages : 5948
Age : 69
Localisation : 83 Var
Date d'inscription : 07/05/2009

Une calculette basique pour les enfants Empty
MessageSujet: Une calculette basique pour les enfants   Une calculette basique pour les enfants EmptyDim 30 Aoû 2015 - 11:59

Comme c'est dit dans le titre, cette calculette est destinée aux enfants.
Elle ne fait qu'une opération à la fois.
L' opération et son résultat sont affichés dans un list pour que l'enfant puisse visualiser ce qu'il tape.
Les touches + - / * = , % sont contrôlées pour éviter les erreurs de saisie.

Code:
' Calculette_Basique par JC 08/2015
hide 0
application_title "CALCULETTE (Basique)"
message string$(51," ")+"INFORMATION"+chr$(13)+"Cette calculette est destinée aux enfants. Elle ne fait qu'un calcul à la fois."
Retourne_Dimension_Bandeau_Et_Bord()
Dim_Label()
Objets()
show 0
reinit()
END
rem ============================================================================
clics:
   if number_click=bt_CE% then reinit()
   if number_click=bt_divise% then divise()
   if number_click=bt_multipli% then multipli()
   if number_click=bt_moins% then moins()
   if number_click=bt_virg% then virg()
   if number_click=bt_PC% then PC()
   if number_click=bt_plus% then plus()
   if number_click=bt_egal% then egal()
   if number_click=bt_0% then bt_0()
   if number_click=bt_1% then bt_1()
   if number_click=bt_2% then bt_2()
   if number_click=bt_3% then bt_3()
   if number_click=bt_4% then bt_4()
   if number_click=bt_5% then bt_5()
   if number_click=bt_6% then bt_6()
   if number_click=bt_7% then bt_7()
   if number_click=bt_8% then bt_8()
   if number_click=bt_9% then bt_9()
RETURN

rem ============================================================================
SUB reinit()
  tour%=0 : nb=0 : nbP=0 : resultP=0 : nombre$="" : lig$="" : op$="" : mode$="" : inactive bt_PC%
  clear afi_result% : clear afi_op% : inactive bt_egal% : inactive_boutons() : active bt_virg%
END_SUB

' les 4 opérations
SUB divise()
    tour%=0 : active bt_virg%
    inactive_boutons() : op$="/" : clear afi_result% : lig$=lig$+" : " : affiche_lig()
    if mode$="" then nb=val(nombre$) : mode$="C" : nbP=nb : nb=0 : nombre$=""
END_SUB

SUB multipli()
    tour%=0 : active bt_virg% : active bt_PC%
    inactive_boutons() : op$="*" : clear afi_result% : lig$=lig$+" x " : affiche_lig()
    if mode$="" then nb=val(nombre$) : mode$="C" : nbP=nb : nb=0 : nombre$=""
END_SUB

SUB plus()
    tour%=0 : active bt_virg% : active bt_PC%
    inactive_boutons() : op$="+" : clear afi_result% : lig$=lig$+" + " : affiche_lig()
    if mode$="" then nb=val(nombre$) : mode$="C" : nbP=nb : nb=0 : nombre$=""
END_SUB

SUB moins()
    tour%=0 : active bt_virg% : active bt_PC%
    inactive_boutons() : op$="-" : clear afi_result% : lig$=lig$+" - " : affiche_lig()
    if mode$="" then nb=val(nombre$) : mode$="C" : nbP=nb : nb=0 : nombre$=""
END_SUB

' résultat
SUB egal()
  if numeric(nombre$)=1
     nb=val(nombre$)
  else
     if right$(nombre$,1)="%" and op$="*"
        nombre$=left$(nombre$,len(nombre$)-1) : nb=val(nombre$) : op$="%*"
     end_if
     if right$(nombre$,1)="%" and op$="+"
        nombre$=left$(nombre$,len(nombre$)-1) : nb=val(nombre$) : op$="%+"
     end_if
     if right$(nombre$,1)="%" and op$="-"
        nombre$=left$(nombre$,len(nombre$)-1) : nb=val(nombre$) : op$="%-"
     end_if
  end_if
  inactive bt_egal% : tour%=0 : active bt_virg%
  if op$="%*" then nbP=(nbP*nb)/100
  if op$="%+" then nbP=nbP+((nbP*nb)/100)
  if op$="%-" then nbP=nbP-((nbP*nb)/100)
  if op$="+" then nbP=nbP+nb
  if op$="-" then nbP=nbP-nb
  if op$="*" then nbP=nbP*nb
  if op$="/"
     if nb<>0
        nbP=nbP/nb
     else
        message "La division par zéro n'existe pas" : reinit() : EXIT_SUB
     end_if
  end_if
  clear afi_result% : lig$=lig$+" = "+str$(nbP) : affiche_lig()
  nb=0 : nombre$="" : mode$="F" : clear afi_result% : item_add afi_result%,str$(nbP)
END_SUB

' la touche %
SUB PC()
    inactive bt_PC%
    Ctrl_Mode() : nombre$=nombre$+"%" : affiche() : lig$=lig$+"%" : affiche_lig()
END_SUB

' la virgule
SUB virg()
    inactive bt_virg%
    if tour%=0 or mode$="F" then nombre$="0" : lig$=lig$+"0"
    nombre$=nombre$+"." : affiche() : lig$=lig$+"," : affiche_lig()
    if mode$="F"  then inactive bt_egal% :  mode$="" : lig$="0," : nbP=0 : affiche_lig()
END_SUB

' les chiffres
SUB bt_0()
    Ctrl_Mode() : nombre$=nombre$+"0" : affiche() : lig$=lig$+"0" : affiche_lig()
END_SUB
SUB bt_1()
    Ctrl_Mode() : nombre$=nombre$+"1" : affiche() : lig$=lig$+"1" : affiche_lig()
END_SUB
SUB bt_2()
    Ctrl_Mode() : nombre$=nombre$+"2" : affiche() : lig$=lig$+"2" : affiche_lig()
END_SUB
SUB bt_3()
    Ctrl_Mode() : nombre$=nombre$+"3" : affiche() : lig$=lig$+"3" : affiche_lig()
END_SUB
SUB bt_4()
    Ctrl_Mode() : nombre$=nombre$+"4" : affiche() : lig$=lig$+"4" : affiche_lig()
END_SUB
SUB bt_5()
    Ctrl_Mode() : nombre$=nombre$+"5" : affiche() : lig$=lig$+"5" : affiche_lig()
END_SUB
SUB bt_6()
    Ctrl_Mode() : nombre$=nombre$+"6" : affiche() : lig$=lig$+"6" : affiche_lig()
END_SUB
SUB bt_7()
    Ctrl_Mode() : nombre$=nombre$+"7" : affiche() : lig$=lig$+"7" : affiche_lig()
END_SUB
SUB bt_8()
    Ctrl_Mode() : nombre$=nombre$+"8" : affiche() : lig$=lig$+"8" : affiche_lig()
END_SUB
SUB bt_9()
    Ctrl_Mode() : nombre$=nombre$+"9" : affiche() : lig$=lig$+"9" : affiche_lig()
END_SUB
SUB Ctrl_Mode()
    if mode$="F" then inactive bt_egal% : mode$="" : lig$="" : nbP=0 : affiche_lig()
    if mode$="C" then active bt_egal% : inactive_boutons()
    if mode$="" then active_boutons()
    tour%=tour%+1
END_SUB
' l'affichage
SUB affiche()
    clear afi_result% : item_add afi_result%,nombre$
END_SUB
SUB affiche_lig()
    clear afi_op% : item_add afi_op%,lig$
END_SUB
' contrôle des boutons
SUB inactive_boutons()
    inactive bt_divise% : inactive bt_multipli% : inactive bt_moins% : inactive bt_plus%
END_SUB
SUB active_boutons()
    active bt_divise% : active bt_multipli% : active bt_moins% : active bt_plus%
END_SUB
rem ============================================================================
SUB Dim_Label()
    dim no%,tour%
    dim nb,nbP,resultP
    dim virgul$,nombre$,lig$,op$,mode$
    virgul$="."
    dim afi_result%,afi_op%
    dim bt_CE%,bt_divise%,bt_multipli%,bt_moins%,bt_virg%,bt_PC%,bt_plus%,bt_egal%
    dim bt_0%,bt_1%,bt_2%,bt_3%,bt_4%,bt_5%,bt_6%,bt_7%,bt_8%,bt_9%
    label fin,clics
END_SUB
' ------------------------------------------------------------------------------
SUB Objets()
    ' Form 0
    border_small 0 : caption 0,"CALCULETTE (Basique)" : width 0,400
    height 0,302 : width 0,187 : top 0,(screen_y/2)-(height(0)/2) : left 0,(screen_x/2)-(width(0)/2)
    color 0,200,240,255
    ' Afficheurs
    no%=no%+1 : afi_op%=no% : list no% : parent no%,0
                ' font_name no%,"DejaVu Sans Mono"
                width no%,width(0)-(bord%*2)-8 : left no%,4 : height no%,20 : top no%,5
    no%=no%+1 : afi_result%=no% : list no% : parent no%,0
                ' font_name no%,"DejaVu Sans Mono"
                font_bold no% : font_size no%,14
                width no%,width(0)-(bord%*2)-8 : left no%,4 : height no%,30 : top no%,top(afi_op%)+height(afi_op%)+2
    ' les boutons
    ' la première rangée
    no%=no%+1 : bt_CE%=no% : button no% : parent no%,0 : width no%,40 : height no%,40
                  font_name no%,"DejaVu Sans Mono" : font_bold no% : font_size no%,18 : caption no%,"C"
                  top no%,top(afi_result%)+height(afi_result%)+2 : left no%,left(afi_result%)
                  on_click no%,clics
    no%=no%+1 : bt_divise%=no% : button no% : parent no%,0 : width no%,40 : height no%,40
                  font_name no%,"DejaVu Sans Mono" : font_bold no% : font_size no%,18 : caption no%,"/"
                  top no%,top(afi_result%)+height(afi_result%)+2 : left no%,left(bt_CE%)+width(bt_CE%)+1
                  on_click no%,clics
    no%=no%+1 : bt_multipli%=no% : button no% : parent no%,0 : width no%,40 : height no%,40
                  font_name no%,"DejaVu Sans Mono" : font_bold no% : font_size no%,18 : caption no%,"*"
                  top no%,top(afi_result%)+height(afi_result%)+2 : left no%,left(bt_divise%)+width(bt_divise%)+1
                  on_click no%,clics
    no%=no%+1 : bt_moins%=no% : button no% : parent no%,0 : width no%,40 : height no%,40
                  font_name no%,"DejaVu Sans Mono" : font_bold no% : font_size no%,18 : caption no%,"-"
                  top no%,top(afi_result%)+height(afi_result%)+2 : left no%,left(bt_multipli%)+width(bt_multipli%)+1
                  on_click no%,clics
    ' la deuxième rangée
    no%=no%+1 : bt_7%=no% : button no% : parent no%,0 : width no%,40 : height no%,40
                  font_name no%,"DejaVu Sans Mono" : font_bold no% : font_size no%,18 : caption no%,"7"
                  top no%,top(afi_result%)+height(afi_result%)+height(bt_CE%)+2 : left no%,left(bt_CE%)
                  on_click no%,clics
    no%=no%+1 : bt_8%=no% : button no% : parent no%,0 : width no%,40 : height no%,40
                  font_name no%,"DejaVu Sans Mono" : font_bold no% : font_size no%,18 : caption no%,"8"
                  top no%,top(afi_result%)+height(afi_result%)+height(bt_CE%)+2 : left no%,left(bt_7%)+width(bt_7%)+1
                  on_click no%,clics
    no%=no%+1 : bt_9%=no% : button no% : parent no%,0 : width no%,40 : height no%,40
                  font_name no%,"DejaVu Sans Mono" : font_bold no% : font_size no%,18 : caption no%,"9"
                  top no%,top(afi_result%)+height(afi_result%)+height(bt_CE%)+2 : left no%,left(bt_8%)+width(bt_8%)+1
                  on_click no%,clics
    ' la troisième rangée
    no%=no%+1 : bt_4%=no% : button no% : parent no%,0 : width no%,40 : height no%,40
                  font_name no%,"DejaVu Sans Mono" : font_bold no% : font_size no%,18 : caption no%,"4"
                  top no%,top(afi_result%)+height(afi_result%)+(height(bt_CE%)*2)+2 : left no%,left(bt_7%)
                  on_click no%,clics
    no%=no%+1 : bt_5%=no% : button no% : parent no%,0 : width no%,40 : height no%,40
                  font_name no%,"DejaVu Sans Mono" : font_bold no% : font_size no%,18 : caption no%,"5"
                  top no%,top(afi_result%)+height(afi_result%)+(height(bt_CE%)*2)+2 : left no%,left(bt_8%)
                  on_click no%,clics
    no%=no%+1 : bt_6%=no% : button no% : parent no%,0 : width no%,40 : height no%,40
                  font_name no%,"DejaVu Sans Mono" : font_bold no% : font_size no%,18 : caption no%,"6"
                  top no%,top(afi_result%)+height(afi_result%)+(height(bt_CE%)*2)+2 : left no%,left(bt_9%)
                  on_click no%,clics
    ' quatrième rangée
    no%=no%+1 : bt_1%=no% : button no% : parent no%,0 : width no%,40 : height no%,40
                  font_name no%,"DejaVu Sans Mono" : font_bold no% : font_size no%,18 : caption no%,"1"
                  top no%,top(afi_result%)+height(afi_result%)+(height(bt_CE%)*3)+2 : left no%,left(bt_4%)
                  on_click no%,clics
    no%=no%+1 : bt_2%=no% : button no% : parent no%,0 : width no%,40 : height no%,40
                  font_name no%,"DejaVu Sans Mono" : font_bold no% : font_size no%,18 : caption no%,"2"
                  top no%,top(afi_result%)+height(afi_result%)+(height(bt_CE%)*3)+2 : left no%,left(bt_5%)
                  on_click no%,clics
    no%=no%+1 : bt_3%=no% : button no% : parent no%,0 : width no%,40 : height no%,40
                  font_name no%,"DejaVu Sans Mono" : font_bold no% : font_size no%,18 : caption no%,"3"
                  top no%,top(afi_result%)+height(afi_result%)+(height(bt_CE%)*3)+2 : left no%,left(bt_6%)
                  on_click no%,clics
    ' cinquième rangée
    no%=no%+1 : bt_0%=no% : button no% : parent no%,0 : width no%,40 : height no%,40
                  font_name no%,"DejaVu Sans Mono" : font_bold no% : font_size no%,18 : caption no%,"0"
                  top no%,top(afi_result%)+height(afi_result%)+(height(bt_CE%)*4)+2 : left no%,left(bt_1%)
                  on_click no%,clics
    no%=no%+1 : bt_PC%=no% : button no% : parent no%,0 : width no%,40 : height no%,40
                  font_name no%,"DejaVu Sans Mono" : font_bold no% : font_size no%,18 : caption no%,"%"
                  top no%,top(afi_result%)+height(afi_result%)+(height(bt_CE%)*4)+2 : left no%,left(bt_2%)
                  on_click no%,clics
    no%=no%+1 : bt_virg%=no% : button no% : parent no%,0 : width no%,40 : height no%,40
                  font_name no%,"DejaVu Sans Mono" : font_bold no% : font_size no%,18 : caption no%,","
                  top no%,top(afi_result%)+height(afi_result%)+(height(bt_CE%)*4)+2 : left no%,left(bt_3%)
                  on_click no%,clics
    ' Bouton +
    no%=no%+1 : bt_plus%=no% : button no% : parent no%,0 : width no%,40 : height no%,80
                  font_name no%,"DejaVu Sans Mono" : font_bold no% : font_size no%,18 : caption no%,"+"
                  top no%,top(afi_result%)+height(afi_result%)+height(bt_moins%)+2 : left no%,left(bt_multipli%)+width(bt_multipli%)+1
                  on_click no%,clics
    ' Bouton =
    no%=no%+1 : bt_egal%=no% : button no% : parent no%,0 : width no%,40 : height no%,80
                  font_name no%,"DejaVu Sans Mono" : font_bold no% : font_size no%,18 : caption no%,"="
                  top no%,top(bt_3%) : left no%,left(bt_plus%)
                  on_click no%,clics
END_SUB
rem ============================================================================
SUB Retourne_Dimension_Bandeau_Et_Bord()
    ' controle de la position de la procédure dans le programme
    IF NUMBER_OBJECTS>0
       message "La SUB 'Retourne_Dimension_Bandeau_Et_Bord' doit être placée avant la création du premier objet !"
       terminate
    END_IF
    ' création des VARIABLES GLOBALES
    IF VARIABLE("bandeau%")=0 then DIM bandeau%
    IF VARIABLE("bord%")=0 then DIM bord%
    ' Calcul de bandeau% et bord%
    dim_local w0%,h0%,w1%,h1%,w2%,h2%
    w0%=WIDTH(0) : h0%=HEIGHT(0)
    picture 1 : full_space 1 : w1%=WIDTH(1) : h1%=HEIGHT(1)
    w2%=w0%-w1% : h2%=h0%-h1% : bandeau%=h2%-(w2%/2) : bord%=w2%/2
    ' Suppression du Picture devenu inutile
    delete 1
END_SUB
rem ============================================================================
fin:
   terminate
RETURN

A+

PS: je ferais une version avec des boutons de couleurs pour la rendre attrayante.
Revenir en haut Aller en bas
Yannick




Nombre de messages : 8610
Age : 53
Localisation : Bretagne
Date d'inscription : 15/02/2010

Une calculette basique pour les enfants Empty
MessageSujet: re   Une calculette basique pour les enfants EmptyDim 30 Aoû 2015 - 14:52

Elle est chouette cette calculette... Laughing
Revenir en haut Aller en bas
Minibug

Minibug


Nombre de messages : 4566
Age : 57
Localisation : Vienne (86)
Date d'inscription : 09/02/2012

Une calculette basique pour les enfants Empty
MessageSujet: Re: Une calculette basique pour les enfants   Une calculette basique pour les enfants EmptyDim 30 Aoû 2015 - 15:11

Super la calculette jean Claude !
Quand GPP fonctionnera, il faudra qu'on la transpose...

Ça sent la rentrée des classes tout ça !  lol!
Revenir en haut Aller en bas
http://gpp.panoramic.free.fr
JL35




Nombre de messages : 7095
Localisation : 77
Date d'inscription : 29/11/2007

Une calculette basique pour les enfants Empty
MessageSujet: Re: Une calculette basique pour les enfants   Une calculette basique pour les enfants EmptyDim 30 Aoû 2015 - 15:34

Chouette, ça va me servir pour ma rentrée en CM2 ! Wink
Ma maîtresse va être contente (enfin, l'autre...)
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

Une calculette basique pour les enfants Empty
MessageSujet: Re: Une calculette basique pour les enfants   Une calculette basique pour les enfants EmptyDim 30 Aoû 2015 - 17:19

Un bon vieux classique avec une version aux goûts du jour Wink
Revenir en haut Aller en bas
Jean Claude

Jean Claude


Nombre de messages : 5948
Age : 69
Localisation : 83 Var
Date d'inscription : 07/05/2009

Une calculette basique pour les enfants Empty
MessageSujet: Re: Une calculette basique pour les enfants   Une calculette basique pour les enfants EmptyDim 30 Aoû 2015 - 20:28

Merci pour vos commentaires sympas.

Je suis entrain de faire la version en image pour enfant.

A+
Revenir en haut Aller en bas
The Gamer

The Gamer


Nombre de messages : 110
Age : 30
Localisation : Toulouse (31)
Date d'inscription : 11/05/2010

Une calculette basique pour les enfants Empty
MessageSujet: Re: Une calculette basique pour les enfants   Une calculette basique pour les enfants EmptyLun 31 Aoû 2015 - 17:11





cheers  Simple + compact + utile = Excellent !! cheers
Revenir en haut Aller en bas
http://pierrehardy.pagesperso-orange.fr/
Jean Claude

Jean Claude


Nombre de messages : 5948
Age : 69
Localisation : 83 Var
Date d'inscription : 07/05/2009

Une calculette basique pour les enfants Empty
MessageSujet: Re: Une calculette basique pour les enfants   Une calculette basique pour les enfants EmptyLun 31 Aoû 2015 - 21:19

Merci The Gamer,

@Tous,
J'ai terminé la version spéciale enfant, mais comme j'ai remplacé les boutons par des images (picture), il faut la télécharger sur mon Webdav
le dossier s’appelle "Calculette_Enfant.zip"

J'ai un peu amélioré le code et je l'ai adapté aux "boutons_image".

J'ai un bug (mineur):  En cas de dépassement du nombre de caractère dans le LIST afi_result%. Ce bug est dans l'affichage du LIST afi_op%. Normalement, en passant par la SUB reinit(), ce LIST devrait être purgé et ce n'est pas le cas.
Et je ne comprends pas pourquoi Question
Pour provoquer ce bug (mineur) il faut taper 15 chiffres (sans opération) à la suite. Vous constaterez (Après le message) que l'afficheur du haut garde en mémoire le dernier chiffre tapé. Je ne vois pas pourquoi Question

A+


Dernière édition par Jean Claude le Mar 1 Sep 2015 - 20:26, édité 1 fois
Revenir en haut Aller en bas
Jean Claude

Jean Claude


Nombre de messages : 5948
Age : 69
Localisation : 83 Var
Date d'inscription : 07/05/2009

Une calculette basique pour les enfants Empty
MessageSujet: Re: Une calculette basique pour les enfants   Une calculette basique pour les enfants EmptyMar 1 Sep 2015 - 20:22

Quelqu'un s'est-il penché sur le bug décrit dans mon intervention précédente ?

De mon coté, je sèche.

A+

EDIT: je précise que je parle de la version "Enfant" à télécharger.
Revenir en haut Aller en bas
Cobra

Cobra


Nombre de messages : 14
Localisation : France
Date d'inscription : 05/11/2009

Une calculette basique pour les enfants Empty
MessageSujet: Re: Une calculette basique pour les enfants   Une calculette basique pour les enfants EmptyMar 1 Sep 2015 - 22:49

Salut Jean-Claude

Je pense que le problème vient de la ligne 126 (procédure bt).
Après avoir fait un clear de la list, n$ contient toujours le dernier chiffre entré et la procédure affiche_lig() à la fin de la ligne 126 le ré-affiche

Bonne soirée
Revenir en haut Aller en bas
Jean Claude

Jean Claude


Nombre de messages : 5948
Age : 69
Localisation : 83 Var
Date d'inscription : 07/05/2009

Une calculette basique pour les enfants Empty
MessageSujet: Re: Une calculette basique pour les enfants   Une calculette basique pour les enfants EmptyMer 2 Sep 2015 - 7:27

Bien vu Cobra,

Pour ceux qui ont téléchargé, il suffit de remplacer la SUB bt(n$) par celle-ci.
Code:
SUB bt(n$)
    Ctrl_Mode() : nombre$=nombre$+n$ : lig$=lig$+n$ : n$="" : affiche() : affiche_lig()
END_SUB

Merci Cobra, j'ai cherché longtemps sans voir ce qui était évident.

A+

PS: Mon Webdav est à jour.
Revenir en haut Aller en bas
Jean Claude

Jean Claude


Nombre de messages : 5948
Age : 69
Localisation : 83 Var
Date d'inscription : 07/05/2009

Une calculette basique pour les enfants Empty
MessageSujet: Re: Une calculette basique pour les enfants   Une calculette basique pour les enfants EmptyLun 14 Sep 2015 - 8:31

Tel quel, la calculette a un petit bug avec la touche de la division.

Voici le nouveau code qui va bien (les images restent les mêmes)

Code:
' Calculette_Basique par JC 08/2015
hide 0
application_title "CALCULETTE (Basique)"
' message string$(51," ")+"INFORMATION"+chr$(13)+"Cette calculette est destinée aux enfants. Elle ne fait qu'un calcul à la fois."
Retourne_Dimension_Bandeau_Et_Bord()
Dim_Label()
Objets()
show 0
reinit()
END
rem ============================================================================
clics:
  if number_click=bt_CE% then reinit()
  if number_click=bt_divise% then divise()
  if number_click=bt_multipli% then multipli()
  if number_click=bt_moins% then moins()
  if number_click=bt_virg% then virg()
  if number_click=bt_PC% then PC()
  if number_click=bt_plus% then plus()
  if number_click=bt_egal% then egal()
  if number_click=bt_0% then bt("0")
  if number_click=bt_1% then bt("1")
  if number_click=bt_2% then bt("2")
  if number_click=bt_3% then bt("3")
  if number_click=bt_4% then bt("4")
  if number_click=bt_5% then bt("5")
  if number_click=bt_6% then bt("6")
  if number_click=bt_7% then bt("7")
  if number_click=bt_8% then bt("8")
  if number_click=bt_9% then bt("9")
RETURN

rem ============================================================================
SUB reinit()
    tour%=0 : nb=0 : nbP=0 : nombre$="" : lig$="" : op$="" : mode$="" : inactive bt_PC%
    clear afi_op% : clear afi_result% : inactive bt_egal% : inactive_boutons() : active bt_virg%
    Ctrl_bouton() : set_focus 0
END_SUB
SUB Ctrl_bouton()
    if active(bt_egal%)=0 then file_load bt_egal%,"egal_nb.bmp"
    if active(bt_egal%)=1 then file_load bt_egal%,"egal.bmp"
    if active(bt_virg%)=0 then file_load bt_virg%,"virgule_nb.bmp"
    if active(bt_virg%)=1 then file_load bt_virg%,"virgule.bmp"
    if active(bt_PC%)=0 then file_load bt_PC%,"Pourcentage_nb.bmp"
    if active(bt_PC%)=1 then file_load bt_PC%,"Pourcentage.bmp"
    if active(bt_plus%)=0 then file_load bt_plus%,"plus_nb.bmp"
    if active(bt_plus%)=1 then file_load bt_plus%,"plus.bmp"
    if active(bt_moins%)=0 then file_load bt_moins%,"moins_nb.bmp"
    if active(bt_moins%)=1 then file_load bt_moins%,"moins.bmp"
    if active(bt_multipli%)=0 then file_load bt_multipli%,"multiplication_nb.bmp"
    if active(bt_multipli%)=1 then file_load bt_multipli%,"multiplication.bmp"
    if active(bt_divise%)=0 then file_load bt_divise%,"division_nb.bmp"
    if active(bt_divise%)=1 then file_load bt_divise%,"division.bmp"
END_SUB

' les 4 opérations
SUB divise()
    tour%=0 : active bt_virg%
    inactive_boutons() : op$="/" : clear afi_result% : lig$=lig$+" : " : affiche_lig()
    if mode$="" then nb=val(nombre$) : mode$="C" : nbP=nb : nb=0 : nombre$=""
END_SUB
SUB multipli()
    tour%=0 : active bt_virg% : active bt_PC%
    inactive_boutons() : op$="*" : clear afi_result% : lig$=lig$+" x " : affiche_lig()
    if mode$="" then nb=val(nombre$) : mode$="C" : nbP=nb : nb=0 : nombre$=""
END_SUB
SUB plus()
    tour%=0 : active bt_virg% : active bt_PC%
    inactive_boutons() : op$="+" : clear afi_result% : lig$=lig$+" + " : affiche_lig()
    if mode$="" then nb=val(nombre$) : mode$="C" : nbP=nb : nb=0 : nombre$=""
END_SUB
SUB moins()
    tour%=0 : active bt_virg% : active bt_PC%
    inactive_boutons() : op$="-" : clear afi_result% : lig$=lig$+" - " : affiche_lig()
    if mode$="" then nb=val(nombre$) : mode$="C" : nbP=nb : nb=0 : nombre$=""
END_SUB
' résultat
SUB egal()
  if numeric(nombre$)=1
    nb=val(nombre$)
  else
    if right$(nombre$,1)="%" and op$="*"
        nombre$=left$(nombre$,len(nombre$)-1) : nb=val(nombre$) : op$="%*"
    end_if
    if right$(nombre$,1)="%" and op$="+"
        nombre$=left$(nombre$,len(nombre$)-1) : nb=val(nombre$) : op$="%+"
    end_if
    if right$(nombre$,1)="%" and op$="-"
        nombre$=left$(nombre$,len(nombre$)-1) : nb=val(nombre$) : op$="%-"
    end_if
  end_if
  inactive bt_egal% : tour%=0 : active bt_virg%
  if op$="%*" then nbP=(nbP*nb)/100
  if op$="%+" then nbP=nbP+((nbP*nb)/100)
  if op$="%-" then nbP=nbP-((nbP*nb)/100)
  if op$="+" then nbP=nbP+nb
  if op$="-" then nbP=nbP-nb
  if op$="*" then nbP=nbP*nb
  if op$="/"
    if nb<>0
        nbP=nbP/nb
    else
        message "La division par zéro n'existe pas" : reinit() : EXIT_SUB
    end_if
  end_if
  clear afi_result% : lig$=lig$+" = "+str$(nbP) : affiche_lig()
  nb=0 : nombre$="" : mode$="F" : clear afi_result% : item_add afi_result%,str$(nbP)
  Ctrl_bouton()
END_SUB
' la touche %
SUB PC()
    inactive bt_PC%
    Ctrl_Mode() : nombre$=nombre$+"%" : affiche() : lig$=lig$+"%" : affiche_lig()
    Ctrl_bouton()
END_SUB
' la virgule
SUB virg()
    inactive bt_virg% : Ctrl_bouton()
    if tour%=0 or mode$="F" then nombre$="0" : lig$=lig$+"0"
    nombre$=nombre$+"." : affiche() : lig$=lig$+"," : affiche_lig()
    if mode$="F"  then inactive bt_egal% :  mode$="" : lig$="0," : nbP=0 : affiche_lig()
END_SUB
' les chiffres
SUB bt(n$)
    Ctrl_Mode() : nombre$=nombre$+n$ : lig$=lig$+n$ : n$="" : affiche() : affiche_lig()
END_SUB
SUB Ctrl_Mode()
    Ctrl_bouton()
    if mode$="F" then inactive bt_egal% : mode$="" : lig$="" : nbP=0 : affiche_lig()
    if mode$="C" then active bt_egal% : inactive_boutons()
    if mode$="" then active_boutons()
    tour%=tour%+1
END_SUB
' l'affichage
SUB affiche()
    if len(nombre$)>14 then message "  14 chiffres maximum !  " : reinit() : Exit_Sub
    clear afi_result% : item_add afi_result%,nombre$
END_SUB
SUB affiche_lig()
    clear afi_op%
    if len(lig$)>26 then Exit_Sub
    item_add afi_op%,lig$
END_SUB
' contrôle des boutons
SUB inactive_boutons()
    inactive bt_divise% : inactive bt_multipli% : inactive bt_moins% : inactive bt_plus%
    Ctrl_bouton()
END_SUB
SUB active_boutons()
    active bt_divise% : active bt_multipli% : active bt_moins% : active bt_plus%
    Ctrl_bouton()
END_SUB
rem ============================================================================
SUB Dim_Label()
    dim no%,tour%
    dim nb,nbP
    dim virgul$,nombre$,lig$,op$,mode$
    virgul$="."
    dim afi_result%,afi_op%
    dim bt_CE%,bt_divise%,bt_multipli%,bt_moins%,bt_virg%,bt_PC%,bt_plus%,bt_egal%
    dim bt_0%,bt_1%,bt_2%,bt_3%,bt_4%,bt_5%,bt_6%,bt_7%,bt_8%,bt_9%
    label fin,clics
END_SUB
' ------------------------------------------------------------------------------
SUB Objets()
    ' Form 0
    border_small 0 : caption 0,"CALCULETTE (Basique)" : width 0,400
    height 0,302 : width 0,187 : top 0,(screen_y/2)-(height(0)/2) : left 0,(screen_x/2)-(width(0)/2)
    color 0,150,240,255
    ' Afficheurs
    no%=no%+1 : afi_op%=no% : list no% :' font_bold no%
                width no%,width(0)-(bord%*2)-8 : left no%,4 : height no%,20 : top no%,5
    no%=no%+1 : afi_result%=no% : list no% : color no%, 255,255,0
                font_color no%,0,100,255
                font_bold no% : font_size no%,14
                width no%,width(0)-(bord%*2)-8 : left no%,4 : height no%,30 : top no%,top(afi_op%)+height(afi_op%)+2
    ' les boutons
    ' la première rangée
    no%=no%+1 : bt_CE%=no% : picture no% : width no%,40 : height no%,40 : file_load no%,"clear.bmp"
                  top no%,top(afi_result%)+height(afi_result%)+2 : left no%,left(afi_result%)
                  on_click no%,clics
    no%=no%+1 : bt_divise%=no% : picture no% : width no%,40 : height no%,40 : file_load no%,"division.bmp"
                  top no%,top(afi_result%)+height(afi_result%)+2 : left no%,left(bt_CE%)+width(bt_CE%)+1
                  on_click no%,clics
    no%=no%+1 : bt_multipli%=no% : picture no% : width no%,40 : height no%,40 : file_load no%,"multiplication.bmp"
                  top no%,top(afi_result%)+height(afi_result%)+2 : left no%,left(bt_divise%)+width(bt_divise%)+1
                  on_click no%,clics
    no%=no%+1 : bt_moins%=no% : picture no% : width no%,40 : height no%,40 : file_load no%,"moins.bmp"
                  top no%,top(afi_result%)+height(afi_result%)+2 : left no%,left(bt_multipli%)+width(bt_multipli%)+1
                  on_click no%,clics
    ' la deuxième rangée
    no%=no%+1 : bt_7%=no% : picture no% : width no%,40 : height no%,40 : file_load no%,"7.bmp"
                  top no%,top(afi_result%)+height(afi_result%)+height(bt_CE%)+2 : left no%,left(bt_CE%)
                  on_click no%,clics
    no%=no%+1 : bt_8%=no% : picture no% : width no%,40 : height no%,40 : file_load no%,"8.bmp"
                  top no%,top(afi_result%)+height(afi_result%)+height(bt_CE%)+2 : left no%,left(bt_7%)+width(bt_7%)+1
                  on_click no%,clics
    no%=no%+1 : bt_9%=no% : picture no% : width no%,40 : height no%,40 : file_load no%,"9.bmp"
                  top no%,top(afi_result%)+height(afi_result%)+height(bt_CE%)+2 : left no%,left(bt_8%)+width(bt_8%)+1
                  on_click no%,clics
    ' la troisième rangée
    no%=no%+1 : bt_4%=no% : picture no% : width no%,40 : height no%,40 : file_load no%,"4.bmp"
                  top no%,top(afi_result%)+height(afi_result%)+(height(bt_CE%)*2)+2 : left no%,left(bt_7%)
                  on_click no%,clics
    no%=no%+1 : bt_5%=no% : picture no% : width no%,40 : height no%,40 : file_load no%,"5.bmp"
                  top no%,top(afi_result%)+height(afi_result%)+(height(bt_CE%)*2)+2 : left no%,left(bt_8%)
                  on_click no%,clics
    no%=no%+1 : bt_6%=no% : picture no% : width no%,40 : height no%,40 : file_load no%,"6.bmp"
                  top no%,top(afi_result%)+height(afi_result%)+(height(bt_CE%)*2)+2 : left no%,left(bt_9%)
                  on_click no%,clics
    ' quatrième rangée
    no%=no%+1 : bt_1%=no% : picture no% : width no%,40 : height no%,40 : file_load no%,"1.bmp"
                  top no%,top(afi_result%)+height(afi_result%)+(height(bt_CE%)*3)+2 : left no%,left(bt_4%)
                  on_click no%,clics
    no%=no%+1 : bt_2%=no% : picture no% : width no%,40 : height no%,40 : file_load no%,"2.bmp"
                  top no%,top(afi_result%)+height(afi_result%)+(height(bt_CE%)*3)+2 : left no%,left(bt_5%)
                  on_click no%,clics
    no%=no%+1 : bt_3%=no% : picture no% : width no%,40 : height no%,40 : file_load no%,"3.bmp"
                  top no%,top(afi_result%)+height(afi_result%)+(height(bt_CE%)*3)+2 : left no%,left(bt_6%)
                  on_click no%,clics
    ' cinquième rangée
    no%=no%+1 : bt_0%=no% : picture no% : width no%,40 : height no%,40 : file_load no%,"0.bmp"
                  top no%,top(afi_result%)+height(afi_result%)+(height(bt_CE%)*4)+2 : left no%,left(bt_1%)
                  on_click no%,clics
    no%=no%+1 : bt_PC%=no% : picture no% : width no%,40 : height no%,40 : file_load no%,"Pourcentage.bmp"
                  top no%,top(afi_result%)+height(afi_result%)+(height(bt_CE%)*4)+2 : left no%,left(bt_2%)
                  on_click no%,clics
    no%=no%+1 : bt_virg%=no% : picture no% : width no%,40 : height no%,40 : file_load no%,"virgule.bmp"
                  top no%,top(afi_result%)+height(afi_result%)+(height(bt_CE%)*4)+2 : left no%,left(bt_3%)
                  on_click no%,clics
    ' Bouton +
    no%=no%+1 : bt_plus%=no% : picture no% : width no%,40 : height no%,80 : file_load no%,"plus.bmp"
                  top no%,top(afi_result%)+height(afi_result%)+height(bt_moins%)+2 : left no%,left(bt_multipli%)+width(bt_multipli%)+1
                  on_click no%,clics
    ' Bouton =
    no%=no%+1 : bt_egal%=no% : picture no% : width no%,40 : height no%,80 : file_load no%,"egal.bmp"
                  top no%,top(bt_3%) : left no%,left(bt_plus%)
                  on_click no%,clics
END_SUB
rem ============================================================================
SUB Retourne_Dimension_Bandeau_Et_Bord()
    ' controle de la position de la procédure dans le programme
    IF NUMBER_OBJECTS>0
      message "La SUB 'Retourne_Dimension_Bandeau_Et_Bord' doit être placée avant la création du premier objet !"
      terminate
    END_IF
    ' création des VARIABLES GLOBALES
    IF VARIABLE("bandeau%")=0 then DIM bandeau%
    IF VARIABLE("bord%")=0 then DIM bord%
    ' Calcul de bandeau% et bord%
    dim_local w0%,h0%,w1%,h1%,w2%,h2%
    w0%=WIDTH(0) : h0%=HEIGHT(0)
    picture 1 : full_space 1 : w1%=WIDTH(1) : h1%=HEIGHT(1)
    w2%=w0%-w1% : h2%=h0%-h1% : bandeau%=h2%-(w2%/2) : bord%=w2%/2
    ' Suppression du Picture devenu inutile
    delete 1
END_SUB
rem ============================================================================
fin:
  terminate
RETURN

A+
Revenir en haut Aller en bas
Contenu sponsorisé





Une calculette basique pour les enfants Empty
MessageSujet: Re: Une calculette basique pour les enfants   Une calculette basique pour les enfants Empty

Revenir en haut Aller en bas
 
Une calculette basique pour les enfants
Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» Petits jeux pour enfants et pour moins jeunes
» Pour mes petits-enfants et pour les vôtres
» Une petite calculette en Hexa
» Calculette Décimal/Hexa sous forme de Sub
» PLM N33

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC :: PANORAMIC :: Vos sources, vos utilitaires à partager-
Sauter vers: