Structured Text String Alterations

Here is an experiment to make my point:
  • Create three string tags:
    • four, initialize as '4'
    • ScanSim, initialize as 'P1234'
    • ScanString, initialize as '$00$00$00$00$00$00$00$00'
  • Write and run the a program with the following rungs:
    • MOV ScanSim ScanString
      • Simulates barcode read
      • ScanString will be 'P1234' after evaluation of this rung
    • EQU ScanString.DATA[0] 80 DELETE ScanString 1 1 ScanString
      • Strips 'P' prefix
      • ScanString will be '1234' after evaluation of this rung.
      • ScanString.DATA[3] and ScanString.DATA[4] will both be '4' i.e. SINT value 52 decimal = 34H
    • MOV 53 ScanString.DATA[3]
      • Overwrite '4' in string with '5' but leaves stale '4' after string
    • MOV -99 result
      • result is a scalar INT tag
      • Ensure next command's execution can be verified
    • FIND ScanString four 1 result
      • Will overwrite value of -99 from previous rung in result with a value of 0
        • because there will be no one-character sub-string four (='4') in ScanString,
        • which proves the '4' (52 dec = 34Hex) at ScanString.DATA[4] is not part of "STRING" tag ScanString
 

Similar Topics

Hi all, I have a customer that is asking for a recipe of 200 recipes to be sorted. I'm trying to do this by way of a bubble sort. Basically my...
Replies
18
Views
3,544
Hi, For strictly development purposes I would like to save the memory address of a variable as a string (e.g. "16#FFFFFFFF"). Now, specifically...
Replies
5
Views
3,862
Hi, i am trying to compare a string value in an IF statement My string value is user defined string called Barcode_String max characters 26...
Replies
6
Views
7,386
How do I Concatenate an XML String in Structured Text? I am using codesys 2.3 with a Wago 750-852. I would expect the answer to be the same...
Replies
5
Views
4,864
Firs of all I'm working with Structured Text on B&R Automation Studio 4.0: I have a binary message on a string (collected from serial port). The...
Replies
4
Views
8,225
Back
Top Bottom