en:documentation:script_example
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:documentation:script_example [2014/06/15 18:18] – [Use the ASCOM driver] pch | en:documentation:script_example [2016/01/20 15:55] (current) – [Script example] pch | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| This page give tips and example of scripting functions.\\ | 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. | + | 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 ===== | ===== Generality ===== | ||
| Line 22: | Line 22: | ||
| 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. |
| </ | </ | ||
| Line 90: | Line 91: | ||
| < | < | ||
| - | c: | + | GetSL(' |
| + | c.clear; | ||
| </ | </ | ||
| - | Create an instance of the TStringList object. | + | Request a TStringList object |
| ---- | ---- | ||
| Line 109: | Line 111: | ||
| </ | </ | ||
| Execute the command and store the result in the variable r. | Execute the command and store the result in the variable r. | ||
| - | |||
| - | ---- | ||
| - | |||
| - | < | ||
| - | c.free; | ||
| - | </ | ||
| - | As soon we no more need the stringlist we destroy it to free the memory. | ||
| ---- | ---- | ||
| Line 256: | Line 251: | ||
| end. | end. | ||
| </ | </ | ||
| + | |||
| + | ===== Open a document ===== | ||
| + | |||
| + | The following code open the Skychart documentation page in the default web browser.\\ | ||
| + | You can use any document type with this function, the document open with the default application the same way as if you double click the document in the file explorer. | ||
| + | |||
| + | < | ||
| + | begin | ||
| + | OpenFile(' | ||
| + | end. | ||
| + | </ | ||
| + | |||
| + | ===== Run a command ===== | ||
| + | |||
| + | There is two different way to run an external command or program, depending if you want to wait for a result or not. | ||
| + | |||
| + | ==== Wait for a result ==== | ||
| + | |||
| + | 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. | ||
| + | |||
| + | < | ||
| + | var r: | ||
| + | begin | ||
| + | GetSL(' | ||
| + | r.clear; | ||
| + | RunOutput(' | ||
| + | Memo_1.lines.assign(r); | ||
| + | end. | ||
| + | </ | ||
| + | |||
| + | ==== No wait ==== | ||
| + | |||
| + | 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. | ||
| + | |||
| + | < | ||
| + | begin | ||
| + | Run(' | ||
| + | end. | ||
| + | </ | ||
| + | |||
en/documentation/script_example.1402849109.txt.gz · Last modified: 2015/11/06 20:34 (external edit)
