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 [2014/06/15 18:58] – 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. | ||
| - | ===== Generality | + | ===== Généralités |
| - | We first look in detail at the code of the Goto button of the Observer tools standard | + | Nous examinons d' |
| - | This cover many programming basis. | + | Cela couvre de nombreuses bases de programmation. |
| - | The full script | + | Le code complet du script ressemble à ceci: |
| < | < | ||
| // Slew telescope | // Slew telescope | ||
| Ligne 24: | Ligne 24: | ||
| a: | a: | ||
| b: | b: | ||
| - | c: | + | |
| + | | ||
| c.add(' | c.add(' | ||
| c.add(a); | c.add(a); | ||
| c.add(b); | c.add(b); | ||
| r: | r: | ||
| - | c.free; | + | c.clear; |
| memo_1.lines.add(r); | memo_1.lines.add(r); | ||
| end | end | ||
| else memo_1.lines.add(rsTelescopeNot); | else memo_1.lines.add(rsTelescopeNot); | ||
| - | end. | + | end. |
| </ | </ | ||
| - | 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 49: | 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 58: | Ligne 59: | ||
| begin | begin | ||
| </ | </ | ||
| - | The start of our program. | + | Le début de notre programme. |
| ---- | ---- | ||
| Ligne 65: | 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 72: | 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 80: | 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 87: | 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 |
| ---- | ---- | ||
| < | < | ||
| - | c: | + | GetSL(' |
| + | c.clear; | ||
| </ | </ | ||
| - | Create an instance of the TStringList | + | Demande un objet TStringList |
| ---- | ---- | ||
| Ligne 103: | Ligne 105: | ||
| c.add(b); | c.add(b); | ||
| </ | </ | ||
| - | Add the command and the required parameters | + | Ajoutez la commande et les paramètres requis |
| ---- | ---- | ||
| Ligne 110: | 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. |
| - | + | ||
| - | ---- | + | |
| - | + | ||
| - | < | + | |
| - | c.free; | + | |
| - | </ | + | |
| - | As soon we no more need the stringlist we destroy it to free the memory. | + | |
| ---- | ---- | ||
| Ligne 124: | 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 131: | 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 139: | 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 161: | Ligne 156: | ||
| </ | </ | ||
| - | Script | + | Script |
| < | < | ||
| function GetTickCount: | function GetTickCount: | ||
| Ligne 176: | 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 206: | Ligne 201: | ||
| </ | </ | ||
| - | Replace | + | Remplacer |
| - | ==== Connect to the ASCOM driver | + | ==== Connecter le pilote |
| - | The following | + | Le code suivant est pour le bouton |
| < | < | ||
| var | var | ||
| Ligne 225: | 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 242: | 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 259: | 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 270: | 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 |
| < | < | ||
| var r: | var r: | ||
| begin | begin | ||
| - | r: | + | |
| + | | ||
| RunOutput(' | RunOutput(' | ||
| Memo_1.lines.assign(r); | Memo_1.lines.assign(r); | ||
| - | r.free; | ||
| end. | end. | ||
| </ | </ | ||
| - | ==== 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 | ||
| Ligne 298: | Ligne 290: | ||
| end. | end. | ||
| </ | </ | ||
| + | |||
fr/documentation/script_example.1402851524.txt.gz · Dernière modification : 2015/11/06 20:37 (modification externe)
