{{tag>Brouillon}} = Notes Gambas Voir : * https://en.wikipedia.org/wiki/Gambas * http://gambaswiki.org/ * https://en.wikibooks.org/wiki/Gambas Voir aussi : * [[Notes Lazarus|Lazarus]] * https://en.m.wikipedia.org/wiki/GNAVI * [[https://vb.developpez.com/actu/315090/Microsoft-Visual-Basic-6-est-mort-mais-RAD-Basic-vient-avec-la-promesse-d-une-solution-100-pourcent-compatible-support-64-bits-et-open-source-au-menu/|RAD Basic]] * [[https://fr.m.wikipedia.org/wiki/Visual_Basic|Visual_Basic]] * [[https://fr.m.wikipedia.org/wiki/Visual_Basic_.NET|Visual_Basic_.NET]] * https://www.developer.com/microsoft/dotnet/microsoft-win32-apis-become-more-net-compatible/ * [[https://en.wikipedia.org/wiki/Rapid_application_development|Rapid application development (RAD)]] * Programmation orientée objets * [[https://en.wikipedia.org/wiki/Event-driven_programming|Programmation événementielles]] * [[https://en.wikipedia.org/wiki/Visual_programming_language|Programmation visuelle]] * ResEdit / ResHack Différences avec Visual Basic : http://gambaswiki.org/wiki/doc/diffvb?l=fr Tutos Demo rapide : * [[https://www.youtube.com/watch?v=ks2iqWsKwK4&t=252s|Gambas 3 Tutorial 1 : To Make Simple Calculator]] * https://www.youtube.com/watch?v=Gu9sqZZOiR0 Visual Programming using Gambas in Linux * [[https://www.youtube.com/watch?v=AjBVxtyg7m0|Visual Programming using Gambas in Linux - Tutorial 1]] * [[https://www.youtube.com/watch?v=9vBZR_fIFd0|Visual Programming using Gambas in Linux - Tutorial 2]] * [[https://www.youtube.com/watch?v=QCu6UA0LY0E|Visual Programming using Gambas in Linux - Tutorial 3]] * [[https://www.youtube.com/watch?v=uxwPmSJiY6E|Visual Programming using Gambas in Linux - Tutorial 4]] * [[https://www.youtube.com/watch?v=vFD69VESDmk|Visual Programming using Gambas in Linux - Tutorial 5.0]] * [[https://www.youtube.com/watch?v=S05JyVbHIM0|Visual Programming using Gambas in Linux - Tutorial 5.1]] * [[https://www.youtube.com/watch?v=nN-2d5OTodo|Visual Programming using Gambas in Linux Tutorial - Video 5.2]] * [[https://www.youtube.com/watch?v=QxD44BaadQw|Visual Programming using Gambas in Linux Tutorial - Video 5.3]] * [[https://www.youtube.com/watch?v=ItGPSXQWlp0|Visual Programming using Gambas in Linux - Tutorial 5.4]] (Resize) * [[https://www.youtube.com/watch?v=ghz8geMQCrs|Visual Programming using Gambas in Linux - Tutorial 5.5]] * [[https://www.youtube.com/watch?v=v14bsubQusk|Visual Programming using Gambas in Linux - Tutorial 5.6 - PREVIEW]] * [[https://www.youtube.com/watch?v=66VMuikwac0|Visual Programming using Gambas in Linux - Tutorial 5.6 (PART 1)]] * [[https://www.youtube.com/watch?v=osmyD_OXxs4|Visual Programming using Gambas in Linux - Tutorial 5.6 (PART 2)]] * [[https://www.youtube.com/watch?v=7wDKbsOA77I|Visual Programming using Gambas in Linux - Tutorial 5.6 (PART 3)]] * [[https://www.youtube.com/watch?v=F_j2qg-Zen8|Visual Programming using Gambas in Linux - Tutorial 5.6 (PART 4)]] CURSO GAMBAS LINUX : * https://www.youtube.com/watch?v=pONhu8Mi5GU&list=PLV5j_hXqw6uDIrSkfOKMBnmI612BPbVNq Gambas report short demo / tutorial * https://www.youtube.com/watch?v=6OXb9OJALrc == Notions * Classes * Objects * Properties * Methods * Controls * Containers * Code * Events * Procedural == Configuration Tools - Preferences - Highlighting theme : * ~~Amber~~ * Blue * Obsidienne * Pastel * Zen Pour forcer une lib graphique particulière #GB_GUI=gb.gtk3 gambas3 GB_GUI=gb.qt5 gambas3 == Compilation et autres === Execution Pour pouvoir exécuter le code Gambas, seul le Runtime (et quelques autres composants) sont nécessaires. Le Runtime est ici : \\ ''/usr/bin/gbx3'' (paquet gambas3-runtime) Pour lancer un programme Gambas il suffit de lancer gbx3 en étant à la racine du projet === Compilation et création d'un fichier exécutable Pour compiler en ligne de commande un projet Gambas vous pouvez utiliser gbc3 Exemple gbc3 -a Une archive correspond à un exe presque autonome (le Runtine est tout de même nécessaire) \\ Pour créer une archive Gambas il suffit de lancer la commande ''gba3'' en étant à la racine du projet. Un fichier .gambas est crée. C'est du bytecode avec le shebang ''/usr/bin/gbr3'' (lien symbolique vers gbx3) == Scripting Voir : * http://gambaswiki.org/wiki/doc/scripting Il est possible de scripter en langage Gambas Exemple ''hello.gbs'' #!/usr/bin/env gbs3 Public Sub Main() Print "Hello Wolrd" End chmod +x hello.gbs gbs3 -c -S -w hello_world.gbs == Le langage Gambas Voir : * https://gambas.one/playground/ === Les commentaires et autres Pour commenter il suffit de procéder le commentaire du caractère apostrophe "'" Le multiligne s'effectue grâce au caractère "_" (blanc souligné) === Les class Startup class Each project must have a startup class. This startup class must define a static public method named **Main** with no arguments. ==== Creating a class From the Integrated Development Environment file, create a class file rhubarbstructure.class as follows: PUBLIC foo AS STRING PUBLIC bar AS INTEGER It is now possible to define a variable utilizing that class, by creating an appropriate definition in the code module as follows: DIM rhubarb AS rhubarbstructure === Les variables Voir : * https://en.wikibooks.org/wiki/Gambas/Variable * https://fr.wikibooks.org/wiki/Gambas_3/Gambas3LeLangage/Le_langage_Gambas_-_les_variables * http://gambaswiki.org/wiki/tutorial/variables?l=fr * http://gambaswiki.org/wiki/lang/vardecl?l=fr In Gambas it is necessary to declare every variable. To dimension a variable, the code is: Dim variablename as type You can just skip the word Dim , so the following is also correct: variablename as type Remplacer ''Dim'' par ''Static'' pour que la variable ne soit pas détruite à la sortie de la procédure / fonction mais seulement à la fermeture de l'application. Gambas also supports the **+=** and **-=** shorthand Pour le type **Variant** voir l'instruction ''VarType'' ==== Les tableaux Les tableaux peuvent avoir plusieurs dimension (60 !?) Dim Tab(15,5) Tab(1,2) = 10 ==== Création de structure (Struct) PUBLIC STRUCT Article Ref AS STRING Designation AS STRING Prix AS INTEGER Poids AS INTEGER END STRUCT Utilisation Dim ArticleAchete As Article Dim ArticleVendu As Article Articlechete.Poids = 10 ArticleVendu = ArticleAchete ? Existe t-il un ORM pour faire le mapping entre l'objet créé et la base de données ? ==== Variables glocales Il n'y a pas de variables globales en Gambas Un contournement et de les mettre dans le module Main et de les déclarer comme ''Public'' Si vous n'avez pas de module Main dans votre projet mais un Main form, vous pouvez les déclarer as Static Public. Pour accèder à ces variables vous devez utiliser le nom du module ou du formulaire ''Main''. MyMainModule.MyGlobalVariable or MyMainForm.MyGlobalVariable === Les boucles Exemple Sub Option1_Click () Dim i For i = 1 To 10 Beep Next End Sub === Les chaînes de caractères String concatenation operator : "**&**" Path concatenation with "**&/**" operator \\ This operator deals with trailing slashes Examples Print "/home/gambas" &/ ".bashrc" Print "/home/gambas" &/ "/tmp" &/ "foo.bar" === Les fichiers Voir : * http://gambaswiki.org/wiki/lang/lineinput * http://gambaswiki.org/wiki/lang/lof Ouvrir un fichier Dim handle As File handle = Open "myfile" For Read === Traduction Translate Print ("Tranlate me") Print "But do not translate me!" === Substitution Substitution avec Subst Print Subst(("Substitution of &1, &2 and &3"), "first", "second", "third") === Les procédures / fonctions Voir : * http://gambaswiki.org/wiki/lang/return Exemple de syntaxe d'une fonction qui additionne deux nombres Fonction Function Fonc1(Param1 As Float, Param2 As Float) As Float Dim Ret As Float Ret = Param1 + Param2 Return Ret End Function Appel de la fonction Print (Fonc1(2, 3)) == Autres Dépendances du projet $ dpkg -S $(strace --trace=%file -f ./testg.gambas 2>&1 |egrep -v "ENOENT|exited|^strace:" |sed -e 's/^.*"\//\//g' |sed -e 's/",.*$//g' |sort -u |grep gambas3) gambas3-runtime: /usr/lib/gambas3/gb.draw.so gambas3-gb-form: /usr/lib/gambas3/gb.form.gambas gambas3-runtime: /usr/lib/gambas3/gb.geom.so gambas3-gb-gtk3: /usr/lib/gambas3/gb.gtk3.so gambas3-gb-gtk3-x11: /usr/lib/gambas3/gb.gtk3.x11.so gambas3-runtime: /usr/lib/gambas3/gb.gui.base.gambas gambas3-gb-gui: /usr/lib/gambas3/gb.gui.so gambas3-gb-image: /usr/lib/gambas3/gb.image.so == Questions / Réflexions Comment faire pour : * Accéder simplement à une API Rest * Gérer le Multithreading * Génerer une appli Gambas autonome avec toutes les dépendances inclus (DLL, runtime, comme avec VB msvbvm60.dll) * Chiffrer simplement un mot de passe (Vault) ? * Créer dynamiquement des "Controles" ? * You can create controls and menu dynamically, just by instantiating them with the NEW instruction. * "caster" ou forcer le type d'une varaible ? * Faire appel à du code écrit dans un autre langage (mais dans un autre langage compiler tel que Go) peut-être via les IPC, les sockets, via API Rest Microservices ? * Forcer un backend graphique (Si GTK et QT sont tous les deux installés) ? * Porter un code Python simple en Gambas * Créer des tableaux nommés / dictionnaires Questions : * Il n'y a pas de Current Directory dans Gambas. Comment faire ? * Existe-il une technique similaire à ResHack ? * Quel est le langage le plus ressemblant syntaxiquement à Gambas pour avoir la coloration syntaxique avec d'autres outils (Git, wiki etc...) * Existe-il des linter et formateur (tel que **black** ou **flake8** sous Python ou encore à ''go fmt'' sous Go) * Pourquoi n'y a t-il pas de Package Manager avec des dépôts de libs et frameworks en ligne? * Ne serait-il pas souhaitable d'inclure un didacticiel intégré comme sur Visual Basic ? * Que manque t-il pour le portage des applis gérées sur ARM Android ? * Pourquoi VB a disparu ? (ou a t-il été remplacé par VB .NET ?) * Existe t-il un ORM pour faire le mapping entre l'objet créé et la base de données ? (voir plus haut) Limitation : * La commande **Shell** n'est pas capable de récupérer la STDERR !? * Voir les instructions SHELL, EXEC et la class Process * Ils n'y a pas d'équivalents à Map, Reduce, Filter Notes marketing : * Mettre en avant la simplicité d'utilisation de Gambas * Mettre en avant les améliorations par rapport à VB * Support commercial ? * Renommer ou insister sur programmation événementiel / objet. Car le mot "Basic" fait peur ou du moins fait vieux * Crossfounding ? * Mettre en avant la capacité à générer facilement des paquets Debian, RedHat, Archinux, Slackware, Autotools, Opensuze... * Mettre à jours car beaucoup de liens morts concernant des vieux projets