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, I have recently been having trouble assigning a string tag to some characters in rs logix 5000. I initially though you could just do...
Replies
3
Views
93
Hello everyone, Wondering if anybody can help me with this: I have a CompactLogix processor running a little robot cell. Every 200 cycles...
Replies
8
Views
170
All, I am trying to reset timers when a Work Order change occurs. The Work Order comes in as a string and I am comparing it to a tag...
Replies
2
Views
115
Hello, I am using studio 5000 pro and am trying to figure out the structured text. Here's my scenario: An operator scans a barcode, the barcode...
Replies
15
Views
359
I am creating a global object in FTView SE 13. I want to have a string read from the PLC and display (in this case the tagname). So lets say...
Replies
4
Views
206
Back
Top Bottom