Difference between revisions of "ReNamer:Pascal Script:Quick guide"

From den4b Wiki
Jump to navigation Jump to search
Line 5: Line 5:
 
<tt>''&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ProgramName'' (''FileList'')''';'''</tt>  
 
<tt>''&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ProgramName'' (''FileList'')''';'''</tt>  
  
<tt>'''CONST''' </tt> <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </tt>
+
<tt>'''CONST''' </tt> <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </tt>  
  
 
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;''Constant declarations&gt;''</tt>  
 
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;''Constant declarations&gt;''</tt>  
  
'''TYPE''' <tt>&nbsp;&nbsp;&nbsp;</tt>
+
'''TYPE''' <tt>&nbsp;&nbsp;&nbsp;</tt>  
  
<tt>&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &lt;''Type declarations&gt;''</tt>
+
<tt>&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &lt;''Type declarations&gt;''</tt>  
  
<tt>'''VAR'''</tt>
+
<tt>'''VAR'''</tt>  
  
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;''Variable declarations&gt;''</tt>
+
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;''Variable declarations&gt;''</tt>  
  
<tt></tt> <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;''definitions of subprogram&gt;''</tt>
+
<tt></tt> <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;''definitions of subprogram&gt;''</tt>  
  
 
'''BEGIN'''
 
'''BEGIN'''
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;''Executable statements&gt;''</tt>
+
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;''Executable statements&gt;''</tt>  
  
 
<tt>'''END.'''</tt>
 
<tt>'''END.'''</tt>

Revision as of 18:16, 9 July 2009

Basic control flow in a pascal script

PROGRAM

        ProgramName (FileList);

CONST        

        <Constant declarations>

TYPE    

        <Type declarations>

VAR

        <Variable declarations>

        <definitions of subprogram>

BEGIN         <Executable statements>

END.

Control Structures

All the typical control structures (building blocks) occurring in Pascal Script are described in the following table.

The table shows a flow chart and Pascal Script code required to implement that logic. You can simnply copy and paste these blocks and then edit them to finish your script.

In actual implementation, just substitute the following:

  • Replace <condition> with an actual Pascal statement that tests for a condition.
  • Replace <Action> with code block that takes action relevant to the condition.
Control structure
Pascal script
Flowchart
If-then
if <condition> then

begin

<Action>

end;

[[Image:]]
If-then-else
if <condition> then

begin

<Action-1>

end else

begin

<Action-2>

end;

[[Image:]]
for
for I:=x to y do

begin

<Action>

end;

[[Image:]]
while
while <condition> do

begin

<Action>

end;

[[Image:]]
case/switch
(exclusive)
case x of


1: begin

<Action-1> Break

end;


2: begin

<Action-2> Break

end;


//repeat for other cases


else begin

<Default Action>

end;


end;

[[Image:]]
case/switch
(fall-through)
case x of


1: begin

<Action-1>

end;


2: begin

<Action-2>

end;


//repeat for other cases


else begin

<Default Action>

end;


end;

[[Image:]]
Repeat until
repeat

<Action>

until <condition>;

[[Image:]]
Break
Continue
Exit