Codesys: Едномерни масиви


Здравейте колеги.

В тази статия съм решил да обясня какво представляват масивите, за какво се използват и как се декларират и извикват в средата Codesys.
Какво представляват масивите.Масива е структура която съдържа подредена информация. Може да си го представите, като последователност от клетки, като всяка клетка си има свой собствен пореден номер и вътре в нея се съдържа информация. Специфичното  в случая е, че всички клетки трябва да съдържат еднотипна информация, като тя може да бъде числа, символи както дори и структури. За структурите ще говорим по-нататък.
Какво е предназначението на масивите.

  • Събирането и организирането на информация от един и същи тип
  • Използване на едно име при използване на която и да е клетка от масива, като разликата е само индекса
  • Значително се улеснява сортирането на информация

Как се използват масивите.
Най-основната декларация, съдържа само името на масива, големината и типа на данните в него.

Име: ARRAY[From..To] of INT;

Тук е важно да се отбележи, че не е задължително броенето да започва от 1 до N както е при повечето езици за програмиране. В случая нямаме ограничение да броенето да започне от 7 и да свърши на 90.Ето и един пример за реална декларация:
NewArray: ARRAY[5..20] of INT;
Също така можем да дадем стойности на масива при самата инициализация.Ще използваме горния пример:
NewArray: ARRAY[5..20] of INT := [6,49,3,659,5];
Как се извикват елементи от масива.
Достъпването на всеки един елемент от масива става като в повечето езици от високо ниво. Пишем името на масива, и в скобите добавяме индекса който искаме да достъпим. За да покажа нагледно ще декларирам нова променлива от същия тип какъвто е и масива, и ще присвоя някоя от неговите стойности.

testBoolVar: BOOL;

testBoolVar:= NewArray[1];

Индкса на масива може да бъде и променлива.

arrIndex: int:=1;

testBoolVar: BOOL;

testBoolVar:= NewArray[arrIndex];

Ако имате въпроси с гореописаните неща, моля да задайте ги в коментарите.

6 thoughts on “Codesys: Едномерни масиви

  1. By way of introduction, I am Mark Schaefer, and I represent Nutritional Products International. We serve both international and domestic manufacturers who are seeking to gain more distribution within the United States. Your brand recently caught my attention, so I am contacting you today to discuss the possibility of expanding your national distribution reach.We provide expertise in all areas of distribution, and our offerings include the following: Turnkey/One-stop solution, Active accounts with major U.S. distributors and retailers, Our executive team held executive positions with Walmart and Amazon, Our proven sales force has public relations, branding, and marketing all under one roof, We focus on both new and existing product lines, Warehousing and logistics. Our company has a proven history of initiating accounts and placing orders with major distribution outlets. Our history allows us to have intimate and unique relationships with key buyers across the United States, thus giving your brand a fast track to market in a professional manner. Please contact me directly so that we can discuss your brand further. Kind Regards, Mark Schaefer, marks@nutricompany.com, VP of Business Development, Nutritional Products International, 101 Plaza Real S, Ste #224, Boca Raton, FL 33432, Office: 561-544-0719

  2. I look after a vape shop website directory and we have had a listing from a vape store in the USA that likewise markets CBD products. A Calendar month later on, PayPal has contacted use to say that our account has been restricted and have asked us to take away PayPal as a payment solution from our vape shop directory. We do not offer for sale CBD items such as CBD oil. We simply offer advertising and marketing services to CBD firms. I have visited Holland & Barrett– the UK’s Leading Health Merchant and if you take a good look, you will see that they offer for sale a comparatively comprehensive variety of CBD product lines, specifically CBD oil and they also happen to accept PayPal as a payment solution. It seems that PayPal is applying double standards to different firms. As a result of this constraint, I can no longer accept PayPal on my CBD-related website. This has restricted my payment possibilities and presently, I am intensely contingent on Cryptocurrency payments and direct bank transfers. I have spoken with a barrister from a Magic Circle law practice in London and they explained that what PayPal is doing is completely against the law and discriminatory as it ought to be applying a systematic benchmark to all firms. I am still to consult with yet another attorney from a US law practice in The city of london to see what PayPal’s legal position is in the United States. In the meantime, I would be very appreciative if anybody here at targetdomain could provide me with alternative payment processors/merchants that work with CBD companies.

  3. By way of introduction, I am Mark Schaefer, and I represent Nutritional Products International. We serve both international and domestic manufacturers who are seeking to gain more distribution within the United States. Your brand recently caught my attention, so I am contacting you today to discuss the possibility of expanding your national distribution reach.We provide expertise in all areas of distribution, and our offerings include the following: Turnkey/One-stop solution, Active accounts with major U.S. distributors and retailers, Our executive team held executive positions with Walmart and Amazon, Our proven sales force has public relations, branding, and marketing all under one roof, We focus on both new and existing product lines, Warehousing and logistics. Our company has a proven history of initiating accounts and placing orders with major distribution outlets. Our history allows us to have intimate and unique relationships with key buyers across the United States, thus giving your brand a fast track to market in a professional manner. Please contact me directly so that we can discuss your brand further. Kind Regards, Mark Schaefer, marks@nutricompany.com, VP of Business Development, Nutritional Products International, 101 Plaza Real S, Ste #224, Boca Raton, FL 33432, Office: 561-544-0719

Leave a Reply

Your email address will not be published. Required fields are marked *