How can I delete values in an db (step7)

Riddick

Member
Join Date
May 2010
Location
Hellevoetsluis
Posts
6
Hi, I want to delete the content of a db (STEP7) where I don't know the length of. In STL there is a command 'DBLG' where you can read out the lenght of a db, is there a way in SCL to determine the length of a db or is there another way to do this ? Thanx in advance
 
You can make function that opens db and uses dblg to check for its lenght and return it. Call that from scl program. Or use SFC 24 from scl program.
 
There is an SFC Test_DB or something that returns the lenght use that

Saw that TurpoUrpo already had posted that.. SFC24..
 
Last edited:
Call this function:

Code:
FUNCTION FC88:VOID
//Determine size of db in bytes and fill it with zeros
VAR_INPUT
DBNumber:WORD;
end_var
VAR_TEMP
iSFC21Return:INT;
iSFC24Return:INT;
Zero:BYTE;
BLK:ANY;
dbLength:WORD;
WriteProtect:BOOL;
BlockFill AT BLK: STRUCT
    id:WORD;
    Count:WORD;
    DB:WORD;
    Area:DWORD;
    END_STRUCT;
END_VAR; 
Zero:=0;
iSFC24Return:=SFC24(DB_Number:=DBNumber,DB_Length:=DBLength, WRITE_PROT:=WriteProtect);
BlockFill.id:=w#16#1002;
BlockFill.Count:=DBLength;
BlockFill.DB:=DBNumber;
BlockFill.Area:=dw#16#84000000;
iSFC21Return:=SFC21(BVAL := Zero,BLK := BLK);
END_FUNCTION
 
Do you want this done in SCL without calling SFC24 ? If so why ?

Here's one implementation.

Code:
FUNCTION FC88:VOID
//Determine size of db in bytes and fill it with zeros
VAR_INPUT
DBNumber:WORD;
end_var
VAR_TEMP
iSFC21Return:INT;
iSFC24Return:INT;
Zero:BYTE;
BLK:ANY;
dbLength:WORD;
WriteProtect:BOOL;
BlockFill AT BLK: STRUCT
    id:WORD;
    Count:int;
    DB:WORD;
    Area:DWORD;
END_STRUCT;
HighSearch:INT;
LowSearch:int;
Search:int;
END_VAR; 
Zero:=0;
BlockFill.id:=w#16#1002;
BlockFill.DB:=DBNumber;
BlockFill.Area:=dw#16#84000000;
LowSearch:=0;
Highsearch:=32767;
WHILE (HighSearch - LowSearch)>1 DO
Search:= (Lowsearch+Highsearch)/2;    
BlockFill.Count:=Search;        
iSFC21Return:=SFC21(BVAL := Zero,BLK := BLK);
IF iSFC21Return = 0 THEN Lowsearch:=Search; ELSE HighSearch:=Search;END_IF;
END_WHILE;
END_FUNCTION
 
Last edited:
Because even SFC24 is using an certain call to this db in a protected language, don't you think it's cool to just do it in scl itselfs? I think I can use the command AT but I don't know how. It isn't that important but I was just wondering if there were other way's to do this.
 
What you mean by protected language? what does it even matter, its os implemented function, that sfc 24 is just interface for it.

What about the suggestion of making fc that uses dblg to check for lenght and returns it? what is prob with it?

I'll look at how db behaves with ANY.
 

Similar Topics

Hello, someone have experience about how to delete an alarm message(alarm already solved) from alarm viewer with something coming from PLC? THANKS
Replies
3
Views
836
Hello, someone have experience about how to delete an alarm message(alarm already solved) from alarm viewer with something coming from PLC? THANKS
Replies
0
Views
384
In my project, I've set up a few user accounts (Operator, Technician, Admin). The person assigned as Admin has said "I want to be able to...
Replies
8
Views
1,150
In the Communications > Network > Protocol 1 - AB Tag Names > PLC10 configuration page there is a Tag Names section (not the same as the separate...
Replies
4
Views
2,487
Hi , How can I remove this tag without affect the instruction, i mean is only a tag with 0-1 value and I want that my instruction has only ins...
Replies
5
Views
1,622
Back
Top Bottom