<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to FB dynamisch instanzieren/referenzieren?</title><link href="https://forge.codesys.com/forge/talk/Deutsch/thread/77499757b2/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Deutsch/thread/77499757b2/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Deutsch/thread/77499757b2/</id><updated>2020-02-27T23:50:24.098000Z</updated><subtitle>Recent posts to FB dynamisch instanzieren/referenzieren?</subtitle><entry><title>FB dynamisch instanzieren/referenzieren?</title><link href="https://forge.codesys.com/forge/talk/Deutsch/thread/77499757b2/?limit=25#b9e6" rel="alternate"/><published>2020-02-27T23:50:24.098000Z</published><updated>2020-02-27T23:50:24.098000Z</updated><author><name>Pippen</name><uri>https://forge.codesys.com/u/pippen/</uri></author><id>https://forge.codesys.com1c076a679f1986a5d5787a21a8203b21d005fff9</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;franzhoepfinger hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
Alle FB's ein gemeinsames Interface implementieren lassen. Siehe "Factory" im Buch von Gamma&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Wie heisst dieses Buch genau?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>FB dynamisch instanzieren/referenzieren?</title><link href="https://forge.codesys.com/forge/talk/Deutsch/thread/77499757b2/?limit=25#02a4" rel="alternate"/><published>2020-02-27T23:50:22.259000Z</published><updated>2020-02-27T23:50:22.259000Z</updated><author><name>franzhoepfinger</name><uri>https://forge.codesys.com/u/franzhoepfinger/</uri></author><id>https://forge.codesys.comb2179a36bf7bbd2d7ce181625b7ccba6d38920fc</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Alle FB's ein gemeinsames Interface implementieren lassen. Siehe "Factory" im Buch von Gamma&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>FB dynamisch instanzieren/referenzieren?</title><link href="https://forge.codesys.com/forge/talk/Deutsch/thread/77499757b2/?limit=25#68dd" rel="alternate"/><published>2020-02-27T23:50:17.571000Z</published><updated>2020-02-27T23:50:17.571000Z</updated><author><name>smart9</name><uri>https://forge.codesys.com/u/smart9/</uri></author><id>https://forge.codesys.com4ffbf1d73210c7644a58e26c6ae8e5611a61ebd7</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hallo singleton,&lt;/p&gt;
&lt;p&gt;vielen Dank für Deinen Hinweis. Aber leider bin ich hier auch nicht in der Lage, dynamisch verschiedene FB's zur Laufzeit zu instanzieren und einer Referenz (bzw. Pointer) zuzuweisen. Der Pointer, welcher __New zurückgibt, muss spezifisch deklariert sein, kann nicht allgemein gehalten werden, also z.B.: POINTER TO fbModuleLeftCorner. Möchte ich demselben Pointer mit __New einen FB 'fbModuleRightCorner' allozieren, bekomme ich einen Konvertierungsfehler. &lt;br/&gt;
Ich muss also folgendermassen vorgehen, dass es für jeden mögl. FB wieder den dazugehörigen Pointer gibt, was wieder etwas unschön ist.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nt"&gt;VAR&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;uiSelection&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;UINT&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;pModuleLeftCorner&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;POINTER&lt;/span&gt; &lt;span class="nt"&gt;TO&lt;/span&gt; &lt;span class="nt"&gt;fbModuleLeftCorner&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;pModuleRightCorner&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;POINTER&lt;/span&gt; &lt;span class="nt"&gt;TO&lt;/span&gt; &lt;span class="nt"&gt;fbModuleRightCorner&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt;  &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;
&lt;span class="nt"&gt;END_VAR&lt;/span&gt;
&lt;span class="nt"&gt;CASE&lt;/span&gt; &lt;span class="nt"&gt;uiSelection&lt;/span&gt; &lt;span class="nt"&gt;OF&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;
&lt;span class="nt"&gt;cLeft&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;pModuleLeftCorner&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;__NEW&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;fbModuleLeftCorner&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;
&lt;span class="nt"&gt;cRight&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;pModuleRightCorner&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;__NEW&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;fbModuleRightCorner&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt;
&lt;span class="nt"&gt;END_CASE&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>FB dynamisch instanzieren/referenzieren?</title><link href="https://forge.codesys.com/forge/talk/Deutsch/thread/77499757b2/?limit=25#a0ef" rel="alternate"/><published>2020-02-27T23:50:15.907000Z</published><updated>2020-02-27T23:50:15.907000Z</updated><author><name>singleton</name><uri>https://forge.codesys.com/u/singleton/</uri></author><id>https://forge.codesys.com4c7d4f756ab1b7a5414b13f5d10bc4036ffc5127</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;br/&gt;
schau mal in der Hilfe nach ```&lt;/p&gt;
&lt;p&gt;__NEW&lt;/p&gt;
&lt;p&gt;&lt;code&gt;und&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;__DELETE&lt;/p&gt;
&lt;p&gt;```. Das sollte Deinen Anwendungsfall abdecken.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>FB dynamisch instanzieren/referenzieren?</title><link href="https://forge.codesys.com/forge/talk/Deutsch/thread/77499757b2/?limit=25#b8d7" rel="alternate"/><published>2020-02-27T23:50:11.210000Z</published><updated>2020-02-27T23:50:11.210000Z</updated><author><name>smart9</name><uri>https://forge.codesys.com/u/smart9/</uri></author><id>https://forge.codesys.comefa98326fc3aff13f8d70fa70df4dba3e4961927</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hallo,&lt;/p&gt;
&lt;p&gt;in einem "ManagerBaustein" möchte ich zur Laufzeit festlegen, welcher FB aufgrufen werden soll. Alle haben eine gleiche Schnittstelle nach aussen, jedoch die Implementation ist unterschiedlich. Nun könnte man hergehen, alle FB's instanzieren, und z.B. über einen 'Case' die entsprechende Instanz aufrufen und ausführen. Gibt es eine elegantere Methode, z.B. den FB dynamisch zu instanzieren oder einen Pointer auf die identische "FB-Hülle" zu legen? (Pointer of FB funktioniert nur mit der abgeleiteten Instanz, nicht mit dem Funktionsblock selbst). Oder hat jemand eine andere Idee? Vielen Dank für Eure Hilfe.&lt;/p&gt;
&lt;p&gt;Matthias&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>