×

Subscribe to newsletter

subscribe to our weekly newsletter to get notified with latest story and article Subscribe now!




PLC BLOG | Panasonic PLC String Instructions

Share on Facebook Share On Twitter Share on LinkedIn Share on Whatsapp


Panasonic PLC String Instructions

A string is a sequence of characters that represents text data. In PLC programming, strings are used to store and manipulate textual data such as messages, key, alarm messages, security key etc. for storing string, we use string data type. The data type STRING consists of a series of up to 32767 ASCII characters. The maximum number of characters depends on the memory size of the PLC. You can declare string data type as global variable or POU header. The syntax of string data type is String[n] =''; where n is a number of characters, the default number of characters for STRING is 32. If you are beginner so initially declare a string value because empty string causes plc error. Strings are usually enclosed in quotation marks for example ‘hello world'. Strings are often used with string manipulation functions to modify, search, or replace parts of the string.

Panasonic DELETE STRING Instructions

Panasonic DELETE STRING Instructions remove characters from a input string. It takes two input value: first the starting position of the characters to be removed, and second the number of characters to remove both input value is integer type. Parameter for Panasonic DELETE STRING Instructions as follows.
    input
  • IN : input string data type is STRING.
  • L : number of input string's characters that are deleted
  • P : start position of deletion, where 1 denotes the first character of the string
  • output
  • output : output of DELETE STRING Instructions

Panasonic DELETE STRING Instructions

above is the example of Panasonic DELETE STRING Instructions. so we have input string 'panasonic plc string example' and if we want to remove 'plc' from input string so plc in postion 11 and we remove three character from input string. so we 3 character at position no 11 from input string and finally we have output 'panasonic string example'. Always remember space is counted as 1.


Panasonic CONCAT (Concatenate) STRING Instructions

Panasonic CONCAT (Concatenate) STRING Instructions join two or more than input string. Output of CONCAT STRING Instructions is equal to string1+string2....+sting6. all input and output is string data type.

Panasonic CONCAT STRING Instructions

so in above example of Panasonic CONCAT (Concatenate) STRING Instructions we join 4 string. string_1='panasonic ', sting_2='plc ', string_3='string ', string_4='example' so we have output='panasonic plc string example' i give space after each word because it doesn’t add space between two word. Space is also counted as 1 in ASCII character.


Panasonic FIND STRING Instructions

Panasonic FIND STRING Instructions find the position of character or word in input string. If the string not found than output is zero. Parameter for Panasonic FIND STRING Instructions is
    input
  • IN1 : input string data type is STRING.
  • IN2 : string that is searched for in the input string
  • output
  • output : position at which the string searched for is found

Panasonic FIND STRING Instructions

above is the example of Panasonic FIND STRING Instructions we have input string is (IN1) = 'panasonic plc string example' and we want to find 'plc' from input string so we specified IN2 as 'plc' so we have output =11, Because plc in position 11. always remember string data type is case sensitive so if find sting is eqal to 'PLC' so output is zero because all letter in capital similarly if any one letter of find string is capital than output zero.


Panasonic FIND_AFTER_POS STRING Instructions

Panasonic FIND_AFTER_POS STRING Instructions find string, word or single character after specified position. This instruction helps when you have multiple word in your input string.

Panasonic FIND_AFTER_POS STRING Instructions

avove is the example of Panasonic FIND_AFTER_POS STRING Instructions where we find 'plc' after position 11 we have already 'plc' in 11 no position so we find 'plc' after position 11. we have input string as 'panasonic plc string example plc'.


Panasonic REPLACE STRING Instructions

Panasonic REPLACE STRING Instructions replaces the characters in the first string (IN1) at specified position (P) and specified L the number of characters to be replaced with the characters specified by second input string(IN2) . The result is written into the output variable. Replace first input string to second input string(sub string) at specified position and line number. If string find at specified position and line number.
    input
  • IN1 : input string data type is STRING.
  • IN2 : string that is replaced from in the input string
  • L : the number of characters in the input string to be replaced
  • P : position at which characters begin to be replaced
  • output
  • output : output of REPLACE STRING Instructions.

Panasonic REPLACE STRING Instructions

in above example of Panasonic REPLACE STRING we replaced 7 number of character at position 22 with string_2 from string_1. so we see 'example' from string_1 replaced with 'Instructions' and out input string is 'panasonic plc string example' and output is 'panasonic plc string Instruction'.


Panasonic INSERT STRING Instructions

Panasonic INSERT STRING Instructions, insert the second string(IN2) to first string (IN1) at specified position number(P). Replace STRING Instructions replace complete word while insert STRING Instructions only insert string at specified position.

Panasonic INSERT STRING Instructions

above is the example of Panasonic INSERT STRING Instructions where we insert sting_2 in string_1 at position 13. so you only string insert not replaced.


Panasonic LEFT STRING Instructions

Panasonic DELETE STRING Instructions


Panasonic LEN STRING Instructions

Panasonic LEN STRING Instructions (LEN) calculate the length of input string and writes the result into the output variable.

Panasonic LEN STRING Instructions

above is the example of Panasonic LEN STRING Instructions.


Panasonic MAX_LEN STRING Instructions

Panasonic MAX_LEN STRING Instructions calculate maximum string length set in the variable declaration from the input variable and writes the value into the output variable.

Panasonic MAX_LEN STRING Instructions

above is the example of Panasonic MAX_LEN STRING Instructions.


Panasonic SET_LEN STRING Instructions

Panasonic SET_LEN STRING Instructions, sets the string length of a input string, length of string is specified in input LEN which is integer data type. If the new length exceeds the maximum length of the string declaration, an error occurs and bError is set to TRUE. If you define a new string length that is shorter than the current string length, the string will be truncated to the new string length.

Panasonic SET_LEN STRING Instructions

above is the example of Panasonic SET_LEN STRING Instructions we have string_input which maximum length is 32 when we set length of input is greater than maximum length than error output is set to 1 otherwise error output is 0.


Panasonic LEFT STRING Instructions

Panasonic LEFT STRING Instructions, copy number of character of input string (IN) from left and return as output. Number of character to be copied is declared in input L.

Panasonic LEFT STRING Instructions

above is the example of Panasonic LEFT STRING Instructions.

Panasonic RIGHT STRING Instructions

Panasonic RIGHT STRING Instructions copy number of character of input string (IN) from right and return as output. number of character to be copied is declared in input L.

Panasonic RIGHT STRING Instructions

above is the example of Panasonic RIGHT STRING Instructions.


Panasonic MID STRING Instructions

Panasonic MID STRING Instructions copy number of character of input string (IN) from middle of the string and return as output. Position is declared in input P and number of character to be copied is declared in input L.

Panasonic MID STRING Instructions

above is the example of Panasonic MID STRING Instructions, in this example 3 number of character copied from input string at position 11 and return copied output.


 
Share on Facebook Share On Twitter Share on LinkedIn Share on Whatsapp


Suggested Post


 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

comment