User Tools

Site Tools


en:documentation:script_example

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:documentation:script_example [2014/06/15 18:58] pchen: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:=floattostr(ra);     a:=floattostr(ra);
     b:=floattostr(de);     b:=floattostr(de);
-    c:=Tstringlist.create;+    GetSL('STRL1',c); 
 +    c.clear;
     c.add('SLEW');     c.add('SLEW');
     c.add(a);     c.add(a);
     c.add(b);     c.add(b);
     r:=cmd('',c);     r:=cmd('',c);
-    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.
 </code>   </code>  
  
Line 90: Line 91:
  
 <code> <code>
-c:=Tstringlist.create;+GetSL('STRL1',c); 
 +c.clear;
 </code> </code>
-Create an instance of the TStringList object. Be careful that everything you explicitly create must be explicitly destroyed later to avoid a memory leak.+Request a TStringList object identified by STRL1We clear any data that may stay in the object.
  
 ---- ----
Line 109: Line 111:
 </code> </code>
 Execute the command and store the result in the variable r. Execute the command and store the result in the variable r.
- 
----- 
- 
-<code> 
-    c.free; 
-</code> 
-As soon we no more need the stringlist we destroy it to free the memory. 
  
 ---- ----
Line 279: Line 274:
 var r:TstringList; var r:TstringList;
 begin begin
-  r:=TstringList.create;+  GetSL('STRL1',r); 
 +  r.clear;
   RunOutput('dir',r);   RunOutput('dir',r);
   Memo_1.lines.assign(r);   Memo_1.lines.assign(r);
-  r.free; 
 end. end.
 </code> </code>
en/documentation/script_example.1402851480.txt.gz · Last modified: 2015/11/06 20:33 (external edit)