Sign in to follow this  
Followers 0
Greg

Cicode error

4 posts in this topic

Hi all, im about to write a script in cicode, i wrote part of it and try to compile it and this what i get as an error "Cicode Function greater than 64K" file size is 538 bytes, what to do? i have scripts bigger then this one and all ok. and if we are already talking about cicode, how can i write a script that checks some analog results from Twido PLC and sends into the report a message, for an example if Analog1<1 then write message "too low" in report. i have the report file and it writes exactly the same results that comes from the PLC, but if the value is low i need to display a message in the same report, report file is in word file. Thanks in advance for your instant help, Best Regards, Greg.

Share this post


Link to post
Share on other sites
This is from the knwoledgebase article: Q5070 Summary: Cicode compiler will refuse to compile some large Cicode fragments Solution: The Cicode compiler at times needs to create internal ‘Branch’ commands as the result of control structure statements (also referred to Conditional Operators) such as: IF/THEN SELECT CASE FOR WHILE The run-time Cicode processor is limited to relative jumps (positive or negative) of 32K (K=1024) in size. This is not the same as the module size limitation of 64K, but related. As a result, it is possible for Cicode functions to be less than 64K in size, but for some required branch statements to be greater than 32K. Note that only very large Cicode control structure statements will report this error. In practice, Cicode SELECT statements of two thousand lines have been seen that have this problem, and they were readily refactored to avoid this issue using methods such as those discussed here. Consider the following Cicode fragment: FUNCTION foo(INT x) IF x > 1 THEN … // sample code more than 32K END END In this situation, a conditional branch is generated around the body of the IF statement. The architecture of the Cicode run-time engine is that branches are a signed 16-bit pointer which makes a jump of more than 32K in either direction impossible. The Cicode compiler now detects this situation and forces a terminating error. The error will be reported by the compiler at the end of the block of Cicode because it is not till that point that the compiler knows how big the jump needs to be. The Cicode which receives this error needs to be re-written in such a way that jumps of more than 32K are not required. The 32K limit is within a function. The sample foo() function above could be re-written in any number of ways so that it looks similar, but does not require any large branches like so: FUNCTION foo2(INT x) IF NOT (x > 1) THEN RETURN; … // sample code more than 32K Cicode addresses END Or another method might be: FUNCTION foo2b (INT x) IF x > 1 THEN … // sample code less than 32K … // makes sure x is not modified in this block END IF x > 1 THEN // same test as the first one … // rest of the sample code, but also than 32K END END RETURN does not generate branches. Large compound statements can be decreased in size by using RETURN and starting new compound statements. Alternatively, break the 32K of Cicode instructions into 2 or more function calls. Each function has the same limitations on jump size and code size. For example: FUNCTION foo3(INT x) IF x > 1 THEN bar1(); // 1 st half of the 32K bytes of code is put in function bar1() bar2(); // 2 nd half of the code goes in bar2() END END In the case of foo3(), the branch is very small. Putting the large block of code in another function means the function foo3 is dramatically reduced in size. For example, SELECT statements could be refactored like so: FUNCTION another() SELECT CASE x CASE 1 statements CASE 2 statements … CASE 100 statements CASE ELSE Other_statements END SELECT END Becomes FUNCTION another() // refactored SELECT CASE x IF x = 1 statements; RETURN; IF x = 2 statements; RETURN; … IF x = 100 statements; RETURN; … Other_statements END The first version above would normally be preferred, and before refactoring the Cicode, we would recommend reducing the size of functions instead

Share this post


Link to post
Share on other sites
thanks for answer, iv tried something, and still cant understand and make it work, here are part of the code that makes me errors. STRING FUNCTION example() STRING ex; IF variable1 < 0.15 THEN ex = "<0.15 PPM"; ELSE ex = variable1; END RETURN ex; END when i GO TO the error it popups the Reports screen and point to "Report format file" Thanks Best Regards, Greg. Edited by Greg

Share this post


Link to post
Share on other sites
Solved the problem, just restored last backup and compile works. my cicode consist from alot internal variables, for example STRING Var1, STRING Var2.. etc. i would like to represent those variables on screen and report. i have tried to display them in the way below: <Cicode Name>("Var1") and in report(Word file) in the way below: {Cicode Name("Var1")}. in both ways popups alot errors, the main error is "Incorrect number of arguments for function". my question is how can i display the values from those variables on my screen and report anyway? Thanks in advance, Best Regards, Greg.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0