Change the first letter of a string in the global DB (Siemens STL)

Aleksandra

Member
Join Date
May 2018
Location
Belgrade
Posts
35
Hello everyone,

I have made a sample project with one FC, and one global DB with a few strings.

In the global DB all strings are written lowercase. In the FC block, I load the first letter of the first string, and I check if it is lowercase. Since this condition is fullfiled, I want to change it to uppercase. Here comes the problem.

OPN "Strings" // Here I open DB with strings

L 0
SLD 3
LAR1 // Here I make the pointer

L DBB [AR1,P#2.0] // Load the first character of the first string
T #FirstChar
A( // Here I check if it is lowercase
L #FirstChar // with the help of ASCII table
L 96
>I
)
A(
L #FirstChar
L 123
<I
)
JC Chng

Chng: L #FirstChar // Since the condition is fullfiled I convert
L 32 // the ASCII code of the small letter
-I // to the ASCII code of the big letter
T #ChangedChar // I transfer it to the local variable just for check
T DBB [AR1,P#2.0] // BUT, when I try to transfer it to the global DB
// it doesn't work!!!

Can anyone please help? What am I missing?

I am using STEP 7, CPU 315-2 PN/DP.
 
I have tested it with and without the jump, that is not the problem.


Yes, I open the DB (see the first line of code), and I successfully read the first character of the first string (I have seen this in ACCU1). I also successfully test if it is lowercase (I have also seen this in monitoring mode).


The only problem comes with the last line of code, when I try to transfer the byte (char), converted from lowercase to uppercase, INTO the DB.
 
Are you calling the FC all the time?
When you say it doesn't work, what information are you looking at?
 
Yes, in the OB1 I have written:


CALL FC 1


Shouldn't it be like that?


I know that it doesn't work because values in the ACCU1 are changing constantly (I don't know how and why). When I go online in the DB, I don't see any changes - the first character stays lowercase, it doesn't change to uppercase.


If I do exactly the same thing with variable of type INT, it works fine, it changes the value in global DB.
 
You cannot monitor a string in a db, use a VAT table with chars.
As you are not skipping the case conversions if the char is not lower case, you are subtracting 32 from DBB2 every scan.

uc.jpg
 
The only thing that comes to my mind is the following: When I try to write the uppercase character into the DB, I write:


T DBB [AR1, P#2.0]


Should I somehow convert the value form ACCU1 to Byte?


I am going nuts...
 
Code fixed: (NB I used a different symbol name for the DB)
Reload the string by downloading DB1 after you have fixed the FC



Code:
      OPN   "dbstrings"                 // Here I open DB with strings

      L     0
      SLD   3
      LAR1                              // Here I make the pointer

      L     DBB [AR1,P#2.0]             // Load the first character of the first string
      T     #Firstchar
      A(                                // Here I check if it is lowercase
      L     #Firstchar                  // with the help of ASCII table
      L     96
      >I    
      )     
      A(    
      L     #Firstchar
      L     123
      <I    
      )     
      JC    Chng
      JU    Noch

Chng: L     #Firstchar                  // Since the condition is fullfiled I convert
      L     32                          // the ASCII code of the small letter
      -I                                // to the ASCII code of the big letter
      T     #changedchar                // I transfer it to the local variable just for check
      T     DBB [AR1,P#2.0]             // BUT, when I try to transfer it to the global DB
Noch: NOP   0
 
Code fixed: (NB I used a different symbol name for the DB)
Reload the string by downloading DB1 after you have fixed the FC



Code:
      OPN   "dbstrings"                 // Here I open DB with strings

      L     0
      SLD   3
      LAR1                              // Here I make the pointer

      L     DBB [AR1,P#2.0]             // Load the first character of the first string
      T     #Firstchar
      A(                                // Here I check if it is lowercase
      L     #Firstchar                  // with the help of ASCII table
      L     96
      >I    
      )     
      A(    
      L     #Firstchar
      L     123
      <I    
      )     
      JC    Chng
      JU    Noch

Chng: L     #Firstchar                  // Since the condition is fullfiled I convert
      L     32                          // the ASCII code of the small letter
      -I                                // to the ASCII code of the big letter
      T     #changedchar                // I transfer it to the local variable just for check
      T     DBB [AR1,P#2.0]             // BUT, when I try to transfer it to the global DB
Noch: NOP   0

You are awesome! It works 🍻
 

Similar Topics

We had one go down. we have a new one. Their emergency Number don't work. The Model is TLSA046AAH-330N01-007 A catalog says we need software TET...
Replies
2
Views
136
“The HMI files we cannot open—they were saved in V13—we do not have that—I cannot restore file –please have them save in V11 and send them back to...
Replies
4
Views
135
Hi guys! I'm working in Studio 5000 and have a bunch of armorstarts there (+- 40). I need to set up parameters for each of them, mostly just same...
Replies
0
Views
75
Hello brothers We are contacting you because an error like [display change is currently controlled remotely] occurred while using the equipment we...
Replies
2
Views
176
Hi all. I'm trying to set up communication between a 1756-L72 (EN2TR) and a 1756-L82 (CPU port) using produced / consumed tags. From the L72...
Replies
13
Views
343
Back
Top Bottom