Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2362 connectés 

 


 Mot :   Pseudo :  
 
 Page :   1  2  3  4  5  6
Auteur Sujet :

[Ada][Topic Unic][Open Source] Je fais péter mes codes.

n°2445248
rufo
Pas me confondre avec Lycos!
Posté le 24-04-2023 à 15:30:01  profilanswer
 

Reprise du message précédent :

MaybeEijOrNot a écrit :

Ah oui mais en ce moment donner de tels outils librement ça revient à soutenir le gouvernement dans sa politique, je n'aime donc pas trop ce logiciel macroniste. :/


 :whistle:  
 
De toute manière, la GPL v1 est obsolète comme le logiciel :o


---------------
Astres, outil de help-desk GPL : http://sourceforge.net/projects/astres, ICARE, gestion de conf : http://sourceforge.net/projects/icare, Outil Planeta Calandreta : https://framalibre.org/content/planeta-calandreta
mood
Publicité
Posté le 24-04-2023 à 15:30:01  profilanswer
 

n°2446758
Harkonnen
Un modo pour les bannir tous
Posté le 20-05-2023 à 15:02:59  profilanswer
 


Je ne roule pas au GPL, ton soft n'est pas pour moi :/


---------------
J'ai un string dans l'array (Paris Hilton)
n°2448511
Harkonnen
Un modo pour les bannir tous
Posté le 12-06-2023 à 16:18:21  profilanswer
 

c'était une blague, laisse couler...


---------------
J'ai un string dans l'array (Paris Hilton)
n°2483509
lady287
La lumière fuse
Posté le 02-11-2024 à 20:20:11  profilanswer
 

Bonsoir.
 
Si ça vous interresse, j'ai un code qui fais ça avec Ada.
 
Ca cherche le premier nom et ça lui colle tous les adjectifs.
 

Loading : Lexique383.tsv
 142673
Voici le décompte du lexique français :  
 48277 noms ;
 64929 verbes ;
 27002 adjectifs ;
 1841 adverbes ;
 88 auxiliaires ;
 35 conjonctions ;
 80 prepositions ;
 171 pronoms ;
 236 onomatopés ;
 0 sans genre ;
 142673Done
Ok !Begin...
word : je : PRO Ok !
word : suis : VER Ok !
word : un : PRO Ok !
word : homme : NOM Ok !
 
Line : le ciel est bleu.
word : le : PRO Ok !
word : ciel : NOM Ok !
word : est : NOM Ok !
word : bleu : ADJ Ok !
 suis
 un
 homme
 le
 ciel
 est bleu
 
 
Line : je suis un homme blanc.
word : je : PRO Ok !
word : suis : VER Ok !
word : un : PRO Ok !
word : homme : NOM Ok !
word : blanc : ADJ Ok !
 suis
 un
 homme
 le
 ciel
 est bleu
 je
 suis
 un
 homme blanc
 
 
Line : je mange une pomme rouge.
word : je : PRO Ok !
word : mange : VER Ok !
word : une : PRO Ok !
word : pomme : NOM Ok !
word : rouge : ADJ Ok !
 suis
 un
 homme
 le
 ciel
 est bleu
 je
 suis
 un
 homme blanc
 je
 mange
 une
 pomme rouge
 
 
Line :  
homme bleu blanc rouge
 
Line : je suis un homme intelligent.
word : je : PRO Ok !
word : suis : VER Ok !
word : un : PRO Ok !
word : homme : NOM Ok !
word : intelligent : ADJ Ok !
homme bleu blanc rouge suis
 un
 homme intelligent
 
 
Line :  
homme bleu blanc rouge intelligent suis
 un
 homme intelligent
 
 
Line :


Message édité par lady287 le 02-11-2024 à 20:22:54
n°2484328
lady287
La lumière fuse
Posté le 12-11-2024 à 18:36:27  profilanswer
 

Bonjour,
 
Vous aimerez peut-être jouer avec.
 
Le jeu consiste à trouver le nom du programme.
 
Il s'agit d'un programme Ada/Prolog dont le but est de sortir du programme en fournissant le bon nom.
 
Le script originel Prolog : nommé "main.pl"
 

Code :
  1. name(main).
  2. is_name(V) :-
  3. name(V), !,
  4. write('Eureka')
  5. ; write('false'),
  6. open('./error.txt', write, Stream),
  7. close(Stream).


 
Le script permettra à Swi-Prolog d'écrire "false" si le nom fourni n'est pas celui attendu puis d'écrire un ficher "error.txt" qui sera effcaer par le program Ada ou d'afficher Eureka si le nom est celui attendu.
 
Le programme Ada est le suivant : nommé main.adb, il est un peu long parce qu'on regénaire un ficher source... Pour le fun.
 

Code :
  1. with Ada.Text_Io;
  2. use Ada;
  3. with System.Os_Lib;
  4. use System;
  5. with Ada.Characters.Handling;
  6. use Ada.Characters;
  7. with Ada.Command_Line;
  8. use Ada.Command_Line;
  9. with Ada.Directories;
  10. use Ada.Directories;
  11. procedure Main is
  12.  
  13.   function System(Cmd : in String) return Integer;
  14.   pragma Import(C, System, "system" );
  15.   Errno : Integer := 0;
  16.  
  17.   Verax : Boolean := False;
  18.   Args   : Os_Lib.Argument_List_Access := new Os_Lib.Argument_List(1..0);
  19.   Pid    : Os_Lib.Process_Id;
  20.   Prolog : Text_Io.File_Type;
  21.   Ada    : Text_Io.File_Type;
  22. begin
  23.  
  24.   Text_Io.Put("Name : " );
  25.   declare
  26.      Name : String := Text_Io.Get_Line;
  27.   begin
  28.      
  29.      Name := Handling.To_Lower(Name);
  30.      
  31.      Errno := System("echo is_name\(" & Name & "\). | /usr/bin/swipl -q -f " & Base_Name(Command_Name) & ".pl" & Character'Val(0));
  32.  
  33.      if Os_Lib.Is_Regular_File("./error.txt" ) then
  34.  
  35.         Os_Lib.Delete_file("./error.txt", Verax);
  36.         Text_Io.Create(Prolog, Text_Io.Out_File, Name & ".pl" );
  37.         Text_Io.Put_Line(Prolog, "name(" & Name & " )." );
  38.         Text_Io.Put_Line(Prolog, "is_name(V) :-" );
  39.         Text_Io.Put_Line(Prolog, " name(V), !," );
  40.         Text_Io.Put_Line(Prolog, " write('Eureka')" );
  41.         Text_Io.Put_Line(Prolog, "; write('false')," );
  42.         Text_Io.Put_Line(Prolog, "open('./error.txt', write, Stream)," );
  43.         Text_Io.Put_Line(Prolog, "close(Stream)." );
  44.         Text_Io.Close(Prolog);
  45.        
  46.         Errno := System("ln -s main bin/" & Name & Character'Val(0));
  47.         if Errno = 0 then
  48.            Text_Io.Create(Ada, Text_Io.Out_File, Name & ".adb" );
  49.  
  50.            
  51.            Text_Io.Put_line(Ada, "with Ada.Text_Io;" );
  52.            Text_Io.Put_line(Ada, "use Ada;" );
  53.            Text_Io.Put_line(Ada, "with System.Os_Lib;" );
  54.            Text_Io.Put_line(Ada, "use System;" );
  55.            Text_Io.Put_line(Ada, "with Ada.Characters.Handling;" );
  56.            Text_Io.Put_line(Ada, "use Ada.Characters;" );
  57.            Text_Io.Put_line(Ada, "with Ada.Command_Line;" );
  58.            Text_Io.Put_line(Ada, "use Ada.Command_Line;" );
  59.            Text_Io.Put_line(Ada, "with Ada.Directories;" );
  60.            Text_Io.Put_line(Ada, "use Ada.Directories;" );
  61.            
  62.            Text_Io.Put_line(Ada, "procedure " & Name & " is" );
  63.            Text_Io.New_Line(Ada);
  64.            Text_Io.Put_Line(Ada, "   function System(Cmd : in String) return Integer;" );
  65.            Text_Io.Put_Line(Ada, "   pragma Import(C, System, ""system"" );" );
  66.            Text_Io.Put_Line(Ada, "   Errno : Integer := 0;" );
  67.            Text_Io.Put_Line(Ada, "   Verax : Boolean := False;" );  
  68.            Text_Io.Put_Line(Ada, "   Args   : Os_Lib.Argument_List_Access;" );
  69.            Text_Io.Put_Line(Ada, "   Pid    : Os_Lib.Process_Id;" );
  70.            Text_Io.Put_Line(Ada, "   Prolog : Text_Io.File_Type;" );
  71.            Text_Io.Put_Line(Ada, "   Ada    : Text_Io.File_Type;" );
  72.            Text_Io.Put_Line(Ada, "begin" );
  73.            Text_Io.New_Line(Ada);
  74.            Text_Io.Put_Line(Ada, "   Text_Io.Put(""Name : "" );" );
  75.            Text_Io.Put_Line(Ada, "   declare" );
  76.            Text_Io.Put_Line(Ada, "      Name : String := Text_Io.Get_Line;" );
  77.            Text_Io.Put_Line(Ada, "   begin" );
  78.            Text_Io.New_Line(Ada);
  79.            Text_Io.Put_Line(Ada, "      Name := Handling.To_Lower(Name);" );
  80.            Text_Io.Put_Line(Ada, "      Errno := System(""echo is_name\("" & Name & ""\). | /usr/bin/swipl -q -f "" & Base_Name(Command_Name) & "".pl"" & Character'Val(0));" );
  81.            Text_Io.Put_Line(Ada, "      if Errno /= 0 then" );
  82.            Text_Io.Put_Line(Ada, "         Text_Io.Create(Prolog, Text_Io.Out_File, Name & "".pl"" );" );
  83.            Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""name("" & Name & "" )."" );" );
  84.            Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""is_name(V) :-"" );" );
  85.            Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, "" name(V), !,"" );" );
  86.            Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, "" write('Eureka')"" );" );
  87.            Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""; write('false'),"" );" );
  88.            Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""open('./error.txt', write, Stream),"" );" );
  89.            Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""close(Stream)."" );" );
  90.            Text_Io.Put_Line(Ada, "         Text_Io.Close(Prolog);" );
  91.            Text_Io.Put_Line(Ada, "         Errno := System(""ln -s main bin/"" & Name & Character'Val(0));" );
  92.            Text_Io.Put_Line(Ada, "         pid := Os_Lib.Non_Blocking_Spawn(""./bin/"" & Name, Args.all);" );
  93.            Text_Io.Put_Line(Ada, "      end if;" );Errno := System("ln -s main bin/" & Name & Character'Val(0));
  94.            Text_Io.Put_Line(Ada, "   end;" );
  95.            Text_Io.Put_Line(Ada, "end " & Name & ";" );
  96.  
  97.            Text_Io.Close(Ada);
  98.  
  99.            Os_Lib.Spawn("./bin/" & Name, Args.all, verax);
  100.            
  101.         else
  102.            Text_Io.Put("Faillure" );
  103.         end if;
  104.      end if;
  105.  
  106.   end;
  107. exception
  108.   when Text_Io.End_Error =>
  109.      Text_Io.Put_Line("bye!" );
  110. end Main;


 
Ce programme est à compiler pour produire un exécutable qui faudra placer dans le répertoire "$HOME/bin".
 
Celui ci appelle Swi-Prolog avec à l'origine le fichier main.pl en argument puis, si un fichier "error.txt" est présent, regénaire un fichier source, donc ; Et crée un lien sur "bin/main" avec le nom fourni puis appelle le programme main en utilisant le lien nouvellement créé ; Si non termine normalement.
 
 
Test :

XTERM:  9.5%: 18:17:52: 0.00$ main            
Name : Manuel
false
true.
 
 
Name : Manuel
Eureka
true.
 
 
 
 


Message édité par lady287 le 12-11-2024 à 19:19:13
n°2484458
lady287
La lumière fuse
Posté le 13-11-2024 à 19:19:49  profilanswer
 

Bonjour,
 
J'ai trouvé une amélioration à apporter qui donne le résultat voulu en fait.
 
Il faudrait modifier le fichier main.adb en conséquence.
 

Code :
  1. name(main).
  2. is_name(V) :-
  3. name(V), !,
  4. write('Eureka')
  5. ; open('./error.txt', write, Stream),
  6.     close(Stream),
  7.     name(V), !,
  8.     write('').


 
Test :

XTERM: 17.8%: 18:19:18: 0.00$ main            
Name : Manuel
false.
 
 
Name : Manuel
Eureka
true.
 
 
 
 

n°2503512
lady287
La lumière fuse
Posté le 21-07-2025 à 20:52:01  profilanswer
 

Bonjour,
 
J'ai poursuivi l'enrichissement de Skywalker en ajoutant l'agent de dialogue et un system client/serveur web dans le projet main sur sourceforge.
 
C'est évidemment un projet écrit avec Ada ; Qu'est pas pleinnement fonctionnel malgrès tout mais ça fait un peu de taf quand même.
 
La doc est incluse dans le paquet d'archive des sources, c'est au nom de prehander.


---------------
jovalise (C) 2002 Manuel De Girardi ; web site
n°2503818
lady287
La lumière fuse
Posté le 27-07-2025 à 14:54:08  profilanswer
 

Bonjour !
 
Je regrète de ne pas avoir eu la présence d'esprit de vous indiquer le nom du projet faisant suite à Skywalker.
 
Comme je suis là ponctuellement pour vous faire pare de l'évolution du projet nommé "main" se trouvant à présent en version 0.6.1r je vous anonce l'implementation de ces derniers jour.
 
En supplement des modes de Skywalker vous trouverez les modes suivants :
 
Maj+F4 : un menu pour gérer le serveur web et une fonction "search" dont l'usage de la touche Entree" menne lors de recherche fructueuse à l'ouverture de la page trouvée avec lynx ; Alors que la recherche commence la localhost ; Les top domaine ciblés sont fr us ca net ; J'en oublie peut - être.
 
Maj+F2 : Projet en cours de développement visant à construire automatiquement une page de documentation ; Bien que la fabrication de cette page pourrait être assuré de manière semi automatique.
 
Maj+F6 : un jeu à l'image d'un guerre des étaloiles.
 
have a nice day.


Message édité par lady287 le 27-07-2025 à 14:55:32

---------------
jovalise (C) 2002 Manuel De Girardi ; web site
n°2503976
lady287
La lumière fuse
Posté le 29-07-2025 à 17:55:49  profilanswer
 

Bonjour !
J'avais oublié de vous indiquer une commande supplémentaire dans le mode Engine en cours de développement.
En effet ; La commande "load" permet de charger une documentation.
Bienq que récemment la distribution Debian 10 ai été abandonné ; Vous pouver abandonné la recherche web implémenté ici grâce à la bibliothèque AWS laquelle est aujourd'huit assuré par une suite de paquet dont j'ignore les contraintes.
 
Pour ce mode Engine, vous pouvez créer un programme objet "program" dans un premier temps grâce à la commande "make program" ; Ce qui devrait afficher l'ensemble des objets implémentés que vous pouver ajouter grâce à la commande make.


---------------
jovalise (C) 2002 Manuel De Girardi ; web site
n°2517488
mockfella
Posté le 10-02-2026 à 17:40:38  profilanswer
 

[:cerveau drapal]


---------------
quand on a un pied dans le passé et l'autre dans le futur, on chie sur le présent...
mood
Publicité
Posté le 10-02-2026 à 17:40:38  profilanswer
 

n°2517521
Harkonnen
Un modo pour les bannir tous
Posté le 10-02-2026 à 22:56:08  profilanswer
 


T'es nouveau ici toi, hein ? :D


---------------
J'ai un string dans l'array (Paris Hilton)
n°2517522
mockfella
Posté le 10-02-2026 à 23:19:02  profilanswer
 

Harkonnen a écrit :


T'es nouveau ici toi, hein ? :D


Alors en fait c'est un simple concours de circonstance :o

 

J'étais à la recherche d'un topoc sur Rust et je suis tombé sur ce fil Ada.
Étant donné que j'ai pas loin de 17 ans d'expérience sur ce merveilleux langage, et que ce n'est tout de même pas si courant (téma la gueule de l'euphémisme), je me suis dit que ça ne coûtait rien de drapaliser si des fois je pouvais à l'avenir répondre à la question d'une brebis égarée :o


