IMetabase.CreateCodeBlock

Syntax

CreateCodeBlock: IMetabaseCodeBlock;

CreateCodeBlock(): Prognoz.Platform.Interop.Metabase.IMetabaseCodeBlock;

Description

The CreateCodeBlock method returns an object that contains a code on Fore.

Example

Add a link to the Metabase system assembly.

Sub UserProc;
Var
    Mb: IMetabase;
    Block: IMetabaseCodeBlock;
    a: Array;
    v: Variant;
Begin
    Mb := MetabaseClass.Active;
    Block := Mb.CreateCodeBlock;
    Block.References := 
"MathFin";
    Block.Text := 
"Sub M;" + #10 +
        
"Begin" + #10 +
        
" Debug.WriteLine(Math.Round(100.959, 2).ToString);" + #10 +
        
"End Sub M;" ;
    
If Block.Valid Then
        v := Block.Execute(
"M", a);
    
Else
        Debug.WriteLine(Block.ErrorMessage + 
". string " + Block.Line.ToString + ". position " + Block.Position.ToString);
    
End If;
    
Dispose Block;
End Sub UserProc;

Public Shared Sub Main(Params: StartParams);
Var
    Mb: IMetabase;
    Block: IMetabaseCodeBlock;
    a: Array;
    v: Object;
Begin
    Mb := Params.Metabase;
    Block := Mb.CreateCodeBlock();
    Block.References := "MathFin";
    Block.Text := "Sub M;" + char.ConvertFromUtf32(13) +
        "Begin" + char.ConvertFromUtf32(13) +
        " Debug.WriteLine(Math.Round(100.959, 2).ToString);" + char.ConvertFromUtf32(13) +
        "End Sub M;" ;
    If Block.Valid Then
        v := Block.Execute("M", a);
    Else
        System.Diagnostics.Debug.WriteLine(Block.ErrorMessage + ". string " + Block.Line.ToString() + ". position " + Block.Position.ToString());
    End If;
    System.Runtime.InteropServices.Marshal.ReleaseComObject(Block);
End Sub;

After executing the example the Block variable contains the object that is a code block on Fore.

See also:

IMetabase