title: TwinCat How To Initialize Functionblock with Reference to Global Variable
body: <p>Hello StackOverflow Community,</p>
  
  <p>i have another question regarding the TwinCat/Beckhoff/Codesys Programming Language, maybe someone is able to help me with this problem.</p>
  
  <p>Here is the Problem:
  I want to initalize a functionblock with a reference to some variable. (In this example a simple bool).
  Hereby i want to make use of the FB_Init Method.</p>
  
  <p>The Functionblock itself looks something like this:</p>
  
  <pre><code>FUNCTION_BLOCK PUBLIC FB_Ref
  VAR
      reftoBool : REFERENCE TO BOOL;
  END_VAR
  
  </code></pre>
  
  <p>The FB_Init Method looks something like this:</p>
  
  <pre><code>METHOD FB_init : BOOL
  VAR_INPUT
      bInitRetains : BOOL := FALSE;
      bInCopyCode : BOOL := FALSE;
      reftoBoolIn : REFERENCE TO BOOL;
  END_VAR
  
  
  
  reftoBool := reftoBoolIn; 
  
  </code></pre>
  
  <p>The problem is that i can't get the code to work.. i don't know what im doing wrong.</p>
  
  <p>Thanks in advance...</p>