Message édité par mockfella le 10-02-2026 à 23:19:17

---------------
quand on a un pied dans le passé et l'autre dans le futur, on chie sur le présent...
n°2517523
TotalRecal​l
Posté le 10-02-2026 à 23:22:18  profilanswer
 

Jovalise est très très égaré, ça tombe bien :o
Par contre on ne sait pas quand il reviendra ni sous quel nom, c'est toujours une surprise. Faut attendre, il revient toujours :o


---------------
Topic .Net - C# @ Prog
n°2517590
slr56
Tout problème a sa solution.
Posté le 11-02-2026 à 15:58:38  profilanswer
 

TotalRecall a écrit :

Jovalise est très très égaré, ça tombe bien :o
Par contre on ne sait pas quand il reviendra ni sous quel nom, c'est toujours une surprise. Faut attendre, il revient toujours :o

 

HFR sans Jovalise... ça manque de piquant  :D


Message édité par slr56 le 11-02-2026 à 15:59:00

---------------
Configurations type du moment : https://forum.hardware.fr/hfr/Hardw [...] 1331_1.htm  https://www.jouannetphotographe.com
n°2517789
rufo
Pas me confondre avec Lycos!
Posté le 15-02-2026 à 11:43:07  profilanswer
 

Oui, il apporte un petit grain de folie.  :whistle:
 
mockfella, je t'invite à prendre connaissance des autres topics de Jovaliseet ses multis (y'en a beaucoup, localghost, faston, par l'anneau de l'ia, lady287...)

Message cité 1 fois
Message édité par rufo le 15-02-2026 à 11:47:07

---------------
Astres, outil de help-desk GPL : http://sourceforge.net/projects/astres, ICARE, gestion de conf : http://sourceforge.net/projects/icare, Outil Planeta Calandreta : https://framalibre.org/content/planeta-calandreta
n°2517790
mockfella
Posté le 15-02-2026 à 12:21:21  profilanswer
 

Oké

 

Ça partait d'un bon sentiment, mais je vais pas trainer ici :o


---------------
quand on a un pied dans le passé et l'autre dans le futur, on chie sur le présent...
n°2517791
TotalRecal​l
Posté le 15-02-2026 à 12:52:57  profilanswer
 

rufo a écrit :

Oui, il apporte un petit grain de folie.  :whistle:

 

mockfella, je t'invite à prendre connaissance des autres topics de Jovaliseet ses multis (y'en a beaucoup, localghost, faston, par l'anneau de l'ia, lady287...)


