String misbehave !

manmeetvirdi

Member
Join Date
Oct 2004
Location
India.
Posts
750
Hi there
As shown in the picture the initial values of the D1 is '01' but when i see it in VAT it shows w#16#3131 which is ASCII equivalent '11'. Similarly D2 shows w#16#3220 which is ASCII equivalent of '2 ' [ie 2 and space]
While D10 shows correct value.Only variable having preceding value of '0' misbehaves ! Why?

string.JPG
 
This is with an empty OB1 - or do you have any code running that can access these strings ?

It will be your code "misbehaving"
 
Last edited:
How did you create the entries in DB4 - did you use any copying/pasting?

The screen shot of the DB does not tell us the contents of DB4 as it shows the initial values column (declaration view). What does the Data view show ? Post the source code of the DB.
 
Hi there
As shown in the picture the initial values of the D1 is '01' but when i see it in VAT it shows w#16#3131 which is ASCII equivalent '11'. Similarly D2 shows w#16#3220 which is ASCII equivalent of '2 ' [ie 2 and space]
While D10 shows correct value.Only variable having preceding value of '0' misbehaves ! Why?

I don't have my S7 laptop infront of me, but I recall getting burned by this before. If I recall correct, there are two views of a DB, the initial view of DB4 and the actual view of DB4.

I bet along the way, some code has altered the actual DB4, and your initial view values have not been updated.
 
Hi there LD
Source code
Code:
DATA_BLOCK "Ignore"
TITLE =
VERSION : 0.1


  STRUCT     
   D1 : STRING  [2 ] := '01';    
   D2 : STRING  [2 ] := '02';    
   D3 : STRING  [2 ] := '03';    
   D4 : STRING  [2 ] := '04';    
   D5 : STRING  [2 ] := '05';    
   D6 : STRING  [2 ] := '06';    
   D9 : STRING  [2 ] := '09';    
   D10 : STRING  [2 ] := '10';    
   D11 : STRING  [2 ] := '11';    
   D12 : STRING  [2 ] := '12';    
   D13 : STRING  [2 ] := '13';    
   D14 : STRING  [2 ] := '14';    
   D17 : STRING  [2 ] := '17';    
   D18 : STRING  [2 ] := '18';    
   D23 : STRING  [2 ] := '23';    
   D24 : STRING  [2 ] := '24';    
   D29 : STRING  [2 ] := '29';    
   D30 : STRING  [2 ] := '30';    
   D35 : STRING  [2 ] := '35';    
   D36 : STRING  [2 ] := '36';    
   D41 : STRING  [2 ] := '41';    
   D42 : STRING  [2 ] := '42';    
   D45 : STRING  [2 ] := '45';    
   D46 : STRING  [2 ] := '46';    
  END_STRUCT ;    
BEGIN
   D1 := '1'; 
   D2 := '2 '; 
   D3 := '3 '; 
   D4 := '4 '; 
   D5 := '5 '; 
   D6 := '6 '; 
   D9 := '9'; 
   D10 := '10'; 
   D11 := '11'; 
   D12 := '12'; 
   D13 := '13'; 
   D14 := '14'; 
   D17 := '17'; 
   D18 := '18'; 
   D23 := '23'; 
   D24 := '24'; 
   D29 := '29'; 
   D30 := '30'; 
   D35 := '35'; 
   D36 := '36'; 
   D41 := '41'; 
   D42 := '42'; 
   D45 := '45'; 
   D46 := '46'; 
END_DATA_BLOCK

Wow dint knew that source code of DBs can be created !!:oops:

Source code shows that actual values of D1 is being stored as D1 := '1'; still question remains why the ASCII equivalent '11' is shown in VAT table.
D2 is being stored as D2 := '2 '; This is now explained.

As curlyandshemp said DB has two views and if i would have seen the data view of the DB then I may have got what source code revealed.
But why does Deceleration view differs from Data view when Iam using this DB only for reading and not writing.

My idea about this DB was that if any string of this DB matches with incoming packet then ignore it. So in program I was just reading this DB and not writing anything in it.I was struck with single digit entries as they were not behaving as per my expectation.Though I solved this by writing inside OB1
L W#16#3031 [ascii equivalent of 01]
T DB4.DBW 2 [in case of DB1]

but was flabbergasted to see what I was seeing !!
 
Hi
Ok seems that ghost decided to reside inside DB4. Created DB2 and wrote the same thing as in DB2 and it worked as expected.
May be I have created DB4 when I was having bad time like --> o_O

Thanks....
 

Similar Topics

Hello Inside a FB, I´m trying to transfer a string from a DB to a IN_OUT var that was define as a UDT. The problem is that i can´t determine the...
Replies
4
Views
84
As the title says, I'm using CCW with a PV800 (and Micro850). I've made a scheduler in which a user can choose a month, day (1-31), hour (0-23)...
Replies
15
Views
454
Hello, So i managed to read the string coming from control logix and put a string display in PanelView 800. Now I am struggling to do the other...
Replies
1
Views
115
Does anyone know why my one string is displaying this way? It is causing issues with my HMI displaying it.
Replies
4
Views
241
Hello Guys, I am using 1769-L36ERMS PLC by Rockwell which doesn't let me MOV or COP literal text into string datatype? i very well know the...
Replies
13
Views
354
Back
Top Bottom