Sign in to follow this  
Followers 0
edda

Help with Cicode script

8 posts in this topic

Right now I´m up to replaceing a old citect application to a Beijer Panel... but i´m rather poor at citect so need help with this... Status = 0; DevFirst(hRiktverk); WHILE Status = 0 DO Recept_Börvärde_Old = strToInt(DevGetField(hRiktverk, "U")); Recept_Börvärde_New = Recept_Börvärde_Old + (Nollvärde_New - Nollvärde_Old); DevSetField(hRiktverk, "U", IntToStr(Recept_Börvärde_New)); Status = DevNext(hRiktverk); END Sure I know that it will be doing it untill Status isnt 0... but what is "Status"? I got the whole script here (11 pages)... Best Regards. //edmund

Share this post


Link to post
Share on other sites
Look for the string "status" in the project editor > tags > variable tags form. In Cicode you can refer to Variable tag names directly.

Share this post


Link to post
Share on other sites
Cant find it there...its beeing declare in the top of the script (INT Status = 0;)... what about this "Status = DevNext(hRiktverk);"?? what is DevNext?

Share this post


Link to post
Share on other sites
DevNext Gets the next record in a device. If the end of the database is reached, the EOF flag is set and an error code is returned. Syntax DevNext(hDev) hDev: The device handle, returned from the DevOpen() function. The device handle identifies the table where all data on the associated device is stored.

Share this post


Link to post
Share on other sites
Somewhere in your 11 pages there will be a DevOpen() this function opens a Citect device that you should be able to find in the Project Editor. The DevOpen will have a returned a handle for this device this handle is stored in hRiktverk. DevNext(hRiktverk) will step to next record in the Device. if it is successful it will return a 0 into the variable Status and will therefore remain in the loop. If it is not successfull it will return an error number and this will drop the code out of the loop. Most likely cause for it to be unsuccessful is that it reaches the end of the device BUT there could be other reasons. have a look through Citec's documentaion on error numbers.

Share this post


Link to post
Share on other sites
Ok but there is about 10 of this DevNext in the script are they all being process at the same time? Are citect script processed all the time or can they be trigged on a signal, I cant find what would start it anyhow... not sure how i can search after it, the citect version is 5.21...

Share this post


Link to post
Share on other sites
I copied this snippet from your original code.. FUNCTION Tryckrulle1() THIS LINE IS THE BEGINNING OF THE FUNCTION. SOMEWHERE ELSE IN YOUR PROJECT THIS FUNCTION WILL BE CALLED. TRY SEARCHING FOR "Tryckrulle1()" . ONCE THIS FUNCTION HAS BEEN CALLED IT WILL RUN ONCE ONLY. Minvärde_Old = LS_sw_press_roll_1_min; //Läser in "gamla" Minvärdet. Maxvärde_Old = LS_sw_press_roll_1_max; //Läser in "gamla" Maxvärdet. Nollvärde_Old = strToInt(Z_pressure_roll_1); //Läser in "gamla" Nollvärdet. Börvärde_Old = SP_pressure_roll_1; //Läser in "gamla" Nollvärdet. Maxvärde_Temp = Maxvärde_Old - Nollvärde_Old; //Beräknar skillnad mellan 0 och Max. Minvärde_Temp = Nollvärde_Old - Minvärde_Old; //Beräknar skillnad mellan Min och 0. Nollvärde_New = PV_pressure_roll_1; //Läser in nya 0-värde från ÄR-värdet. Maxvärde_New = Maxvärde_Temp + Nollvärde_New; //Beräknar nya Maxvärdet LS_sw_press_roll_1_max = Maxvärde_New; //Läser ut det nya Maxvärdet till PLCn. Minvärde_New = Nollvärde_New - Minvärde_Temp; //Beräknar nya Minvärdet LS_sw_press_roll_1_min = Minvärde_New; //Läser ut det nya Minvärdet till PLCn. // Börvärde_New = Börvärde_Old + (Nollvärde_New - Nollvärde_Old);//Beräknar nya Börvärdet // SP_pressure_roll_1 = Börvärde_New; //Läser ut det nya Börvärdet till PLCn. Z_pressure_roll_1 = IntToStr(Nollvärde_New); Status = 0; DevFirst(hRiktverk); THE DEVICE HAS BEEN OPENED ELSEWHERE ,LOOK FOR "DevOpen(hRiktverk)" .THIS LINE ENSURES THAT WE ARE AT THE FIRST RECORD IN THE DEVICE WHILE Status = 0 DO Recept_Börvärde_Old = strToInt(DevGetField(hRiktverk, "U")); Recept_Börvärde_New = Recept_Börvärde_Old + (Nollvärde_New - Nollvärde_Old); DevSetField(hRiktverk, "U", IntToStr(Recept_Börvärde_New)); Status = DevNext(hRiktverk); ONLY WHEN WE HAVE REACHED THE LAST RECORD WILL Status <> 0 THEN WE WILL JUMP OUT OF THE LOOP END END THIS LINE IS THE END OF THE FUNCTION. ANYTHING BELOW HERE IS MOST LIKELY ANOTHER FUNCTION AND WILL ONLY BE EXCUTED WHEN THAT FUNCTION IS CALLED . I hope this explains some of what your are looking for. I have had a quick look thru your code. If you have access to Citect's Example project have a look thru their recipe demonstartion it uses similar cicode to what you have posted here . If your English is good it may help .

Share this post


Link to post
Share on other sites
Thank you dua anjing.... this will help me Ok I will take a look at the examples...

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