Decision Structures

Top  Previous  Next

 

Decision structures allow users to control the flow of the scripting logic.  Decision structures execute specific blocks of script based on one or more conditions.

 

1."if" EXPR "then" BLOCK |
2."if" EXPR "then" BLOCK "else" BLOCK |

 

 

INSTR = "if" EXPR "then" BLOCK |

 

-Example 1:

// If bFileExists is true then deletes file

If bFileExists=True Then DeleteFile(File);

 

-Example 2:

// If bFileExists is true then

If bFileExists=True Then

Begin

//…It deletes file

DeleteFile(File);

 

//…It creates a directory

CreateDir ('c:\files');

 

//…It creates a file

CreateFile(File);

End;

 

INSTR = "if" EXPR "then" BLOCK "else" BLOCK |

 

-        Example 1:

// If bFileExists is true then deletes file otherwise create file

If bFileExists=True Then DeleteFile(File) Else CreateFile(File);

 

-        Example 2:

// If bFileExists is true then

If bFileExists=True Then

 

// Delete file

DeleteFile(File)

 

//…otherwise…

Else

Begin

//…It creates a directory

CreateDir ('c:\files');

 

//…It creates a file

CreateFile(File);

End;