fr:documentation:script_example
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| fr:documentation:script_example [2017/02/10 22:09] – pch | fr:documentation:script_example [2017/02/28 15:43] (Version actuelle) – [Sans attente] pch | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | FIXME **This page is not fully translated, yet. Please help completing the translation.**\\ //(remove this paragraph once the translation is finished)// | + | ====== Exemple de script ====== |
| - | ====== Script example ====== | + | Cette page donne des conseils et des exemples de script. \\ |
| + | Vous pouvez également regarder le code des [[toolbox|boîte à outils standard]] | ||
| + | Pour plus de détails sur une fonction spécifique, | ||
| - | This page give tips and example of scripting functions.\\ | ||
| - | You can also look at the three [[toolbox|standard tool box]] code from within the program.\\ | ||
| - | For more details about a specific function see the [[script_reference|script reference]] page. | ||
| - | ===== Generality ===== | ||
| - | We first look in detail at the code of the Goto button of the Observer tools standard tool box.\\ | + | ===== Généralités ===== |
| - | This cover many programming basis. | + | |
| - | The full script | + | Nous examinons d' |
| + | Cela couvre de nombreuses bases de programmation. | ||
| + | |||
| + | Le code complet du script ressemble à ceci: | ||
| < | < | ||
| // Slew telescope | // Slew telescope | ||
| Ligne 37: | Ligne 37: | ||
| </ | </ | ||
| - | Take a look at each part in detail: | + | Regardons chaque partie en détail: |
| < | < | ||
| // Slew telescope | // Slew telescope | ||
| </ | </ | ||
| - | Is a comment, you can use < | + | C'est un commentaire, vous pouvez utiliser |
| ---- | ---- | ||
| Ligne 50: | Ligne 50: | ||
| c: Tstringlist; | c: Tstringlist; | ||
| </ | </ | ||
| - | Define the variable we use later in the script.\\ | + | Définit les variables que nous utiliserons plus loin dans le script.\\ |
| - | Important | + | Les types de variable |
| - | The Tstringlist | + | Le type Tstringlist est utilisé pour envoyer des commandes à Cartes du Ciel. |
| ---- | ---- | ||
| Ligne 59: | Ligne 59: | ||
| begin | begin | ||
| </ | </ | ||
| - | The start of our program. | + | Le début de notre programme. |
| ---- | ---- | ||
| Ligne 66: | Ligne 66: | ||
| memo_1.clear; | memo_1.clear; | ||
| </ | </ | ||
| - | Clear the text box we use to show the messages. | + | Efface la zone de texte que nous utilisons pour afficher les messages. |
| ---- | ---- | ||
| Ligne 73: | Ligne 73: | ||
| if MenuTelescopeConnect.checked then begin | if MenuTelescopeConnect.checked then begin | ||
| </ | </ | ||
| - | We test the Checked | + | Nous testons la propriété |
| - | If the result is true we execute the code block starting at " | + | Si le résultat est vrai, nous exécutons le bloc de code commençant par " |
| ---- | ---- | ||
| Ligne 81: | Ligne 81: | ||
| if not StrToAR(Edit_1.text, | if not StrToAR(Edit_1.text, | ||
| </ | </ | ||
| - | We try to convert the RA in HMS format | + | Nous essayons de convertir |
| ---- | ---- | ||
| Ligne 88: | Ligne 88: | ||
| | | ||
| </ | </ | ||
| - | Convert the RA back to string representation but with the decimal | + | Conversion de RA à nouveau en chaîne de caractères mais avec le format |
| ---- | ---- | ||
| Ligne 96: | Ligne 96: | ||
| c.clear; | c.clear; | ||
| </ | </ | ||
| - | Request a TStringList | + | Demande un objet TStringList |
| ---- | ---- | ||
| Ligne 105: | Ligne 105: | ||
| c.add(b); | c.add(b); | ||
| </ | </ | ||
| - | Add the command and the required parameters | + | Ajoutez la commande et les paramètres requis |
| ---- | ---- | ||
| Ligne 112: | Ligne 112: | ||
| | | ||
| </ | </ | ||
| - | Execute the command and store the result in the variable r. | + | Exécute la commande et stocke le résultat dans la variable r. |
| ---- | ---- | ||
| Ligne 119: | Ligne 119: | ||
| memo_1.lines.add(r); | memo_1.lines.add(r); | ||
| </ | </ | ||
| - | Show the result of the command to the text box. | + | Affiche le résultat de la commande dans la zone de texte. |
| ---- | ---- | ||
| Ligne 126: | Ligne 126: | ||
| else memo_1.lines.add(rsTelescopeNot); | else memo_1.lines.add(rsTelescopeNot); | ||
| </ | </ | ||
| - | The case the test MenuTelescopeConnect.checked | + | Dans le cas où le test MenuTelescopeConnect.checked |
| - | It show in the text box a translation in the local language of 'Telescope not connected'. | + | Il affiche dans la zone de texte une traduction dans la langue locale de 'Télescope non connecté'. |
| ---- | ---- | ||
| Ligne 134: | Ligne 134: | ||
| end. | end. | ||
| </ | </ | ||
| - | The end of the program. | + | La fin du programme. |
| - | ===== Call an external library | + | ===== Appel d'une librairie externe |
| - | You can define a function in an external library for use within your script | + | Vous pouvez définir une fonction dans une librairie externe à utiliser dans votre script |
| - | This example implement a simple | + | Cet exemple implémente un chronomètre |
| - | There is two button | + | Il y a deux boutons |
| - | Script | + | Script |
| < | < | ||
| | | ||
| Ligne 156: | Ligne 156: | ||
| </ | </ | ||
| - | Script | + | Script |
| < | < | ||
| function GetTickCount: | function GetTickCount: | ||
| Ligne 171: | Ligne 171: | ||
| </ | </ | ||
| - | You can call any library function this way but beware this is system dependent, the kernel32.dll | + | Vous pouvez appeler n' |
| - | Another | + | Une autre limitation |
| - | ===== Using ASCOM directly | + | ===== Utiliser |
| - | This describe how to use an ASCOM device directly from your script | + | Cela décrit comment utiliser un périphérique |
| - | This can be use to access another class of device, the example here connect to a dome, or to access additional properties for your telescope.\\ | + | Il peut être utilisé pour accéder à une autre classe de périphérique, l' |
| - | In the later case you must be careful that your script | + | Dans ce dernier cas, vous devez faire attention que votre script |
| - | ==== Use the ASCOM chooser | + | ==== Choisir un périphérique |
| - | The following | + | Le code suivant assigné à un bouton permet de sélectionner le pilote |
| < | < | ||
| Ligne 201: | Ligne 201: | ||
| </ | </ | ||
| - | Replace | + | Remplacer |
| - | ==== Connect to the ASCOM driver | + | ==== Connecter le pilote |
| - | The following | + | Le code suivant est pour le bouton |
| < | < | ||
| var | var | ||
| Ligne 220: | Ligne 220: | ||
| </ | </ | ||
| - | ==== Use the ASCOM driver | + | ==== Utilisation du pilote |
| - | + | ||
| - | Now we want to add a button to open the dome shutter. This is just an example, at this point any ASCOM property can be use.\\ | + | |
| - | The first test protect again a program crash if we try to use an initialized variant.\\ | + | |
| - | The second test protect again an ASCOM error if the dome is not connected. | + | |
| + | Maintenant, nous voulons ajouter un bouton pour ouvrir le volet du dôme. C'est juste un exemple, à ce stade, n' | ||
| + | Le premier test protège d'un blocage du programme si nous essayons d' | ||
| + | Le deuxième test protège d'une erreur ASCOM si le dôme n'est pas connecté. | ||
| < | < | ||
| var | var | ||
| Ligne 237: | Ligne 236: | ||
| </ | </ | ||
| - | ==== Disconnect the ASCOM driver | + | ==== Déconnexion du pilote |
| - | + | ||
| - | Add a button to disconnect the driver and release the resources. | + | |
| + | Ajout d'un bouton pour déconnecter le pilote et libérer les ressources. | ||
| < | < | ||
| var | var | ||
| Ligne 254: | Ligne 252: | ||
| </ | </ | ||
| - | ===== Open a document ===== | + | ===== Ouvrir un document ===== |
| - | The following | + | Le code suivant ouvre la documentation |
| - | You can use any document | + | Vous pouvez utiliser n' |
| < | < | ||
| Ligne 265: | Ligne 263: | ||
| </ | </ | ||
| - | ===== Run a command | + | ===== Exécuter une commande |
| - | There is two different way to run an external command or program, depending if you want to wait for a result or not. | + | Il existe deux façons différentes d' |
| - | ==== Wait for a result | + | ==== Avec attente du résultat |
| - | The following command run the DIR command in the current directory. The result is stored in a stringlist and later show in a text memo. It contain the list of files in the directory. | + | Le code suivant exécute la commande |
| < | < | ||
| Ligne 283: | Ligne 281: | ||
| </ | </ | ||
| - | ==== No wait ==== | + | ==== Sans attente |
| - | + | ||
| - | If the command can run for an undetermined time or do not produce an output you need to use the following form.\\ | + | |
| - | This example run the Variable star observer program and exit immediately. | + | |
| + | Si la commande peut s' | ||
| + | Cet exemple exécute le programme " | ||
| < | < | ||
| begin | begin | ||
fr/documentation/script_example.1486760968.txt.gz · Dernière modification : 2017/02/10 22:09 de pch
