SCL newb question. Changed name of EQ_STRNG

JOLTRON

Lifetime Supporting Member
Join Date
Aug 2006
Location
MI
Posts
692
I'm not sure where to even look for an answer on this. I googled around a little but didn't see anything that helps.

In my SCL code I have " IF (tmpString1 = tmpString2) THEN"

When i do a compile i get an error "Cannot find /copy block EQ_STRNG"

Now I know when you use the "=" it automaticlly uses the FC10 for string compare, I believe that it searches for it by name "EQ_STRNG" in the project. Our company standard is that any FC's or FB's that are general system functions must start with SYS, so the name of the FC now is "SYS_EQ_STRNG".

Is there anyway I can associate the "=" with the symbolic name "SYS_EQ_STRNG". Or will I have to call the function a different way?

Regards,
Joel

Here is my code for reference:
Code:
(*##############################################################################
################################################################################
Revision History
################################################################################
 YYYY MM DD
(2011-06-08 v0.1)   Creation of the routine.
##############################################################################*)
FUNCTION SYS_TraceArray : INT    // set up attributes that will be displayed in the 'Blocks' section
TITLE       = ''
VERSION     : '1.0'
AUTHOR      : 'JW'
NAME        : ''
FAMILY      : 'TRACE'
(*##############################################################################
Inputs -- Discrete Inputs or other Constant Values
##############################################################################*)
VAR_INPUT
          TraceNumber : STRING[10];
          Side_in    : INT;  // This is the side the trace number was welded on 1=A, 2=B
          Selection : INT;   // 1 = find this trace number, 2 = delete this trace number, 3 = add this trace number            
END_VAR
 
(*##############################################################################
Outputs -- Discrete Outputs
##############################################################################*)
VAR_OUTPUT
    Side_out   : INT;
END_VAR
 
(*##############################################################################
Inputs Passed by References (may be modified apart from this routine)
##############################################################################*)
VAR_IN_OUT
    TraceBuffer : ARRAY[1..100] OF TraceAndSide;     
END_VAR
 
(*##############################################################################
Static Variables
##############################################################################*)
VAR
    i                        : INT ;             // iterator
    Match                    : BOOL;
    Move                    : BOOL;
    tmpString1:STRING[10];
    tmpString2:STRING[10];
END_VAR
 
 
BEGIN
 
  SYS_TraceArray := -1;
  Move := 1;
  tmpString2 := TraceNumber;
 
 
  CASE Selection OF
    1:  // search for the trace number and return the Side number
        FOR i := 1 TO 100 DO  
 
            tmpString1 :=   TraceBuffer[i].TraceNum;
            IF (tmpString1 = tmpString2) THEN             
            //IF (tmpString1 = tmpString2 ) THEN
              SYS_TraceArray := i;  
              Side_out := TraceBuffer[i].Side;      
              EXIT;
            END_IF;    
 
        END_FOR;   
 
    2: // find and delete this trace number, then bump the remaining items to close the gaps  
        FOR i := 1 TO 100 DO
 
            tmpString1 :=   TraceBuffer[i].TraceNum;
 
            //If trace number is found clear it out        
            IF (tmpString1 = tmpString2 ) THEN
              SYS_TraceArray := i;  
              TraceBuffer[i].TraceNum := '0000000000';
              TraceBuffer[i].Side := 0;
 
              //After trace number is deleted close the gap by bumping up the rest of the entries
              WHILE i <= 99 AND Move DO
 
                  tmpString1 :=   TraceBuffer[i].TraceNum;
                  tmpString2 :=   TraceBuffer[i+1].TraceNum;
 
                  //If the next trace is not equal to zero bump it up
                  IF tmpString2 <> '0000000000' THEN 
                    TraceBuffer[i].TraceNum :=TraceBuffer[i+1].TraceNum;
                    TraceBuffer[i].Side :=TraceBuffer[i+1].Side;
                  //If next trace is equal to zero then zero out current trace and set Move to zero to finish loop
                  ELSE
                    TraceBuffer[i].TraceNum := '0000000000';
                    TraceBuffer[i].Side := 0;
                    Move:=0;
                  END_IF;
 
                  i:= i+1;
              END_WHILE ;
 
              EXIT;
            END_IF;    
 
        END_FOR;   
 
    3: // first see if this number already exists, if it does then use this spot and just update the user Side
       // if it doesn't exist then find an empty spot and add this trace number end Side
       // if the new trace occupied position 99 then clear out the first 10 entries and shift the remaining data up  
 
         FOR i := 1 TO 100 DO //If trace number is already in the DB update the side then exit       
 
            tmpString1 :=   TraceBuffer[i].TraceNum;
 
            IF (tmpString1 = tmpString2 ) THEN
              SYS_TraceArray := i;  
              TraceBuffer[i].Side := Side_in;      
              EXIT;
            END_IF;    
        END_FOR;
 
        IF SYS_TraceArray = -1 THEN   // didn't find the number in the current list so look for an empty spot to enter it
            FOR i := 1 TO 100 DO 
 
                tmpString1 :=   TraceBuffer[i].TraceNum;
 
                IF (tmpString1 = '0000000000' ) THEN
                  SYS_TraceArray := i;  
                  TraceBuffer[i].TraceNum := TraceNumber;
                  TraceBuffer[i].Side := Side_in;    
                  EXIT;
                END_IF;    
            END_FOR;   
        END_IF;
 
         IF SYS_TraceArray >= 99 OR SYS_TraceArray = -1  THEN   // If number was entered in position 99 then re-organize
 
            FOR i := 1 TO 99 DO //Move data from 11 thru 99 up 10 positions into 1 thru 89 then clear out 90 - 99
 
                IF i<90 THEN
                    TraceBuffer[i].TraceNum :=TraceBuffer[i+10].TraceNum;
                    TraceBuffer[i].Side :=TraceBuffer[i+10].Side;
                ELSE
                    TraceBuffer[i].TraceNum := '0000000000';
                    TraceBuffer[i].Side := 0;
                END_IF;
 
            END_FOR;
 
        END_IF;
 
 
  END_CASE;
 
END_FUNCTION

I am assuming I cannot change the symbolic name it automaticlly uses and will have to go the route of:
IF SYS_EQ_STRNG(S1 := tmpString1 ,tmpString2 ) THEN
 
Last edited:
I am assuming I cannot change the symbolic name it automaticlly uses and will have to go the route of:
IF SYS_EQ_STRNG(S1 := tmpString1 ,S2:= tmpString2 ) THEN

This is a correct assumption. NB your temp Variables in the FC you have posted are named as STAT!
 
Took me a little bit to figure out what NB means. Am I correct that it is a Latin acronym for "please note"?

Thanks for pointing that out. It should be:
Code:
VAR_TEMP
    i                        : INT ;             // iterator
    Match                    : BOOL;
    Move                    : BOOL;
    tmpString1:STRING[10];
    tmpString2:STRING[10];
END_VAR

I am supprised that it doesn't throw a fault for that. I copied my FC and pasted it into another project without the SCL code in it so I could view the interface window. And even tho it is a VAR since it is compiled as an FC it puts them in the TEMP area of the window.

Regards,
Joel

SCL Stat as FC.png
 

Similar Topics

HI i would like to know how to get a variable that will store the amount of times a program has been executed. The issue is I have 3 DBs for 1 FB...
Replies
2
Views
82
Hi, I have an intermediate-advance knowledge of programming with TIA Porta in Ladder, would you recommend me to start learning SCL for it to...
Replies
11
Views
566
Hello nice to meet you, im new in here, I'm currently trying to convert code written in STL for a S7-400 to SCL for an S7-1500, because when i run...
Replies
5
Views
325
Hi everyone, I am new to this amazing world of PLC, well... I mean, in practice, since I already knew electronics, programming languages, IT, and...
Replies
7
Views
656
Hi all, This is my first post; I am new to PLC Controls stuff and English is not my native language, so I apologize in advance if something is...
Replies
4
Views
514
Back
Top Bottom