Malheureusement il en a fait mass delete la moitié, une perte terrible pour le patrimoine Ada français :(
C'est aussi pour ça qu'on est nombreux à ne même plus tenter de lui répondre quand on sent qu'on pourrait lui faire des suggestions, si c'est pour que les topics disparaissent peu après aucun intéret...

Message cité 1 fois
Message édité par TotalRecall le 15-02-2026 à 12:54:03

---------------
Topic .Net - C# @ Prog
n°2517799
slr56
Tout problème a sa solution.
Posté le 16-02-2026 à 10:38:29  profilanswer
 

TotalRecall a écrit :


Malheureusement il en a fait mass delete la moitié, une perte terrible pour le patrimoine Ada français :(
C'est aussi pour ça qu'on est nombreux à ne même plus tenter de lui répondre quand on sent qu'on pourrait lui faire des suggestions, si c'est pour que les topics disparaissent peu après aucun intéret...

 

Ils sont sûrement plusieurs dans sa tête. Son raisonnement est délirant... Quand je vois les commentaires rationnels ET logiques que vous lui faites toi et Rufo... et qu'en retour lui, il fait des réponses lunaires voire jupitériennes... Vous êtes très courageux de lui répondre. Vous méritez la légion d'honneur pour services rendus à la Nation :pt1cable:


Message édité par slr56 le 16-02-2026 à 10:39:16

---------------
Configurations type du moment : https://forum.hardware.fr/hfr/Hardw [...] 1331_1.htm  https://www.jouannetphotographe.com
n°2518592
antac
..
Posté le 23-02-2026 à 11:04:10  profilanswer
 

C'est vrai que c'est systématiquement débile mais toujours inattendu.

n°2518593
rufo
Pas me confondre avec Lycos!
Posté le 23-02-2026 à 11:25:03  profilanswer
 

Jovalise serait Perceval ?  :ouch:


---------------
Astres, outil de help-desk GPL : http://sourceforge.net/projects/astres, ICARE, gestion de conf : http://sourceforge.net/projects/icare, Outil Planeta Calandreta : https://framalibre.org/content/planeta-calandreta
n°2518683
lady287
La lumière fuse
Posté le 24-02-2026 à 18:24:33  profilanswer
 

Je rappelle que les sources de skywalker sont sur inconito.net.
C'est le site web de jovalise.
En cas de panne, je restaure.
Si le problème persiste, c'est que les trolls sont allés loingt.
Moi, c'est l'oinc.
Bisou.


---------------
jovalise (C) 2002 Manuel De Girardi ; web site
n°2518696
TotalRecal​l
Posté le 24-02-2026 à 22:54:38  profilanswer
 

lady287 a écrit :

Je rappelle que les sources de skywalker sont sur inconito.net.
C'est le site web de jovalise.
En cas de panne, je restaure.
Si le problème persiste, c'est que les trolls sont allés loingt.
Moi, c'est l'oinc.
Bisou.


Il est parmi nous [:shimay:1]
Bon retour :o

 

edit : je pense qu'on te l'avait déjà suggéré mais tu pourrais te faire un github avec tes sources. C'est gratuit, bien visible, ça permet de bien organiser, et aucun risque de perte...


Message édité par TotalRecall le 24-02-2026 à 22:56:12

---------------
Topic .Net - C# @ Prog
n°2518698
rufo
Pas me confondre avec Lycos!
Posté le 25-02-2026 à 08:51:21  profilanswer
 

Github n'est pas codé en Ada, donc no way pour Jovalise :o


---------------
Astres, outil de help-desk GPL : http://sourceforge.net/projects/astres, ICARE, gestion de conf : http://sourceforge.net/projects/icare, Outil Planeta Calandreta : https://framalibre.org/content/planeta-calandreta
n°2518768
slr56
Tout problème a sa solution.
Posté le 26-02-2026 à 10:36:31  profilanswer
 

rufo a écrit :

Github n'est pas codé en Ada, donc no way pour Jovalise :o


 [:rofl]


Message édité par slr56 le 26-02-2026 à 10:36:49

---------------
Configurations type du moment : https://forum.hardware.fr/hfr/Hardw [...] 1331_1.htm  https://www.jouannetphotographe.com
n°2519128
lady287
La lumière fuse
Posté le 02-03-2026 à 20:01:12  profilanswer
 

Bonjour,
J'ai posté dernièrement, une implémentation défaillante d'un algorithme de recherche de chemin pour lequel il est nécessaire de véillé à la priorité des élément.
Non seulement l'implémentation évoquée contenait un boucle inutile pour procéder à une simple évaluation ; De plus, le programme que j'avais publié utilisait un liste doublement chaînée avec laquelle un simple tri est possible selon l'implémentation fourni avec Ada.Containers.Doubly_Linked_List.


---------------
jovalise (C) 2002 Manuel De Girardi ; web site
n°2520135
lady287
La lumière fuse
Posté le 15-03-2026 à 12:33:12  profilanswer
 

Bonjour,
 
Petit "week end" profitable durant lequel j'ai enfin trouvé l'algo convenant pour utiliser un temps soit peu normalement la procedure spawn attendant éventuellement un nom de fichier ou dercripteur de ficher dans lequel serait dirigé la sortie du programme et encore éventuellement, la sortie d'erreur.
 
Voici un ensemble le résultat d'une recherche resté en suspend durant des années dans lequel j'ai ajouté une condition pour afficher "true." ; Chaîne de sortie de Prolog en blanc éclairci, ici dans une fenêtre produite grâce au paquetage de Hibou.
 
 
Edit : Il manquait dans la tache File_Thread une variable telle que Only_One de type booléene pour sortir avec un exit when de la seconde boucle lorsque cette variable est positinnée à True par les entrées de Page_Up, ... dans la boocle d'attente débutant la tache ; Et laquelle doit être remise à False dans le accept Strat.
 

Code :
  1. task File_Thread is
  2.      entry Page_Down;
  3.      entry Page_Up;
  4.      entry Up_Arrow;
  5.      entry Down_Arrow;
  6.      entry Start;
  7.      entry Reset;
  8.      entry Release;
  9.      entry Halt;
  10. end File_Thread;
  11. task body File_Thread is
  12.      Line_Count  : Natural := 0;
  13.      Count : Natural := 0;
  14.      Line_Index  : Natural := 1;
  15.      File : File_Type;
  16.      Free : Boolean := False;
  17.      begin
  18.     Main_Loop :
  19.      loop
  20.         loop
  21.            select
  22.           accept Page_Down do
  23.  
  24.              Line_Index := 1;
  25.             
  26.              Line_count := Line_count + App.Cmd_Result.Win.H/2;
  27.              Draw_Window(App.Cmd_Result.Win);
  28.           end Page_Down;
  29.           exit;
  30.            or
  31.           accept Page_Up do
  32.             
  33.              Line_Index := 1;
  34.              if Line_count - App.Cmd_Result.Win.H/2 >= 0 then
  35.             Line_count := Line_count - App.Cmd_Result.Win.H/2;
  36.              end if;
  37.              Draw_Window(App.Cmd_Result.Win);
  38.           end Page_Up;
  39.           exit;
  40.            or
  41.           accept Up_Arrow do
  42.  
  43.              Line_Index := 1;
  44.              if Line_Count - 1 >= 0 then
  45.             Line_count := Line_count - 1;
  46.              end if;
  47.              Draw_Window(App.Cmd_Result.Win);
  48.           end Up_Arrow;
  49.           exit;
  50.            or
  51.           accept Down_Arrow do
  52.  
  53.              Line_Index := 1;
  54.             
  55.              Line_count := Line_count + 1;
  56.              Draw_Window(App.Cmd_Result.Win);
  57.           end Down_Arrow;
  58.           exit;
  59.            or
  60.           accept Start;
  61.           exit;
  62.            or
  63.           accept Halt;
  64.           exit Main_Loop;
  65.            or
  66.           accept Reset do
  67.              Line_Index := 1;
  68.              Line_Count := 0;
  69.           end Reset;
  70.            or
  71.           accept Release do
  72.              Free := True;
  73.           end Release;
  74.            end Select;
  75.         end loop;
  76.         
  77.         loop
  78.  
  79.            Open(File, In_File, ".Out" );
  80.           
  81.            while not End_Of_File(File) loop
  82.  
  83.           declare
  84.              Line : String := Get_Line(File);
  85.              Pro_Index : Natural := Fixed.Index(Line, "true." );
  86.              Next : Natural := 0;
  87.           begin
  88.              if Pro_Index /= 0 then
  89.             if Line'Length >= Pro_Index + 4 then
  90.               
  91.                Next := Pro_Index + 4;
  92.             end if;
  93.              end if;
  94.              Count := Count + 1;            
  95.              if Count > Line_Count then
  96.             if Next /= 0 then
  97.                Draw_Text(App.Cmd_Result.win, Line_Index, 1, White, Handling.To_Wide_String(Line(Line'First..Pro_Index-1)));
  98.                Enlight_Draw_Text(App.Cmd_Result.win, Line_Index, Pro_Index, White, Handling.To_Wide_String(Line(Pro_Index..Next)));
  99.                if Line'Length > Next then
  100.                   Draw_Text(App.Cmd_Result.win, Line_Index, Pro_Index+5, White, Handling.To_Wide_String(Line(Next+1..Line'Last)));
  101.                end if;
  102.             else
  103.                Draw_Text(App.Cmd_Result.win, Line_Index, 1, White, Handling.To_Wide_String(Line));
  104.             end if;
  105.             Line_Index := Line_Index + 1;
  106.              end if;
  107.             
  108.             
  109.           end;    
  110.           exit when Line_Index > App.Cmd_Result.Win.H-2;
  111.            end loop;
  112.           
  113.            Close(File);
  114.           
  115.           
  116.            delay 0.1;
  117.            if not Free then
  118.           if count > Line_Count then
  119.              Line_Count := Count;
  120.           end if;
  121.            else
  122.           Line_Index := 1;
  123.            end if;
  124.            select
  125.           accept Reset do
  126.              Line_Index := 1;
  127.              Line_Count := 0;
  128.           end Reset;
  129.           exit;
  130.            or
  131.           accept Page_Down do
  132.  
  133.              Line_Index := 1;
  134.             
  135.              Line_count := Line_count + App.Cmd_Result.Win.H/2;
  136.  
  137.              Draw_Window(App.Cmd_Result.Win);
  138.  
  139.           end Page_Down;
  140.  
  141.            or
  142.           accept Page_Up do
  143.  
  144.              Line_Index := 1;
  145.              if Line_count - App.Cmd_Result.Win.H/2 >= 0 then
  146.             Line_count := Line_count - App.Cmd_Result.Win.H/2;
  147.  
  148.             Draw_Window(App.Cmd_Result.Win);
  149.  
  150.              end if;
  151.  
  152.             
  153.           end Page_Up;
  154.  
  155.            or
  156.           accept Up_Arrow do
  157.  
  158.              Line_Index := 1;
  159.              if Line_Count - 1 >= 0 then
  160.             Line_count := Line_count - 1;
  161.  
  162.             Draw_Window(App.Cmd_Result.Win);
  163.  
  164.              end if;
  165.  
  166.             
  167.           end Up_Arrow;
  168.  
  169.            or
  170.           accept Down_Arrow do
  171.  
  172.              Line_Index := 1;
  173.             
  174.              Line_count := Line_count + 1;
  175.  
  176.              Draw_Window(App.Cmd_Result.Win);
  177.  
  178.           end Down_Arrow;
  179.            or
  180.           
  181.           accept Release do
  182.              Free := True;
  183.           end Release;
  184.  
  185.            or
  186.           accept Halt;
  187.           exit Main_Loop;
  188.  
  189.            or
  190.           delay 0.05;
  191.            end select;
  192.           
  193.            Count := 0;
  194.           
  195.         end loop;
  196.         
  197.      end loop Main_Loop;
  198.      end File_Thread;
  199.      
  200.      
  201.      task type Exec_Thread (Cmd_Line : String_Access;Result : Result_Access) is
  202.      entry Spawn;
  203.      entry Wait(Success : out Boolean;Errno : out Integer);
  204.      entry Read_Line;
  205.      entry Halt;
  206. end Exec_Thread;
  207.      
  208. task body Exec_Thread is
  209.  
  210.      Success : Boolean := False;
  211.      Errno : Integer := 0;
  212.      PID   : Os_Lib.Process_ID;
  213.     
  214.      begin
  215.      accept Spawn do
  216.         if not (Command_Name(Cmd_line.all)'Length = Cmd_line'Length) then
  217.           
  218.            null;
  219.           
  220.         end if;
  221.         
  222.      end Spawn;          
  223.     
  224.     
  225.      if Command_Name(Cmd_Line.all)'Length = Cmd_Line'Length then
  226.         
  227.         if not Os_Lib."="(Os_Lib.Locate_Exec_On_Path(Cmd_Line.all), null) then
  228.           
  229.            declare
  230.           Args : constant Os_Lib.Argument_List_Access := Os_Lib.Argument_String_To_List
  231.             ("-c """ & Os_Lib.Locate_Exec_On_Path(Cmd_Line.all).all & """" );
  232.            begin
  233.           Os_Lib.Normalize_Arguments(Args.all);
  234.           
  235.           PID := Os_Lib.Non_Blocking_Spawn("/usr/bin/sh", Args.all, ".Out", Success);
  236.           
  237.            end;
  238.         end if;
  239.      else
  240.         
  241.         declare
  242.            Args : constant Os_Lib.Argument_List_Access := Os_Lib.Argument_String_To_List
  243.          (Os_Lib.Locate_Exec_On_Path(Command_Name(Cmd_Line.all)).all & " " &
  244.             Cmd_Line(Command_Name(Cmd_Line.all)'Length+2..Cmd_Line'Last));
  245.  
  246.         begin
  247.           
  248.            Os_Lib.Normalize_Arguments(Args.all);
  249.           
  250.            PID := Os_Lib.Non_Blocking_Spawn(Os_Lib.Locate_Exec_On_Path(Args(1).all).all, Args(2..Args'Last), ".Out", Success);
  251.           
  252.         end;
  253.      end if;
  254.     
  255.     
  256.      Os_Lib.Wait_Process(PID, Success);
  257.      File_Thread.Release;
  258.      loop
  259.         select
  260.            accept Wait(Success : out Boolean;Errno : out Integer) do
  261.           if Errno = 0 then
  262.              Success := True;
  263.           end if;
  264.           Errno := Exec_Thread.Errno;
  265.            end Wait;
  266.         or
  267.            accept Read_Line;
  268.         or
  269.            accept Halt do
  270.           File_Thread.Reset;
  271.            end Halt;
  272.           
  273.            exit;
  274.         end select;
  275.      end loop;
  276. end Exec_Thread;


Message édité par lady287 le 16-03-2026 à 07:36:28

---------------
jovalise (C) 2002 Manuel De Girardi ; web site
n°2520159
lady287
La lumière fuse
Posté le 15-03-2026 à 16:13:15  profilanswer
 

Bonjour !
Ou Re- !
 
 
Voici la variante avec l'utilisation de Get_Immediate pour saisir le nom attendu devant être saisi comme exposé plus haut dans le programme appellant Swi-Prolog.
La nuance permet sont utlisation dans un process tel que celui présenté dans le message précédent.
 
Le principe est le même...
Vous devez fourir le nom du programme.
 

Code :
  1. with Ada.Text_Io;
  2. use Ada;
  3. with System.Os_Lib;
  4. use System;
  5. with Ada.Characters.Handling;
  6. use Ada.Characters;
  7. with Ada.Command_Line;
  8. use Ada.Command_Line;
  9. with Ada.Directories;
  10. use Ada.Directories;
  11. procedure Main is
  12.  
  13.   function System(Cmd : in String) return Integer;
  14.   pragma Import(C, System, "system" );
  15.   Errno : Integer := 0;
  16.  
  17.   Verax : Boolean := False;
  18.   Args   : Os_Lib.Argument_List_Access := new Os_Lib.Argument_List(1..0);
  19.   Pid    : Os_Lib.Process_Id;
  20.   Prolog : Text_Io.File_Type;
  21.   Ada    : Text_Io.File_Type;
  22.   File   : Text_Io.File_Type;
  23. begin
  24.   --Text_Io.Open(File, Text_Io.Out_File, .all);
  25.   Text_Io.Put("Name : " );
  26.   declare
  27.      Name : String(1..32) := (others => Character'Val(32));
  28.      Top : Positive := 1;
  29.      Available : Boolean := False;
  30.      The_Char : Character := ' ';
  31.   begin
  32.      Get_Name :
  33.      loop
  34.      begin
  35.         for Char in Top .. Name'last loop
  36.           
  37.           
  38.            Text_Io.Get_immediate(Name(Char));
  39.            case Name(Char) is
  40.           when Character'Val(10) | Character'Val(13) =>
  41.              Name(Char) := Character'Val(32);
  42.              exit Get_Name;
  43.           when Character'Val(127) | Character'Val(8) =>
  44.              if Top > 1 then
  45.             Name(Top) := Character'Val(32);
  46.             Name(Top - 1) := Character'Val(32);            
  47.             Text_Io.Put(Character'Val(13) & "Name : " & Name(1..Top-1) & Character'Val(8));
  48.             Top := Top - 1;
  49.             exit;
  50.              end if;
  51.           when others =>
  52.  
  53.              Text_Io.Put(Text_Io.Standard_Error, Name(Char));
  54.              --Text_Io.Put(Char);
  55.              Top := Top + 1;
  56.            end case;
  57.         end loop;
  58.         
  59.      exception
  60.         when Text_Io.End_Error =>
  61.            null;
  62.      end;
  63.      end loop Get_name;
  64.      Text_Io.Put_line(Character'Val(13) & "Name : " & Name(1..Top-1));
  65.      Name := Handling.To_Lower(Name);
  66.      
  67.      Errno := System("echo is_name\(" & Name(Name'First..Top-1) & "\). | /usr/bin/swipl -q -f " &
  68.             Base_Name(Command_Name) & ".pl" & Character'Val(0));
  69.  
  70.      if Os_Lib.Is_Regular_File("./error.txt" ) then
  71.  
  72.      Os_Lib.Delete_file("./error.txt", Verax);
  73.      Text_Io.Create(Prolog, Text_Io.Out_File, Name(Name'First..Top-1) & ".pl" );
  74.      Text_Io.Put_Line(Prolog, "name(" & Name(Name'First..Top-1) & " )." );
  75.      Text_Io.Put_Line(Prolog, "is_name(V) :-" );
  76.      Text_Io.Put_Line(Prolog, " name(V), !," );
  77.      Text_Io.Put_Line(Prolog, " write('Eureka')" );
  78.      Text_Io.Put_Line(Prolog, "; open('./error.txt', write, Stream)," );
  79.      Text_Io.Put_Line(Prolog, "close(Stream)," );
  80.      Text_Io.Put_Line(Prolog, "name(V), !," );
  81.      Text_Io.Put_Line(Prolog, "write('')." );
  82.      Text_Io.Close(Prolog);
  83.     
  84.      Errno := System("ln -s ../main bin/" & Name(Name'First..Top-1) & Character'Val(0));
  85.  
  86.      if Errno = 0 then
  87.         Text_Io.Create(Ada, Text_Io.Out_File, Name(Name'First..Top-1) & ".adb" );
  88.  
  89.         
  90.         Text_Io.Put_line(Ada, "with Ada.Text_Io;" );
  91.         Text_Io.Put_line(Ada, "use Ada;" );
  92.         Text_Io.Put_line(Ada, "with System.Os_Lib;" );
  93.         Text_Io.Put_line(Ada, "use System;" );
  94.         Text_Io.Put_line(Ada, "with Ada.Characters.Handling;" );
  95.         Text_Io.Put_line(Ada, "use Ada.Characters;" );
  96.         Text_Io.Put_line(Ada, "with Ada.Command_Line;" );
  97.         Text_Io.Put_line(Ada, "use Ada.Command_Line;" );
  98.         Text_Io.Put_line(Ada, "with Ada.Directories;" );
  99.         Text_Io.Put_line(Ada, "use Ada.Directories;" );
  100.         
  101.         Text_Io.Put_line(Ada, "procedure " & Name(Name'First..Top-1) & " is" );
  102.         Text_Io.New_Line(Ada);
  103.         Text_Io.Put_Line(Ada, "   function System(Cmd : in String) return Integer;" );
  104.         Text_Io.Put_Line(Ada, "   pragma Import(C, System, ""system"" );" );
  105.         Text_Io.Put_Line(Ada, "   Errno : Integer := 0;" );
  106.         Text_Io.Put_Line(Ada, "   Verax : Boolean := False;" );  
  107.         Text_Io.Put_Line(Ada, "   Args   : Os_Lib.Argument_List_Access;" );
  108.         Text_Io.Put_Line(Ada, "   Pid    : Os_Lib.Process_Id;" );
  109.         Text_Io.Put_Line(Ada, "   Prolog : Text_Io.File_Type;" );
  110.         Text_Io.Put_Line(Ada, "   Ada    : Text_Io.File_Type;" );
  111.         Text_Io.Put_Line(Ada, "begin" );
  112.         Text_Io.New_Line(Ada);
  113.         Text_Io.Put_Line(Ada, "   Text_Io.Put(""Name : "" );" );
  114.         Text_Io.Put_Line(Ada, "   declare" );
  115. --        Text_Io.Put_Line(Ada, "      Name : String := Text_Io.Get_Line;" );
  116.         Text_Io.Put_Line(Ada, "  Name : String(1..32) := (others => Character'Val(32));" );
  117.         Text_Io.Put_Line(Ada, "  Top : Positive := 1;" );
  118.         Text_Io.Put_Line(Ada, "   begin" );
  119.         Text_Io.Put_Line(Ada, "        Get_Name :" );
  120.         Text_Io.Put_Line(Ada, "      loop" );
  121.         Text_Io.Put_Line(Ada, " begin" );
  122.         Text_Io.Put_Line(Ada, "    for Char in Top .. Name'last loop" );
  123.         Text_Io.Put_Line(Ada, "       Text_Io.Get_Immediate(Name(Char));" );
  124.         Text_Io.Put_Line(Ada, "       case Name(Char) is" );
  125.         Text_Io.Put_Line(Ada, "  when Character'Val(10) | Character'Val(13) =>" );
  126.         Text_Io.Put_Line(Ada, "     Name(Char) := Character'Val(32);" );
  127.         Text_Io.Put_Line(Ada, "     exit Get_Name;" );
  128.         Text_Io.Put_Line(Ada, "  when Character'Val(127) | Character'Val(8) =>" );
  129.         Text_Io.Put_Line(Ada, "     if Top > 1 then" );
  130.         Text_Io.Put_Line(Ada, "Name(Top) := Character'Val(32);" );
  131.         Text_Io.Put_Line(Ada, "Name(Top - 1) := Character'Val(32);" );
  132.         Text_Io.Put_Line(Ada, "Text_Io.Put(Character'Val(13) & ""Name : "" & Name(1..Top-1) & Character'Val(8));" );
  133.         Text_Io.Put_Line(Ada, "Top := Top - 1;" );
  134.         Text_Io.Put_Line(Ada, "exit;" );
  135.         Text_Io.Put_Line(Ada, "     end if;" );
  136.         Text_Io.Put_Line(Ada, "  when others =>" );
  137.         Text_Io.Put_Line(Ada, "     Text_Io.Put(Name(Char));" );
  138.         Text_Io.Put_Line(Ada, "     Top := Top + 1;" );
  139.         Text_Io.Put_Line(Ada, "       end case;" );
  140.         Text_Io.Put_Line(Ada, "    end loop;" );
  141.         
  142.         Text_Io.Put_Line(Ada, " exception" );
  143.         Text_Io.Put_Line(Ada, "    when Text_Io.End_Error =>" );
  144.         Text_Io.Put_Line(Ada, "       null;" );
  145.         Text_Io.Put_Line(Ada, " end;" );
  146.         Text_Io.Put_Line(Ada, "      end loop Get_name;" );
  147.         Text_Io.Put_Line(Ada, "     Text_Io.Put_line(Character'Val(13) & ""Name : "" & name);" );
  148.  
  149.         --    Text_Io.Put_Line(Ada, "   Text_Io.Put(Character'Val(13) & ""Name : "" & Name);" );
  150.         Text_Io.New_Line(Ada);
  151.         Text_Io.Put_Line(Ada, "      Name := Handling.To_Lower(Name);" );
  152.         Text_Io.Put_Line(Ada, "          Errno := System(""echo is_name\("" & Name(Name'First..Top-1) & ""\). | /usr/bin/swipl -q -f "" & " );
  153.         Text_Io.Put_Line(Ada, "Base_Name(Command_Name) & "".pl"" & Character'Val(0));" );
  154.  
  155.         --    Text_Io.Put_Line(Ada, "      Errno := System(""echo is_name\("" & Name & ""\). | /usr/bin/swipl -q -f "" & Base_Name(Command_Name) & "".pl"" & Character'Val(0));" );
  156.         Text_Io.Put_Line(Ada, "      if Errno /= 0 then" );
  157.         Text_Io.Put_Line(Ada, "         Text_Io.Create(Prolog, Text_Io.Out_File, Name & "".pl"" );" );
  158.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""name("" & Name & "" )."" );" );
  159.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""is_name(V) :-"" );" );
  160.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, "" name(V), !,"" );" );
  161.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, "" write('Eureka')"" );" );
  162.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""; open('./error.txt', write, Stream),"" );" );
  163.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""close(Stream),"" );" );
  164.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""name(V), !,"" );" );
  165.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""write('')."" );" );
  166.         Text_Io.Put_Line(Ada, "         Text_Io.Close(Prolog);" );
  167.         Text_Io.Put_Line(Ada, "         Errno := System(""ln -s ../main bin/"" & Name(Name'First..Top-1) & Character'Val(0));" );
  168.         Text_Io.Put_Line(Ada, "         pid := Os_Lib.Non_Blocking_Spawn(""./bin/"" & Name(Name'First..Top-1), Args.all);" );
  169.         Text_Io.Put_Line(Ada, "      end if;" );
  170.         Text_Io.Put_Line(Ada, "   end;" );
  171.         Text_Io.Put_Line(Ada, "end " & Name & ";" );
  172.  
  173.         Text_Io.Close(Ada);
  174.  
  175.         Os_Lib.Spawn("./bin/" & Name(Name'First..Top-1), Args.all, verax);
  176.         
  177.      else
  178.         Text_Io.Put("Faillure" );
  179.      end if;
  180.      end if;
  181.  
  182.   end;
  183. exception
  184.   when Text_Io.End_Error =>
  185.      Text_Io.Put_Line("bye!" );
  186. end Main;


 
Le script main.pl est recqui.


Message édité par lady287 le 15-03-2026 à 21:24:53

---------------
jovalise (C) 2002 Manuel De Girardi ; web site
n°2520164
lady287
La lumière fuse
Posté le 15-03-2026 à 17:23:12  profilanswer
 

Je vous fais pare d'un autre programme donnant le nom du jour correspondant au jour de votre naissance ; Et affichant des messages selon l'état correspondant à un modulo 6 dans un type énuméré et le nombre de jours écoulé depuis votre naissance.
 

Code :
  1. with Ada.Text_Io;
  2. use Ada.Text_Io;
  3. with Ada.Calendar;
  4. with Ada.Calendar.Formatting;
  5. use Ada.Calendar;
  6. with Ada.Calendar.Arithmetic;
  7. with PragmARC.Ansi_Tty_Control;
  8. use PragmARC.Ansi_Tty_Control;
  9. procedure Day_Count is
  10.  
  11.   type Week_Enum is (None, Monthday, Tusday, Wenesday, Thirday, Friday, Saturday, Sunday);
  12.   type Sem_Enum is (None, Lundi, Mardi, Mercredi, Jeudi, Vendredi, Samedi, Dimanche);
  13.   type Romain_Enum is (None, Lundi, Mardi, Mercredi, Jeudi, Vendredi, Samedi, Dimanche);
  14.  
  15.   Start_Date : Time := Time_Of(1970, 4, 20, 43200.0);
  16.   Date_Cur : Time := Clock+43200.0;
  17.  
  18.   Birthday : Time := Time_of(****, *, **, 14580.0);
  19.  
  20.   Day_Num : Arithmetic.Day_Count := 0;
  21.   sec   : Duration := 0.0;
  22.   Leaps : Arithmetic.Leap_Seconds_Count := 0;
  23.  
  24.   type Step_Enum is (Chaos, Machine, Program, Result, Manuel);
  25.  
  26.   type Cmd_Enum is (Logique, Raison, science, Hasard, Libre, Buggy);
  27.  
  28.   type Name_Enum is (Amour, Classe, Style, BCBG, Bab, Ceel, Admin);
  29.  
  30.   Step : Positive := Positive(Year(Clock)) - 665;  
  31.   Cross : Positive := 1970;
  32.   Line : Positive := 1;
  33.   Col : Positive := ;1
  34.   function System (Cmd : String) return Integer;
  35.   Errno : Integer;
  36.   pragma Import (C, System, "system" );
  37.  
  38.   task Day_Name is
  39.      entry Arrêt;      
  40.   end Day_Name;
  41.  
  42.   task body Day_Name is
  43.   begin
  44.      loop
  45.      select
  46.         accept Arrêt;
  47.         exit;
  48.      or
  49.         delay 1.0;
  50.         Date_Cur := Clock+43200.0;
  51.         --Errno := System ("clear" & Character'Val(0));
  52.         Put(Position(Line, Col) & Formatting.Image(Clock));
  53.         Line := Line + 1;
  54.         Arithmetic.Difference(Date_Cur, Start_Date, Day_Num, Sec, Leaps);
  55.         Put(Position(Line, Col) & "Day count : " & Integer'Image(Integer(Day_Num)) & " : " & Step_Enum'Image(step_Enum'Val(Integer(Day_Num) mod 5)));
  56.         Line := Line + 1;
  57.         
  58.         Put(Position(Line, Col) & "Day  : " & Week_Enum'Image(Week_Enum'Val(((Integer(Day_Num)) mod 7)+1)));
  59.         Line := Line + 1;
  60.         Put(Position(Line, Col) & "Jour : " & Sem_Enum'Image(Sem_Enum'Val(((Integer(Day_Num)) mod 7)+1)));
  61.         Line := Line + 1;
  62.         Put(Position(Line, Col) & "Dio  : " & Romain_Enum'Image(Romain_Enum'Val(((Integer(Day_Num)) mod 7)+1)));
  63.         Line := Line + 1;
  64.         
  65.         Put(Position(Line, Col) & Name_Enum'Image(Name_Enum'Val(Cross mod 6)));
  66.         
  67.         if Day(Clock) = (Day(Birthday) - 1) and Month(Clock) = Month(Birthday) then
  68.            Put(Position(Line, Col+7) & " ; Happy birthday!" );
  69.            Line := Line + 1;
  70.         elsif Day(Clock) = (Day(Birthday)) and Month(Clock) = Month(Birthday) then
  71.            Put(Position(Line, Col+7) & " ; It's happy day!" );
  72.            Line := Line + 1;
  73.         else
  74.            Put(Position(Line, Col+7) & " ; Have a nice day!" );
  75.            Line := Line + 1;
  76.         end if;
  77.         Put(Position(Line, Col) & "Commande : " );
  78.         
  79.         Put(Cmd_Enum'Image(Cmd_Enum'Val(Day(Clock) mod 5)));
  80.         Put(Position(23, 20));
  81.         Line := 1;
  82.      end select;
  83.      end loop;
  84.   end Day_Name;
  85.  
  86.   Char : Character;
  87. begin  
  88.   loop
  89.      
  90.      Get_Immediate(Char);
  91.      Day_Name.Arrêt;      
  92.      exit;
  93.   end loop;
  94. end Day_Count;


 
Ici, ma date de naissance est remplacé par des charactères '*' (asterisque).
 

Citation :

2026-03-15 16:21:54
Day count :  20418 : RESULT
Day  : SUNDAY
Jour : DIMANCHE
Dio  : DIMANCHE
STYLE   ; Have a nice day!
Commande : LOGIQUE


---------------
jovalise (C) 2002 Manuel De Girardi ; web site
n°2520167
lady287
La lumière fuse
Posté le 15-03-2026 à 17:46:19  profilanswer
 

Enfin, jje vous donne le lien d'un petit éditeur en cours d'écriture.
Il est pas penssable dans cet état d'éditer ce programme avec lui même.
L'affichage des longues ligne est incertain et tous les testes de déplacement/insersion/Remplaecement/suppresion n'ont pas été effectué.
 
Il manque la variable Alphabet : Wide_string; Et il vous faudra integrer le type tache au type Main_Interface ; Puis écrire votre saise pour obtenir les rendez vous prévus.
 
http://inconito.net/edit.adb.html est la page html
http://inconito.net/edit.adb est le lien du fichier sources.
 
Ctrl+O permet d'ouvrir un fichier existant
Ctrl+N permet d'initialiser un fichier avec l'entête de la GPL 2 avec la date et le $LOGNAME en Copyright.


---------------
jovalise (C) 2002 Manuel De Girardi ; web site
n°2520211
lady287
La lumière fuse
Posté le 15-03-2026 à 21:27:56  profilanswer
 

J'ai posté il y a une demi heure un programme main faisant un appel à Swi-Prolog, en disant qu'il s'agissait d'une variante avec Get_Immediate.
Cependant, il semble qu'il y ai eu confusion.
Je viens de reposter dans le message évoqué ce trouvant 3 message plus haut le code dédié à la solution de Spawn et fonctionnant assi bien à travers le Spawn que dans un shell tel de Bash (Bourne Again Shell).


---------------
jovalise (C) 2002 Manuel De Girardi ; web site
n°2520221
lady287
La lumière fuse
Posté le 16-03-2026 à 07:41:10  profilanswer
 

Bonjour,
 
Edit : Il manquait dans la tache File_Thread une variable telle que Only_One de type booléene pour sortir avec un exit when de la seconde boucle lorsque cette variable est positinnée à True par les entrées de Page_Up, ... dans la boocle d'attente débutant la tache ; Et laquelle doit être remise à False dans le accept Strat.
 
 
De plus ; Il semble que l'appel de spawn ne soit pas absolument efficace.
L'appel de sh devrait permettre d'obtenir un resultat pour ls commande "ls *" ou l'inverse.


---------------
jovalise (C) 2002 Manuel De Girardi ; web site
n°2520231
lady287
La lumière fuse
Posté le 16-03-2026 à 13:31:05  profilanswer
 

Petite insatisfaction relative au use case du programme main évoqué plus haut.
Etant possible d'appelle le programme dans un shell, à travers un spawn sans contrainte supplémentaire et dans un environnement a contrario exposant un ensemple de spécifications supplémentaire comme ici avec la paquetage de fenêtre de Hibou ; Le programme est adapté de manière à fonctionner dans les trois situations.
 

Code :
  1. with Ada.Text_Io;
  2. use Ada;
  3. with System.Os_Lib;
  4. use System;
  5. with Ada.Characters.Handling;
  6. use Ada.Characters;
  7. with Ada.Command_Line;
  8. use Ada.Command_Line;
  9. with Ada.Directories;
  10. use Ada.Directories;
  11. procedure Main is
  12.  
  13.   function System(Cmd : in String) return Integer;
  14.   pragma Import(C, System, "system" );
  15.   Errno : Integer := 0;
  16.  
  17.   Verax : Boolean := False;
  18.   Args   : Os_Lib.Argument_List_Access := new Os_Lib.Argument_List(1..0);
  19.   Pid    : Os_Lib.Process_Id;
  20.   Prolog : Text_Io.File_Type;
  21.   Ada    : Text_Io.File_Type;
  22.  
  23. begin
  24.  
  25.   Text_Io.Put("Name : " );
  26.   declare
  27.      Name : String(1..32) := (others => Character'Val(32));
  28.      Top : Positive := 1;
  29.      Available : Boolean := False;
  30.      The_Char : Character := ' ';
  31.   begin
  32.      Get_Name :
  33.      loop
  34.      begin
  35.         for Char in Top .. Name'last loop
  36.           
  37.           
  38.            Text_Io.Get_immediate(Name(Char));
  39.            case Name(Char) is
  40.           when Character'Val(10) | Character'Val(13) =>
  41.              Name(Char) := Character'Val(32);
  42.              exit Get_Name;
  43.           when Character'Val(127) | Character'Val(8) =>
  44.              if Top > 1 then
  45.             Name(Top) := Character'Val(32);
  46.             Name(Top - 1) := Character'Val(32);            
  47.                     
  48.             Text_Io.Put(Character'Val(8) & Character'Val(32) & Character'Val(8));
  49.             
  50.             Top := Top - 1;
  51.             exit;
  52.              end if;
  53.           when others =>
  54.  
  55.              Text_Io.Put(Name(Char));
  56.              Top := Top + 1;
  57.            end case;
  58.         end loop;
  59.         
  60.      exception
  61.         when Text_Io.End_Error =>
  62.            null;
  63.      end;
  64.      end loop Get_name;
  65.      Name := Handling.To_Lower(Name);
  66.      Text_Io.New_Line;
  67.      
  68.      Errno := System("echo is_name\(" & Name(Name'First..Top-1) & "\). | /usr/bin/swipl -q -f " &
  69.             Base_Name(Command_Name) & ".pl" & Character'Val(0));
  70.  
  71.      if Os_Lib.Is_Regular_File("./error.txt" ) then
  72.  
  73.      Os_Lib.Delete_file("./error.txt", Verax);
  74.      Text_Io.Create(Prolog, Text_Io.Out_File, Name(Name'First..Top-1) & ".pl" );
  75.      Text_Io.Put_Line(Prolog, "name(" & Name(Name'First..Top-1) & " )." );
  76.      Text_Io.Put_Line(Prolog, "is_name(V) :-" );
  77.      Text_Io.Put_Line(Prolog, " name(V), !," );
  78.      Text_Io.Put_Line(Prolog, " write('Eureka')" );
  79.      Text_Io.Put_Line(Prolog, "; open('./error.txt', write, Stream)," );
  80.      Text_Io.Put_Line(Prolog, "close(Stream)," );
  81.      Text_Io.Put_Line(Prolog, "name(V), !," );
  82.      Text_Io.Put_Line(Prolog, "write('')." );
  83.      Text_Io.Close(Prolog);
  84.     
  85.      Errno := System("ln -s ../main bin/" & Name(Name'First..Top-1) & Character'Val(0));
  86.  
  87.      if Errno = 0 then
  88.         Text_Io.Create(Ada, Text_Io.Out_File, Name(Name'First..Top-1) & ".adb" );
  89.  
  90.         
  91.         Text_Io.Put_line(Ada, "with Ada.Text_Io;" );
  92.         Text_Io.Put_line(Ada, "use Ada;" );
  93.         Text_Io.Put_line(Ada, "with System.Os_Lib;" );
  94.         Text_Io.Put_line(Ada, "use System;" );
  95.         Text_Io.Put_line(Ada, "with Ada.Characters.Handling;" );
  96.         Text_Io.Put_line(Ada, "use Ada.Characters;" );
  97.         Text_Io.Put_line(Ada, "with Ada.Command_Line;" );
  98.         Text_Io.Put_line(Ada, "use Ada.Command_Line;" );
  99.         Text_Io.Put_line(Ada, "with Ada.Directories;" );
  100.         Text_Io.Put_line(Ada, "use Ada.Directories;" );
  101.         
  102.         Text_Io.Put_line(Ada, "procedure " & Name(Name'First..Top-1) & " is" );
  103.         Text_Io.New_Line(Ada);
  104.         Text_Io.Put_Line(Ada, "   function System(Cmd : in String) return Integer;" );
  105.         Text_Io.Put_Line(Ada, "   pragma Import(C, System, ""system"" );" );
  106.         Text_Io.Put_Line(Ada, "   Errno : Integer := 0;" );
  107.         Text_Io.Put_Line(Ada, "   Verax : Boolean := False;" );  
  108.         Text_Io.Put_Line(Ada, "   Args   : Os_Lib.Argument_List_Access;" );
  109.         Text_Io.Put_Line(Ada, "   Pid    : Os_Lib.Process_Id;" );
  110.         Text_Io.Put_Line(Ada, "   Prolog : Text_Io.File_Type;" );
  111.         Text_Io.Put_Line(Ada, "   Ada    : Text_Io.File_Type;" );
  112.         Text_Io.Put_Line(Ada, "begin" );
  113.         Text_Io.New_Line(Ada);
  114.         Text_Io.Put_Line(Ada, "   Text_Io.Put(""Name : "" );" );
  115.         Text_Io.Put_Line(Ada, "   declare" );
  116.  
  117.         Text_Io.Put_Line(Ada, "  Name : String(1..32) := (others => Character'Val(32));" );
  118.         Text_Io.Put_Line(Ada, "  Top : Positive := 1;" );
  119.         Text_Io.Put_Line(Ada, "   begin" );
  120.         Text_Io.Put_Line(Ada, "        Get_Name :" );
  121.         Text_Io.Put_Line(Ada, "      loop" );
  122.         Text_Io.Put_Line(Ada, " begin" );
  123.         Text_Io.Put_Line(Ada, "    for Char in Top .. Name'last loop" );
  124.         Text_Io.Put_Line(Ada, "       Text_Io.Get_Immediate(Name(Char));" );
  125.         Text_Io.Put_Line(Ada, "       case Name(Char) is" );
  126.         Text_Io.Put_Line(Ada, "  when Character'Val(10) | Character'Val(13) =>" );
  127.         Text_Io.Put_Line(Ada, "     Name(Char) := Character'Val(32);" );
  128.         Text_Io.Put_Line(Ada, "     exit Get_Name;" );
  129.         Text_Io.Put_Line(Ada, "  when Character'Val(127) | Character'Val(8) =>" );
  130.         Text_Io.Put_Line(Ada, "     if Top > 1 then" );
  131.         Text_Io.Put_Line(Ada, "Name(Top) := Character'Val(32);" );
  132.         Text_Io.Put_Line(Ada, "Name(Top - 1) := Character'Val(32);" );
  133.         Text_Io.Put_Line(Ada, "Text_Io.Put(Character'Val(13) & ""Name : "" & Name(1..Top-1) & Character'Val(8));" );
  134.         Text_Io.Put_Line(Ada, "Top := Top - 1;" );
  135.         Text_Io.Put_Line(Ada, "exit;" );
  136.         Text_Io.Put_Line(Ada, "     end if;" );
  137.         Text_Io.Put_Line(Ada, "  when others =>" );
  138.         Text_Io.Put_Line(Ada, "     Text_Io.Put(Name(Char));" );
  139.         Text_Io.Put_Line(Ada, "     Top := Top + 1;" );
  140.         Text_Io.Put_Line(Ada, "       end case;" );
  141.         Text_Io.Put_Line(Ada, "    end loop;" );
  142.         
  143.         Text_Io.Put_Line(Ada, " exception" );
  144.         Text_Io.Put_Line(Ada, "    when Text_Io.End_Error =>" );
  145.         Text_Io.Put_Line(Ada, "       null;" );
  146.         Text_Io.Put_Line(Ada, " end;" );
  147.         Text_Io.Put_Line(Ada, "      end loop Get_name;" );
  148.         Text_Io.Put_Line(Ada, "     Text_Io.Put_line(Character'Val(13) & ""Name : "" & name);" );
  149.  
  150.  
  151.         Text_Io.New_Line(Ada);
  152.         Text_Io.Put_Line(Ada, "      Name := Handling.To_Lower(Name);" );
  153.         Text_Io.Put_Line(Ada, "          Errno := System(""echo is_name\("" & Name(Name'First..Top-1) & ""\). | /usr/bin/swipl -q -f "" & " );
  154.         Text_Io.Put_Line(Ada, "Base_Name(Command_Name) & "".pl"" & Character'Val(0));" );
  155.  
  156.  
  157.         Text_Io.Put_Line(Ada, "      if Errno /= 0 then" );
  158.         Text_Io.Put_Line(Ada, "         Text_Io.Create(Prolog, Text_Io.Out_File, Name & "".pl"" );" );
  159.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""name("" & Name & "" )."" );" );
  160.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""is_name(V) :-"" );" );
  161.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, "" name(V), !,"" );" );
  162.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, "" write('Eureka')"" );" );
  163.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""; open('./error.txt', write, Stream),"" );" );
  164.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""close(Stream),"" );" );
  165.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""name(V), !,"" );" );
  166.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""write('')."" );" );
  167.         Text_Io.Put_Line(Ada, "         Text_Io.Close(Prolog);" );
  168.         Text_Io.Put_Line(Ada, "         Errno := System(""ln -s ../main bin/"" & Name(Name'First..Top-1) & Character'Val(0));" );
  169.         Text_Io.Put_Line(Ada, "         pid := Os_Lib.Non_Blocking_Spawn(""./bin/"" & Name(Name'First..Top-1), Args.all);" );
  170.         Text_Io.Put_Line(Ada, "      end if;" );
  171.         Text_Io.Put_Line(Ada, "   end;" );
  172.         Text_Io.Put_Line(Ada, "end " & Name & ";" );
  173.  
  174.         Text_Io.Close(Ada);
  175.  
  176.         Os_Lib.Spawn("./bin/" & Name(Name'First..Top-1), Args.all, verax);
  177.         
  178.      else
  179.         Text_Io.Put("Faillure" );
  180.      end if;
  181.      end if;
  182.  
  183.   end;
  184. exception
  185.   when Text_Io.End_Error =>
  186.      Text_Io.Put_Line("bye!" );
  187. end Main;


 
Si le système de thread présenté plus haut n'était pas utilisable ; Une implémentation complète est disponible dans le projet Emergeance de prehander sur sourceforge.net.


Message édité par lady287 le 16-03-2026 à 13:34:02

---------------
jovalise (C) 2002 Manuel De Girardi ; web site
n°2520235
lady287
La lumière fuse
Posté le 16-03-2026 à 13:56:57  profilanswer
 

Amoins d'avoir été piraté dès mon disque dure rebranché, les deux version de main.adb présenté ici peuvent s'avérer adapté à votre version de GNU/Linux ou Gnat spécifiquement.
En effet, je constae que la dernière version de ce programme fonctionne sur Debian 10 et pas sur 12.
La procedure get_immediate semble ne pas fonctinner de la même façon.
https://forum.hardware.fr/hfr/Progr [...] m#t2520231


---------------
jovalise (C) 2002 Manuel De Girardi ; web site
n°2520342
lady287
La lumière fuse
Posté le 17-03-2026 à 13:16:34  profilanswer
 

Bonjour !
Après 24 heures de programmeur, j'ai enfin trouvé l'algorithme et les usage permettant d'utiliser Spawn de sorte que l'appel d'un autre programme permette une inter-action malgrès l'utilisation d'un fichier de sortie nécessaire au traitement permettant de faire défiler la sortie grâce aux boutons prévus à cet effet.
 
Ansi le programme main.adb c'est vu modifié à l'appel de spawn où le pipe a été remplacé par une redirection.
 
Dans la version suivante ; La variable Line_Count est remplacé par la variable Old_Count alors que la variable Line_Count permet de faire défiler la sortie.
 
Le thread Exec_Thread publié ici utilise un type dédié au programme cible et n'est pas indispensable en général.
 
Nouveau code de main.adb

Code :
  1.  


 
Elements du processus exposé

Code :
  1.  


 
Le programme main utilise le script main.pl.
 
Utilisation du type Exec_Thread

Code :
  1. declare
  2.                       Thread : Exec_Thread(new String ' (Handling.to_String(Text.all)));
  3.                       Success : Boolean := False;
  4.                       Errno : Integer := 0;
  5.                       File : File_Type;                                            
  6.                       
  7.                        begin
  8.                       Clocking.Suspend;
  9.                       Thread.Spawn;
  10.                       delay 0.2;
  11.                       File_thread.Start;
  12.                       Thread.Wait(Success, Errno);
  13.                       Thread.halt;
  14.                       Clocking.start;
  15.                       
  16.                        end;


 
Une erreur de procédure d'archivage reporte la publication des corrections des sources.


Message édité par lady287 le 17-03-2026 à 14:06:25

---------------
jovalise (C) 2002 Manuel De Girardi ; web site
n°2520347
lady287
La lumière fuse
Posté le 17-03-2026 à 14:27:04  profilanswer
 

La correction est sensiblement divergeante de la version originelle pour le programme main pour lequel ici il fut nécessaire de récupérer dans un fichier de sortie l'entrée du programme cible, ici main.

Code :
  1. with Ada.Text_Io;
  2. use Ada;
  3. with System.Os_Lib;
  4. use System;
  5. with Ada.Characters.Handling;
  6. use Ada.Characters;
  7. with Ada.Command_Line;
  8. use Ada.Command_Line;
  9. with Ada.Directories;
  10. use Ada.Directories;
  11. procedure Main is
  12.  
  13.   function System(Cmd : in String) return Integer;
  14.   pragma Import(C, System, "system" );
  15.   Errno : Integer := 0;
  16.  
  17.   Verax : Boolean := False;
  18.   Args   : Os_Lib.Argument_List_Access := new Os_Lib.Argument_List(1..0);
  19.   Pid    : Os_Lib.Process_Id;
  20.   Prolog : Text_Io.File_Type;
  21.   Ada    : Text_Io.File_Type;
  22.  
  23. begin
  24.  
  25.   Text_Io.Put("Name : " );
  26.   declare
  27.      Name : String(1..32) := (others => Character'Val(32));
  28.      Top : Positive := 1;
  29.      Available : Boolean := False;
  30.      The_Char : Character := ' ';
  31.   begin
  32.      Get_Name :
  33.      loop
  34.      begin
  35.         for Char in Top .. Name'last loop
  36.           
  37.           
  38.            Text_Io.Get_immediate(Name(Char));
  39.            case Name(Char) is
  40.           when Character'Val(10) | Character'Val(13) =>
  41.              Name(Char) := Character'Val(32);
  42.              exit Get_Name;
  43.           when Character'Val(127) | Character'Val(8) =>
  44.              if Top > 1 then
  45.             Name(Top) := Character'Val(32);
  46.             Name(Top - 1) := Character'Val(32);            
  47.             Text_Io.Put(Character'Val(8) & Character'Val(32) & Character'Val(8));
  48.             Top := Top - 1;
  49.             exit;
  50.              end if;
  51.           when others =>
  52.  
  53.              Text_Io.Put(Name(Char));
  54.              Top := Top + 1;
  55.            end case;
  56.         end loop;
  57.         
  58.      exception
  59.         when Text_Io.End_Error =>
  60.            null;
  61.      end;
  62.      end loop Get_name;
  63.      Name := Handling.To_Lower(Name);
  64.      Text_Io.New_Line;
  65.      
  66.      Errno := System("echo is_name\(" & Name(Name'First..Top-1) & "\). | /usr/bin/swipl -q -f " &
  67.             Base_Name(Command_Name) & ".pl" & Character'Val(0));
  68.  
  69.      if Os_Lib.Is_Regular_File("./error.txt" ) then
  70.  
  71.      Os_Lib.Delete_file("./error.txt", Verax);
  72.      Text_Io.Create(Prolog, Text_Io.Out_File, Name(Name'First..Top-1) & ".pl" );
  73.      Text_Io.Put_Line(Prolog, "name(" & Name(Name'First..Top-1) & " )." );
  74.      Text_Io.Put_Line(Prolog, "is_name(V) :-" );
  75.      Text_Io.Put_Line(Prolog, " name(V), !," );
  76.      Text_Io.Put_Line(Prolog, " write('Eureka')" );
  77.      Text_Io.Put_Line(Prolog, "; open('./error.txt', write, Stream)," );
  78.      Text_Io.Put_Line(Prolog, "close(Stream)," );
  79.      Text_Io.Put_Line(Prolog, "name(V), !," );
  80.      Text_Io.Put_Line(Prolog, "write('')." );
  81.      Text_Io.Close(Prolog);
  82.     
  83.      Errno := System("ln -s ../main bin/" & Name(Name'First..Top-1) & Character'Val(0));
  84.  
  85.      if Errno = 0 then
  86.         Text_Io.Create(Ada, Text_Io.Out_File, Name(Name'First..Top-1) & ".adb" );
  87.  
  88.         
  89.         Text_Io.Put_line(Ada, "with Ada.Text_Io;" );
  90.         Text_Io.Put_line(Ada, "use Ada;" );
  91.         Text_Io.Put_line(Ada, "with System.Os_Lib;" );
  92.         Text_Io.Put_line(Ada, "use System;" );
  93.         Text_Io.Put_line(Ada, "with Ada.Characters.Handling;" );
  94.         Text_Io.Put_line(Ada, "use Ada.Characters;" );
  95.         Text_Io.Put_line(Ada, "with Ada.Command_Line;" );
  96.         Text_Io.Put_line(Ada, "use Ada.Command_Line;" );
  97.         Text_Io.Put_line(Ada, "with Ada.Directories;" );
  98.         Text_Io.Put_line(Ada, "use Ada.Directories;" );
  99.         
  100.         Text_Io.Put_line(Ada, "procedure " & Name(Name'First..Top-1) & " is" );
  101.         Text_Io.New_Line(Ada);
  102.         Text_Io.Put_Line(Ada, "   function System(Cmd : in String) return Integer;" );
  103.         Text_Io.Put_Line(Ada, "   pragma Import(C, System, ""system"" );" );
  104.         Text_Io.Put_Line(Ada, "   Errno : Integer := 0;" );
  105.         Text_Io.Put_Line(Ada, "   Verax : Boolean := False;" );  
  106.         Text_Io.Put_Line(Ada, "   Args   : Os_Lib.Argument_List_Access;" );
  107.         Text_Io.Put_Line(Ada, "   Pid    : Os_Lib.Process_Id;" );
  108.         Text_Io.Put_Line(Ada, "   Prolog : Text_Io.File_Type;" );
  109.         Text_Io.Put_Line(Ada, "   Ada    : Text_Io.File_Type;" );
  110.         Text_Io.Put_Line(Ada, "begin" );
  111.         Text_Io.New_Line(Ada);
  112.         Text_Io.Put_Line(Ada, "   Text_Io.Put(""Name : "" );" );
  113.         Text_Io.Put_Line(Ada, "   declare" );
  114.  
  115.         Text_Io.Put_Line(Ada, "  Name : String(1..32) := (others => Character'Val(32));" );
  116.         Text_Io.Put_Line(Ada, "  Top : Positive := 1;" );
  117.         Text_Io.Put_Line(Ada, "   begin" );
  118.         Text_Io.Put_Line(Ada, "        Get_Name :" );
  119.         Text_Io.Put_Line(Ada, "      loop" );
  120.         Text_Io.Put_Line(Ada, " begin" );
  121.         Text_Io.Put_Line(Ada, "    for Char in Top .. Name'last loop" );
  122.         Text_Io.Put_Line(Ada, "       Text_Io.Get_Immediate(Name(Char));" );
  123.         Text_Io.Put_Line(Ada, "       case Name(Char) is" );
  124.         Text_Io.Put_Line(Ada, "  when Character'Val(10) | Character'Val(13) =>" );
  125.         Text_Io.Put_Line(Ada, "     Name(Char) := Character'Val(32);" );
  126.         Text_Io.Put_Line(Ada, "     exit Get_Name;" );
  127.         Text_Io.Put_Line(Ada, "  when Character'Val(127) | Character'Val(8) =>" );
  128.         Text_Io.Put_Line(Ada, "     if Top > 1 then" );
  129.         Text_Io.Put_Line(Ada, "Name(Top) := Character'Val(32);" );
  130.         Text_Io.Put_Line(Ada, "Name(Top - 1) := Character'Val(32);" );
  131.         Text_Io.Put_Line(Ada, "Text_Io.Put(Character'Val(13) & ""Name : "" & Name(1..Top-1) & Character'Val(8));" );
  132.         Text_Io.Put_Line(Ada, "Top := Top - 1;" );
  133.         Text_Io.Put_Line(Ada, "exit;" );
  134.         Text_Io.Put_Line(Ada, "     end if;" );
  135.         Text_Io.Put_Line(Ada, "  when others =>" );
  136.         Text_Io.Put_Line(Ada, "     Text_Io.Put(Name(Char));" );
  137.         Text_Io.Put_Line(Ada, "     Top := Top + 1;" );
  138.         Text_Io.Put_Line(Ada, "       end case;" );
  139.         Text_Io.Put_Line(Ada, "    end loop;" );
  140.         
  141.         Text_Io.Put_Line(Ada, " exception" );
  142.         Text_Io.Put_Line(Ada, "    when Text_Io.End_Error =>" );
  143.         Text_Io.Put_Line(Ada, "       null;" );
  144.         Text_Io.Put_Line(Ada, " end;" );
  145.         Text_Io.Put_Line(Ada, "      end loop Get_name;" );
  146.         Text_Io.Put_Line(Ada, "     Text_Io.Put_line(Character'Val(13) & ""Name : "" & name);" );
  147.  
  148.  
  149.         Text_Io.New_Line(Ada);
  150.         Text_Io.Put_Line(Ada, "      Name := Handling.To_Lower(Name);" );
  151.         Text_Io.Put_Line(Ada, "          Errno := System(""echo is_name\("" & Name(Name'First..Top-1) & ""\). | /usr/bin/swipl -q -f "" & " );
  152.         Text_Io.Put_Line(Ada, "Base_Name(Command_Name) & "".pl"" & Character'Val(0));" );
  153.  
  154.  
  155.         Text_Io.Put_Line(Ada, "      if Errno /= 0 then" );
  156.         Text_Io.Put_Line(Ada, "         Text_Io.Create(Prolog, Text_Io.Out_File, Name & "".pl"" );" );
  157.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""name("" & Name & "" )."" );" );
  158.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""is_name(V) :-"" );" );
  159.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, "" name(V), !,"" );" );
  160.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, "" write('Eureka')"" );" );
  161.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""; open('./error.txt', write, Stream),"" );" );
  162.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""close(Stream),"" );" );
  163.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""name(V), !,"" );" );
  164.         Text_Io.Put_Line(Ada, "         Text_Io.Put_Line(Prolog, ""write('')."" );" );
  165.         Text_Io.Put_Line(Ada, "         Text_Io.Close(Prolog);" );
  166.         Text_Io.Put_Line(Ada, "         Errno := System(""ln -s ../main bin/"" & Name(Name'First..Top-1) & Character'Val(0));" );
  167.         Text_Io.Put_Line(Ada, "         Errno := System(""/usr/bin/sh -c ""bin/"" & Name(Name'First..Top-1) & """" & Character'Val(0));" );
  168.  
  169.         Text_Io.Put_Line(Ada, "      end if;" );
  170.         Text_Io.Put_Line(Ada, "   end;" );
  171.         Text_Io.Put_Line(Ada, "end " & Name & ";" );
  172.  
  173.         Text_Io.Close(Ada);
  174.         Errno := System("/usr/bin/sh -c ""bin/" & Name(Name'First..Top-1) & """" & Character'Val(0));
  175.  
  176.         
  177.      else
  178.         Text_Io.Put("Faillure" );
  179.      end if;
  180.      end if;
  181.  
  182.   end;
  183. exception
  184.   when Text_Io.End_Error =>
  185.      Text_Io.Put_Line("bye!" );
  186. end Main;


En cas d'erreur de ma pare, vérifiez que le nombre de guillemet soit celui requis dans la version acidentelle du programme résultant de votre erreur par excès ou par défaut.
 
 
 
 

Code :
  1. task File_Thread is
  2.      entry Page_Down;
  3.      entry Page_Up;
  4.      entry Up_Arrow;
  5.      entry Down_Arrow;
  6.      entry Start;
  7.      entry Reset;
  8.      entry Release;
  9.      entry Halt;
  10.      end File_Thread;
  11.      task body File_Thread is
  12.      Line_Count  : Natural := 0;
  13.      Count : Natural := 0;
  14.      Old_Count : Natural := 0;
  15.      Line_Index  : Natural := 1;
  16.      File : File_Type;
  17.      Free : Boolean := False;
  18.      Only_One : Boolean := False;
  19.      begin
  20.     Main_Loop :
  21.      loop
  22.         loop
  23.            select
  24.           accept Page_Down do
  25.  
  26.              Line_Index := 1;
  27.             
  28.              Line_count := Line_count + App.Cmd_Result.Win.H/2;
  29.              Draw_Window(App.Cmd_Result.Win);
  30.              Only_One := True;
  31.           end Page_Down;
  32.           exit;
  33.            or
  34.           accept Page_Up do
  35.             
  36.              Line_Index := 1;
  37.              if Line_count - App.Cmd_Result.Win.H/2 >= 0 then
  38.             Line_count := Line_count - App.Cmd_Result.Win.H/2;
  39.              end if;
  40.              Draw_Window(App.Cmd_Result.Win);
  41.              Only_One := True;
  42.           end Page_Up;
  43.           exit;
  44.            or
  45.           accept Up_Arrow do
  46.  
  47.              Line_Index := 1;
  48.              if Line_Count - 1 >= 0 then
  49.             Line_count := Line_count - 1;
  50.              end if;
  51.              Draw_Window(App.Cmd_Result.Win);
  52.              Only_One := True;
  53.           end Up_Arrow;
  54.           exit;
  55.            or
  56.           accept Down_Arrow do
  57.  
  58.              Line_Index := 1;
  59.             
  60.              Line_count := Line_count + 1;
  61.              Draw_Window(App.Cmd_Result.Win);
  62.              Only_One := True;
  63.           end Down_Arrow;
  64.           exit;
  65.            or
  66.           accept Start do
  67.              Only_One := False;
  68.              Free := False;
  69.              Old_Count := 0;
  70.              Line_Count := 0;
  71.              Count := 0;
  72.           end Start;
  73.           exit;
  74.            or
  75.           accept Halt;
  76.           exit Main_Loop;
  77.            or
  78.           accept Reset do
  79.              Line_Index := 1;
  80.              Line_Count := 0;
  81.           end Reset;
  82.            or
  83.           accept Release do
  84.              Free := True;
  85.           end Release;
  86.            end Select;
  87.         end loop;
  88.         
  89.         loop
  90.            delay 0.1;
  91.            Open(File, In_File, ".Out" );
  92.            Draw_Window(App.Cmd_Result.Win);
  93.            while not End_Of_File(File) loop
  94.           declare
  95.              Line : String := Get_Line(File);
  96.              Pro_Index : Natural := Fixed.Index(Line, "true." );
  97.              Next : Natural := 0;
  98.           begin
  99.              if Pro_Index /= 0 then
  100.             if Line'Length >= Pro_Index + 4 then
  101.               
  102.                Next := Pro_Index + 4;
  103.             end if;
  104.              end if;
  105.             
  106.              if Count+1 >= Old_Count+Line_count then
  107.             if Next /= 0 then
  108.                Draw_Text(App.Cmd_Result.win, Line_Index, 1, White, Handling.To_Wide_String(Line(Line'First..Pro_Index-1)));
  109.                Enlight_Draw_Text(App.Cmd_Result.win, Line_Index, Pro_Index, White, Handling.To_Wide_String(Line(Pro_Index..Next) & Normal_mode));
  110.                if Line'Length > Next then
  111.                   Draw_Text(App.Cmd_Result.win, Line_Index, Pro_Index+5, White, Handling.To_Wide_String(Line(Next+1..Line'Last)));
  112.                end if;
  113.             else
  114.                Draw_Text(App.Cmd_Result.win, Line_Index, 1, White, Handling.To_Wide_String(Line));
  115.             end if;
  116.             Line_Index := Line_Index + 1;
  117.             if (Count - Old_Count) + Line_Index + 1 > App.Cmd_Result.Win.H-2 then
  118.                Old_Count := Old_Count + 1;
  119.               
  120.             end if;
  121.           
  122.              end if;
  123.              Count := Count + 1;
  124.             
  125.           end;    
  126.           exit when Line_Index > App.Cmd_Result.Win.H-2;
  127.           
  128.            end loop;
  129.           
  130.            Close(File);
  131.           
  132.            if Count > Old_Count then
  133.  
  134.           
  135.                  if not Free then
  136.                    
  137.              if not (Old_Count /= Old_Count + (Count - (App.Cmd_Result.Win.H-2))) then
  138.                    null;
  139.                     elsif Count > Old_Count+(App.Cmd_Result.Win.H-2) then
  140.                    Old_Count := Old_Count + (Count - (App.Cmd_Result.Win.H-2));
  141.                     end if;
  142.             
  143.                  end if;
  144.           
  145.            elsif not (Old_Count /= Old_Count + (Count - (App.Cmd_Result.Win.H-2))) then
  146.           null;
  147.            elsif Count > Old_Count+(App.Cmd_Result.Win.H-2) then
  148.           Old_Count := Old_Count + (Count - (App.Cmd_Result.Win.H-2));
  149.            end if;
  150.           
  151.           
  152.            Line_Index := 1;
  153.            select
  154.           accept Reset do
  155.              Line_Index := 1;
  156.              Line_Count := 0;
  157.           end Reset;
  158.           exit;
  159.            or
  160.           
  161.           accept Page_Down do
  162.  
  163.              Line_Index := 1;
  164.             
  165.              Line_count := Line_count + App.Cmd_Result.Win.H/2;
  166.  
  167.              Draw_Window(App.Cmd_Result.Win);
  168.  
  169.           end Page_Down;
  170.  
  171.            or
  172.           
  173.           accept Page_Up do
  174.  
  175.              Line_Index := 1;
  176.              if Line_count - App.Cmd_Result.Win.H/2 >= 0 then
  177.             Line_count := Line_count - App.Cmd_Result.Win.H/2;
  178.  
  179.             Draw_Window(App.Cmd_Result.Win);
  180.  
  181.              end if;
  182.  
  183.             
  184.           end Page_Up;
  185.  
  186.            or
  187.           
  188.           accept Up_Arrow do
  189.  
  190.              Line_Index := 1;
  191.              if Line_Count - 1 >= 0 then
  192.             Line_count := Line_count - 1;
  193.  
  194.             Draw_Window(App.Cmd_Result.Win);
  195.  
  196.              end if;
  197.  
  198.             
  199.           end Up_Arrow;
  200.  
  201.            or
  202.           
  203.           accept Down_Arrow do
  204.  
  205.              Line_Index := 1;
  206.             
  207.              Line_count := Line_count + 1;
  208.  
  209.              Draw_Window(App.Cmd_Result.Win);
  210.  
  211.           end Down_Arrow;
  212.            or
  213.           
  214.           accept Release do
  215.              Free := True;
  216.           end Release;
  217.  
  218.            or
  219.           accept Halt;
  220.           exit Main_Loop;
  221.  
  222.            or
  223.           delay 0.05;
  224.            end select;
  225.           
  226.            Count := 0;
  227.            exit when Only_One;
  228.         end loop;
  229.         Only_One := False;
  230.      end loop Main_Loop;
  231.      end File_Thread;
  232.      
  233.      
  234.      task type Exec_Thread (Cmd_Line : String_Access) is
  235.      entry Spawn;
  236.      entry Wait(Success : out Boolean;Errno : out Integer);
  237.      entry Read_Line;
  238.      entry Halt;
  239.      end Exec_Thread;
  240.      
  241.      task body Exec_Thread is
  242.  
  243.      Success : Boolean := False;
  244.      Errno : Integer := 0;
  245.      PID   : Os_Lib.Process_ID;
  246.     
  247.      begin
  248.     
  249.      accept Spawn do
  250.         if not (Command_Name(Cmd_line.all)'Length = Cmd_line'Length) then
  251.           
  252.            null;
  253.           
  254.         end if;
  255.         
  256.      end Spawn;          
  257.      Screen_Lock.Seize;
  258.      if Command_Name(Cmd_Line.all)'Length = Cmd_Line'Length then
  259.         
  260.         if not Os_Lib."="(Os_Lib.Locate_Exec_On_Path(Cmd_Line.all), null) then
  261.           
  262.            declare
  263.           Args : constant Os_Lib.Argument_List_Access := Os_Lib.Argument_String_To_List
  264.             ("-c """ & Os_Lib.Locate_Exec_On_Path(Cmd_Line.all).all & """" );
  265.            begin
  266.           --Os_Lib.Normalize_Arguments(Args.all);
  267.           
  268.           --PID := Os_Lib.Non_Blocking_Spawn("/usr/bin/sh", Args.all, ".Out", True);
  269.           --Result := new Spawn_Result_Type' (Shell_Spawn(Os_Lib.Locate_Exec_On_Path(Command_Name(Cmd_Line.all)).all & " " &
  270.           --                          Cmd_Line(Command_Name(Cmd_Line.all)'Length+2..Cmd_Line'Last)));
  271.           Result := new Spawn_Result_Type ' (Spawn(Cmd_Line.all, ".Out" ));
  272.           U_Array_Free(Result.Wlines);
  273.           
  274.           Wide_Result_Free(Result);
  275.  
  276.           --Errno := System("/usr/bin/sh -c """ & Os_Lib.Locate_Exec_On_Path(Cmd_Line.all).all & " | /usr/bin/tee .Out 1> .Out""" & Character'Val(0));
  277.            end;
  278.         end if;
  279.      elsif Fixed.Index(Command_Name(Cmd_Line.all), "/" ) = 0 then
  280.         Result := new Spawn_Result_Type' (Spawn(Cmd_Line.all, ".Out" ));
  281.      else
  282.         
  283.         declare
  284.            Args : constant Os_Lib.Argument_List_Access := Os_Lib.Argument_String_To_List
  285.          (Os_Lib.Locate_Exec_On_Path(Command_Name(Cmd_Line.all)).all & " " &
  286.             Cmd_Line(Command_Name(Cmd_Line.all)'Length+2..Cmd_Line'Last));
  287.  
  288.         begin
  289.           
  290.            Os_Lib.Normalize_Arguments(Args.all);
  291.           
  292.            PID := Os_Lib.Non_Blocking_Spawn(Os_Lib.Locate_Exec_On_Path(Args(1).all).all, Args(2..Args'Last), ".Out", True);
  293.            Os_Lib.Wait_Process(PID, Success);
  294.           
  295.            --Errno := System("/usr/bin/sh -c """ & Os_Lib.Locate_Exec_On_Path(Cmd_Line.all).all & " | /usr/bin/tee .Out 1> .Out""" & Character'Val(0));
  296.         end;
  297.      end if;
  298.      Screen_Lock.Release;
  299.      File_Thread.Release;
  300.     
  301.      loop
  302.         select
  303.            accept Wait(Success : out Boolean;Errno : out Integer) do
  304.           if Errno = 0 then
  305.              Success := True;
  306.           end if;
  307.           Errno := Exec_Thread.Errno;
  308.            end Wait;
  309.         or
  310.            accept Read_Line;
  311.         or
  312.            accept Halt do
  313.           File_Thread.Reset;
  314.            end Halt;
  315.           
  316.            exit;
  317.         end select;
  318.      end loop;
  319.      end Exec_Thread;


 
Refrétablement ; Cette solution fonctionnant sur Debian Stretch semble défaillante sur Debian Bookworm.

 
La vérification montre que les sources sont fonctionnelles su les deux versions évoquées.


Message édité par lady287 le 17-03-2026 à 15:08:19

---------------
jovalise (C) 2002 Manuel De Girardi ; web site
n°2520351
lady287
La lumière fuse
Posté le 17-03-2026 à 15:08:54  profilanswer
 

:bounce: Ca fonctionne en fait !
 


---------------
jovalise (C) 2002 Manuel De Girardi ; web site
n°2520744
lady287
La lumière fuse
Posté le 23-03-2026 à 09:22:51  profilanswer
 

Le projet Emergeance st uploadé en pré-version 0.14.8a à sourceforge.net.  
Emergeance


---------------
jovalise (C) 2002 Manuel De Girardi ; web site
n°2520751
lady287
La lumière fuse
Posté le 23-03-2026 à 10:20:54  profilanswer
 

J'ai oublié de vous informer que l'éditeur intégré est en cours d'écriture es ne constitu pour le moment un éditeur.
 
Le gestionnaire de projets appellle Emacs.


---------------
jovalise (C) 2002 Manuel De Girardi ; web site
mood
Publicité
Posté le   profilanswer
 

 Page :   1  2  3  4  5  6

Aller à :
Ajouter une réponse
 

Sujets relatifs
Probleme robot google ? Ma source internet ? aidez moiInterface ADA avec C
Projet de frontend Open-Source pour émulateursOpen Office: Base de données
code source pdf ?Modifier le code source de SIP-Communicator
[JS] Pb avec un page de javascripts et module open flash chart[ADA] /!\ Combien on peux boire de biere JEUDI MIDI §§§ la defense ??
Fonction window.open (javascript) 
Plus de sujets relatifs à : [Ada][Topic Unic][Open Source] Je fais péter mes codes.


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)