Flash Pascal Flash Pascal Manual

Flash Pascal is a Pascal like language compiler that build Flash (SWF) files.


Pascal for Flash compiler (c)2008 by Paul TOTH
Pascal for Flash compiler portions (c) 2011 by Péter Gábor

Contents of the manual
Released for Flash Pascal version 0.8

This manual is a draft only, so anything or everything may be wrong and can change anytime.

This minor manual contains informations mostly about the special abilities and adventages of the Flash Pascal compiler and nothing about the pascal programing language itself, we assume that you know it.

Some words about Flash Pascal

Flash Pascal is released under the terms of GNU GENERAL PUBLIC LICENSE Version 2. See copying.txt or gnu.org for details.
The history of developement can be found in the history.txt.
The project is hosted at SourceForge.net.
The command line:

FlashPascal.exe [-?|h] [-c] [-[e][n][p][s][t][u][v][w][x]] filename
-?  display usage help message (-h)
-c  display copyright informations
-e  display error messages on programming errors
-h  display usage help message (-?)
-n  display notes stored in the source
-p  pause after execution (hit <ENTER> to exit)
-s  display buggy line of source code on error (with -e only)
-t  generate html file for (web) testing
-u  do not compress the swf file (for special needs if any)
-v  verbose mode, same as -ensw
-w  display warning messages on possible mistakes
-x  syntax checking only, no files written
filename  the file to be compiled, multiple source files are not supported

The compiler can return different exit codes (errorlevel) after execution:
0  successful execution (also if warnings were generated or no compilation started)
1  programming error
255  fatal error (eg. file i/o)

Flash Pascal internals

The _root object:

_root  the root object of every flash application is MovieClip

Base types:

CHAR  one character
STRING  character string
INTEGER  integer number
DOUBLE  double precision number
BOOLEAN  boolean
TOBJECT  undefined: any object, any type

Keywords:

PROGRAM  program file
UNIT  unit file
INTERFACE  interface section
IMPLEMENTATION  implementation section
USES  list of required units
USES ... IN ...  use specified file as source of the unit
TYPE  type definition block
CONST  constant declaration block
VAR  varible declaration block
NIL  nil (undefined object), can be compared (= or <>) with all kind of variables to test that it is defined or not
TRUE  boolean true
FALSE  boolean false
RESULT  inside a FUNCTION this holds the return value, in other places it's free to use
SELF  reference to the class in its methods
ARRAY ... OF ...  array definition
CLASS  class declaration
CLASS ... EXTERNAL ...  import external Flash class: MovieClip=external class or TMath=external class(Math)
CONSTRUCTOR  constuctor of a class
CONSTRUCTOR ... AS ...  pseudo constructor of a class: constructor Create(Parent:TObject) as Parent.Create;
INHERITED  class method is inherited
PROPERTY  class property declaration
PROPERTY ... AS ...  class property alias to override reserved words property type_:string as type;
PROCEDURE ... AS ...  procedure method alias for external Flash class method: procedure sort_(A:array of TObject;FieldName:string) as sort;
FUNCTION ... AS ...  function method alias for external Flash class method: function Copy_:TContextMenu as copy;
PROCEDURE ... OF OBJECT  procedure method prototype definition
FUNCTION ... OF OBJECT  function method prototype definition
PROCEDURE ... EXTERNAL ...  procedure alias for external Flash class method: procedure showSettings(tabID:Number) extenal System.showSettings;
FUNCTION ... EXTERNAL ...  function alias for external Flash class method: function random:double external Math.random;
PROCEDURE ...  procedure header
FUNCTION ...  function header
BEGIN ... END  code block
IF ... THEN ... ELSE ...  conditional execution
FOR ... TO ... DO ...  for block counting up
FOR ... DOWNTO ... DO ...  for block counting down
CASE ... OF ... ELSE ... END  case statements accept any kind of expression
REPEAT ... UNTIL ...  repeat block
WHILE ... DO ...  while block
EXIT  return from functions and procedures or stop swf's execution

Operators:

OR  bitwise and Boolean OR operation
AND  bitwise and Boolean AND operation
XOR  bitwise and Boolean XOR operation
NOT  bitwise and Boolean NOT operation
=  equal
>=  greater or equal
>  greater
<=  lesser or equal
<  lesser
SHRI  >>  bitwise signed shift right operation - the sign bit remains untouched, so negative value remains negative
SHR  >>>  bitwise unsigned shift right operation
SHL  <<  bitwise shift left operation
+  add
-  subtract
*  multiply
:=  assignment
DIV  divide
/  divide double precision numbers
MOD  modulus (reminder of divide)

Symbols:

..  range definition in CASE labels and ARRAY declaration
.  decimal point, structure member separator, program end.
,  parameter and ARRAY element separator
:  data TYPE assignment in VAR and FUNCTION result declarations, CASE label definition
;  statement separator
( )  parenthesis
[ ]  range definition in ARRAY declaration
{$ }  compiler switch delimiters
(* *)  comment delimiters
{ }  comment delimiters
//  comment to the end of line
$  hexadecimal number
#  character code
' '  string constant delimiters

Built-in functions:

COPY(S:string;Start,Length:Integer):string;  get a part of a string
LENGTH(S:string):Integer;  get length of a string
ORD(C:Char):Integer;  get ascii value (code) of a character
CHR(I:Integer):Char;  get character referenced by ascii value (code)
INC(N:numeric_type):numeric_type;  incremet a number (+1)
INC(N:numeric_type,N2:numeric_expression):numeric_type;  incremet a number by a specified value
DEC(N:numeric_type):numeric_type;  decrement a number (-1)
DEC(N:numeric_type,N2:numeric_expression):numeric_type;  decrement a number by a specified value
TRUNC(F:Double):Integer;  get integer part of a real number
INTTOSTR(I:Integer):string;  convert integer to string
FLOATTOSTR(F:Double):string;  convert double to string
BOOLTOSTR(B:Boolean):string;  convert boolean to string
SORT(A:array of base_type);  sort elements in an array
SORT(A:array of TObject;FieldName:string);  sort the elements in an array according to the given field
LOW(A:array of any_type):Integer;  lowest index in an array (0 for open arrays)
HIGH(A:array of any_type):Integer;  highest index in an array (including undefined items to the highest defined for open arrays)
TRACE(S:string);  write a string to the debug output (not tested)

Compiler switches:

FRAME_WIDTH pixel_count  set the width of the SWF frame
FRAME_HEIGHT pixel_count  set the height of the SWF frame
FRAME_RATE frames_per_second  set the frame rate per seconds
BACKGROUND color  set the background color of the SWF frame
VERSION flash_version  minimal version of flash required to play the compiled SWF file
NOTE any_text  important notices that can be displayed at compile time

Acknowledgment

The SWF code part is based on Sphing (Swf with PHp without mING): Copyright 2002 Igor Clukas
Deflate is based on paszlib: Copyright (C) 1998 by Jacques Nomssi Nzali
The original ZLib: Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
The SWF File Format Reference was originally written by Alexis Wilke.
Interface units based on MTASC headers: (c)2004-2008 Motion-Twin



Get FlashPascal at SourceForge.net. Fast, secure and Free Open Source software downloads Support This Project

Regards, Paul TOTH & Péter Gábor