Automaton Posted December 15, 2009 Report Posted December 15, 2009 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
tragically1969 Posted December 16, 2009 Report Posted December 16, 2009 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.
Automaton Posted December 18, 2009 Author Report Posted December 18, 2009 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
Fredrix Posted January 11, 2010 Report Posted January 11, 2010 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
Fredrix Posted January 11, 2010 Report Posted January 11, 2010 Did a small test here, and it worked very nice
Automaton Posted January 14, 2010 Author Report Posted January 14, 2010 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now