~ Line Continuation Operator

Occasionally, it may be desirable to break a single script statement into multiple lines.  This is particularly useful when a statement is very long, or if part of the statement is variable in accordance with conditional statements.

 

Line continuations are used in definition script mostly for clarity.  That is, PSCAD will automatically break segment lines that exceed the Fortran standard of 72 columns anyway, and so the user does not normally need to worry about this.  However, to ensure that code is easily readable to everyone, line continuations should be used.

 

The line continuation operator is used as follows:  A line ending in the ~ symbol will be joined with the next line if it starts with a ~ symbol as well.  This processing is performed after conditional statements have been interpreted and is used in formatting the text for output into the Fortran or Data files.

NOTE:  The line continuation operator can be used anywhere, except it cannot be used on lines containing a directive statement. The only exception to this is the #CASE directive, which supports the use of the continuation operator.

 

 

EXAMPLE 10-23:

 

In Example 10-12, #IF, #ELSEIF, #ELSE, #ENDIF directives were used to define the output shape of a signal generator model.  The script from that example is shown again below:

 

!

! Signal Generator

!

#IF Type == 1

      $OUT = SIN(TWO_PI*$F)

#ELSE

      $OUT = COS(TWO_PI*$F)

#ENDIF

!

 

As a simple illustration of how a ~ line continuation operator can be exploited, the above script is re-written using an equivalent method:

 

!

! Signal Generator

!

       $OUT = ~

#IF Type==1

~SIN~

#ELSE

~COS~

#ENDIF

~(TWO_PI*$F)

!

 

If Type = 2, then after the #IF, #ELSEIF, #ELSE, #ENDIF directives and line continuation operators are processed, the definition script would appear as follows:

 

!

! Signal Generator

!

       $OUT = COS(TWO_PI*$F)

!