Sign in to follow this  
Followers 0
Automaton

Citect,Cicode Forms,

6 posts in this topic

Hello I am working on a project with Citect 7.10 I am having some difficulties with the forms. Basically I trigger the function "EndOfShipping()" from an event the looks at the change of a bit from 0 to 1 Once triggered the code creates a Form with the yes, no buttons as configured below. When I click yes , the "StopShip()" function is carried out. Everything works fine, The catch is when more than one event is triggered, what I want is to stack the forms on top of each other so that the user can deal with them in turn. I have managed to get the pop ups to stack on top of each other ( code commented out) but the yes functionality only works for the most recently triggered form. I am sure that this is down to me using the same hForm object. Does anybody have any advice on what is the best way to achieve this? Any help would be greatly appreciated. INT FUNCTION EndOfShipping(STRING N,INT S,INT F) CurrentFb = F; IF (ReadTagBit(S,2)=1) THEN //IF FormActive(hForm) THEN //FormDestroy(hForm); //END Msg = "Stop Shipping? "; hForm = FormNew(N,44,2,16); FormButton(15,1," Yes ",StopShip,0); FormButton(24,1," No ",0,1); FormPrompt(0,0,Msg); FormRead(0); RETURN 0; END END INT FUNCTION StopShip() IF FormActive(hForm) THEN FormDestroy(hForm); END Alarm_Control_Reg_S =CurrentFb BITOR 0x04; RETURN 0; END

Share this post


Link to post
Share on other sites
If you dont mind an honest answer.......I wouldnt have done it with forms I like to see what i am doing and as there is no graphical develpoment environment for forms in Citect thats pretty hard. I would have just developed my own page and popped this from the event, if there are lots with different text etc. i would have used a supergenie to wrap it all in. You could even just use the message() function, it will return 0 if the OK button is pressed. I know thats not much help but i think its a bit cleaner than using forms for a simple task like you have.

Share this post


Link to post
Share on other sites
Hi tragically1969 Thanks for the response, I was thinking along a similar line after thinking about it a bit more. I find the Cicode forms very handy for quick pop ups as they are very quick to make but are a bit trickier to manage. I did manage to get it working by writing a Cicode routine that acts as a First in First out buffer to store and process the pop up requests but this has made it more complicated than it needs to be. I think I will re do it with a Super Genie as you suggested Regards Automaton

Share this post


Link to post
Share on other sites
Hi, It looks to me like hForm is a global variable, that's why it only works for the last form If you do like this instead, it should work: INT FUNCTION StopShip() INT hCurrForm, hCurrField; FormCurr(hCurrForm, hCurrField); FormDestroy(hCurrForm); Alarm_Control_Reg_S =CurrentFb BITOR 0x04; RETURN 0; END

Share this post


Link to post
Share on other sites
Did a small test here, and it worked very nice

Share this post


Link to post
Share on other sites
Hi Fredrix Thanks for your reply. Looking at your code, what you say makes sense. For this project I ended up scrapping the Cicode forms and used a pop up form /Supergenie But I will try your method as I do find using Cicode forms great for quick simple Yes/No type forms. Regards Automaton

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