Onze merken

Impact-Company-Logo-English Black-01-177x54

Welkom op de website van Schneider Electric

Welkom op onze website.
		
Hoe kunnen wij u vandaag helpen?
Using an indirect variable in Structured Text logic

DISCLAIMER

These sample programs are intended to demonstrate one or more programming functions or methods and are presented as programming examples only. Schneider Electric assumes no liability for the use or application of these example programs or any portion thereof.



It can be helpful having a code that accepts the name of an object and allows access to different methods and properties of that object. This can be accomplished by using indirect ({<string>}) and object (%O) variables. Let's use the following structured text logic as example:

TYPE
DBPnt : DATABASE_OBJECT (COpcAlgPoint)
ScannerId:DINT;
TagName:STRING;
END_DATABASE_OBJECT;
END_TYPE

PROGRAM NewStructuredTextProgram2

VAR_INPUT
objName : STRING;
END_VAR

VAR
IN AT %O({OBJNAME.EN_US}) : DBPnt;
END_VAR

IN.TagName := 'Dummy9';
IN.ScannerId := 12219;
;
END_PROGRAM


The first step is to declare a DATABASE_OBJECT for the type of point of interest, including any methods and properties we want to invoke or change. In our example we created a TYPE called DBPnt, that is derived from COpcAlgPoint. Within this object, we want to expose the "ScannerId" and "Tagname" properties, so we can change it for any object of this type.
The second part of the code accepts the name of the object we want to change the properties (objName) and use it to assign that object to our internal variable "IN", of type DBPnt. Please note the following line of code:

VAR
IN AT %O({OBJNAME.EN_US}) : DBPnt;
END_VAR


After that, we can access or change the object properties directly:

IN.TagName := 'Dummy9';
IN.ScannerId := 12219;


Please note that objName must be a VAR_INPUT variable, so this logic needs to be invoked by another logic program or script.

Schneider Electric Belgium

Ontdek meer
Productfamilie
Ontdek meer
Productfamilie

Hulp nodig?

  • Selecteer zelf het juiste product

    Vind snel en eenvoudig de juiste producten en toebehoren voor uw toepassingen.

  • Offerte aanvragen

    Dien uw aanvraag online in en een expert zal contact met u opnemen.

  • Verkooppunten

    Vind eenvoudig de dichtstbijzijnde distributeur van Schneider Electric op uw locatie.

  • Help Center

    Vind de antwoorden die u nodig heeft via bladeren door veelgestelde vragen over onderwerpen.

  • Productdocumentatie
  • Software & firmware
  • Productselector
  • Productvervanging
  • Help- en Contact Center
  • Vind onze kantoren
  • Offerte aanvragen?
  • Verkooppunten
  • Schneider Electric Community
  • Werken bij
  • Bedrijfsprofiel
  • Wangedrag melden
  • Toegankelijkheid
  • Newsroom
  • Investeerders
  • EcoStruxure
  • Vacature zoeken
  • Blog
  • Als eerste op de hoogte nieuws?
  • Privacybeleid
  • Cookieverklaring
  • Gebruiksvoorwaarden
  • Algemene verkoop- en inkoopvoorwaarden
  • Change your cookie settings