PREFIX/END PREFIX statements  

Purpose

Executes a series of statements, each of which utilizes pre-defined source code.

Syntax

PREFIX "source code"

  [additional statements]

END PREFIX

Remarks

PREFIX/END PREFIX statements enclose a set of statements, each of which has the same specified "source code" prepended.  The "source code" (in languages which support it) is usually required to be the name of an object variable.  However, in PowerBASIC, this definition has been expanded greatly to allow virtually any code to be used.  This reduces repetitive typing and reduces the risk of typing errors.  For example:

PREFIX/END PREFIX

Compiles as:

PREFIX "MyObject."

  Init(xx)

  Sleep(2)

END PREFIX

MyObject.Init(xx)

MyObject.Sleep(2)

PREFIX "MyStruc."

  Height = 220

  Width  = 345

  Color  = %Blue  

END PREFIX

MyStruc.Height = 220

MyStruc.Width  = 345

MyStruc.Color  = %Blue

PREFIX "ASM"

  Mov  Eax, Ebx

  Mov  Ecx, &H14

  IMul Eax, Esi

END PREFIX

ASM Mov  Eax, Ebx

ASM Mov  Ecx, &H14

ASM IMul Eax, Esi

If the "source code" prefix refers to an object variable or a UDT structure variable, be sure it ends with a period (.) to reference members of that item.  Otherwise, be sure it contains whole words. Just as with macros and line continuations, you cannot put half a word on one line, and half a word on another.  For example, the following code is illegal and will generate an exception:

PREFIX "PRI"

  NT #1, "Hello World"

END PREFIX

PREFIX/END PREFIX structures may not be nested.

See Also

ASM ALIGN