User Tools

Site Tools


Sidebar

Home

Documentation

Tutorial

Reference Manual

Installation

en:documentation:script_example

Pascal language example

Here is the code of a Pascal version of scope_unpark script you can use to unpark the telescope.

The full script code look as following:

{
  This script unpark the telescope mount
}
 
var ok,parked: boolean;
    arg: TStringList;
    r: string;
begin
 
  // telescope connected?
  GetB('TELESCOPE_CONNECTED',ok);
  if not ok then begin
    logMsg('Telescope not connected!');
    exit;
  end;
 
  // get park status
  GetB('TELESCOPE_PARKED',parked);
 
  if parked then begin
    getSl('STRL1',arg);
    arg.clear;
    arg.add('OFF');
    r:=cmdArg('TELESCOPE_PARK',arg);
    if r<>msgOK then logMsg('Telescope park: '+r);
  end
  else begin
    logMsg('Telescope already unparked');
  end;
end.                                            

Take a look at each part in detail:

{
  This script unpark the telescope mount
}

Is a comment, you can use // {..} (*..*) to enclose your comments.


var ok,parked: boolean;
    arg: TStringList;
    r: string;

Define the variable we use later in the script.
Important variable type are: integer, double, string, boolean.
The Tstringlist type is use here to send a command argument to CCDciel.


  begin

The start of our script.


GetB('TELESCOPE_CONNECTED',ok);

We ask CCDciel about the status of a boolean variable to know if the telescope is connected, the result is in our variable ok.


  if not ok then begin
    logMsg('Telescope not connected!');
    exit;
  end;

We test the result of the previous command, ok is true if the telescope is connected, so we add the negation “not” to test for “not connected”. If the result of the test “not connected” is true we execute the code block starting at “begin” up to the corresponding “end”, this write a message in the log and exit the script.


GetB('TELESCOPE_PARKED',parked);

We continue and we do the same to check if the telescope is parked, with the result in our parked variable..


    if parked then begin

We test if the telescope is parked, in this case we can unpark.


GetSL('STRL1',arg);
arg.clear;

Request a TStringList object identified by STRL1. We clear any data that may stay in the object. We need this TStringlist to pass argument to a CCDciel command.

This code is using the CCDCiel specific GetSL to access a global stringlist. An alternative way for getSL is the create a stringlist in standard Pascal as follows:

arg:=TStringList.Create;
arg.clear;

end at the end of the program free it:

arg.Free;

    arg.add('OFF');
    r:=cmdArg('TELESCOPE_PARK',arg);

Add the argument 'OFF' for the command and execute 'TELESCOPE_PARK' 'OFF'. This effectively unpark the telescope and the result is in variable r.


if r<>msgOK then logMsg('Telescope park: '+r);

We test the result is different than msgOK, in this case we write a message to the log to show the error from the driver.


 end.

The end of the script.

en/documentation/script_example.txt · Last modified: 2021/12/03 15:08 by han.k