CitectSCADA cicode help

Stalker

Member
Join Date
Feb 2010
Location
Hungary
Posts
8
Hello,

i would like make a simpe cicode program. I just wanna change an object color when the mouse on it. Im new in cicode so in 1st step I just want make a test cicode which was:

DspGetMouse(X, Y);
IF X>300 THEN
FileDelete("C:\Report.Txt");
END

so read mouse x,y cordinates and make a filedelete. / Citect ver. 6.1 /

The compiler return with 2 errors. I attached them below.
(I tried DspGetMouse(X,Y) and DspGetMouse(X, Y) too)

66054437.png


84786146.png


Any ideas? 🤞🏻
 
You need to link back to the X and Y variables somewhere, you dont need them a actual variables so just use them in the function.

Its much easier if you make a cicode file and a function to do this and call the function from the button, something like this:

FUNCTION Delete_File()

INT iX, iY

DspGetMouse(iX, iY)

IF iX > 300 THEN
FileDelete("C:\Report.Txt");
END


 
Last edited:
So I save the code with Cicode editor to a .ci file.

And after how? I put down a button and have Apperance, Movement, Input and Access tabs... :rolleyes:
 
Start the Cicode editor, paste the text in to it from my post, save the file as a name of your choosing

On the button up action put Delete_File()

Compile the project........see what happens !!

Next question, why do you want to know the location of the mouse to delete a file ?
 
Actually i would like change object color if the mouse over it :) The file delete was just a test how the things are work.

Maybe you can help me with that. My plan is if mouse pointer is in the specified area x1,y1 and x2,y2 then A object change color. (i donno how change color so I just draw a similar object with different color and hide/show it.

My other problem: i need the mouse cordinates in the plantviewer only, but the DspGetMouse read cordinates from all windows desktop :|

As I said Im a beginner ... đź“š
 
There is an inbuilt function in Citect - DspGetMouseOver(iAn) - you can use this in the "Fill" properties of an object (text, box, any object with dynamic properties) to change the color when the mouse is over it.
Actual code is in Cicode (assuming you are running at least ver 6) - you can look at it to see how it was implemented.
If you know the coordinates of your Plantviewer, you will need to write another Cicode function limiting the DspGetMouse(iX,iY) Coordinates to a bounded area. A dynamic window would take a bit more work - if you are keeping track of your window numbers, you may be able to drag the properties out of it (WndFind() and WndInfo()- or you may need to momentarily set your focus on it and fix its size.

I'll leave you to the help files for these
 
Okay, i made this:

FUNCTION Show_kor(INT iE, INT iG)

INT MouseeX, MouseY, AN_num, AN_x, AN_y,

DspGetMouse(MouseeX, MouseY)
AN_num = DspGetAnFromPoint(MouseeX, MouseY)

IF AN_num=iE OR AN_num=iG THEN

DspAnMove(iG,30000,0)

ELSE

AN_y = DspGetAnBottom(iE)
AN_x = DspGetAnLeft(iE)
DspAnMove(iG,AN_x,AN_y)

END
END


and obviously its not working. When i compile then drop 3 errors:

93073233.jpg


66051100.jpg


54848280.jpg



After this i tried the following little program to check the DspGetMouse function.

FUNCTION Show_obj()

INT iX, iY

DspGetMouse(iX, iY)

DspAnMove(10,400,600)


END


This worked fine.

I have no idea whats next... :mad:
 
Okay, i made this:

FUNCTION Show_kor(INT iE, INT iG)

INT MouseeX, MouseY, AN_num, AN_x, AN_y,

DspGetMouse(MouseeX, MouseY)
AN_num = DspGetAnFromPoint(MouseeX, MouseY)

IF AN_num=iE OR AN_num=iG THEN

DspAnMove(iG,30000,0)

ELSE

AN_y = DspGetAnBottom(iE)
AN_x = DspGetAnLeft(iE)
DspAnMove(iG,AN_x,AN_y)

END
END

:mad:

You have a trailing comma (,) after you have declared your local variables, it needs removing, the one after AN_y
 
slightly different method

moz-screenshot.jpg
moz-screenshot-1.jpg
moz-screenshot-2.jpg
Also, at the end of each statement (except for the If,Else and End, and also the declarations) you will need a ; (semicolon). Some of the older versions were not strict on that, so just be careful.
moz-screenshot-5.jpg
Another method - single function.
Add (object - Text, "Hello World") to a graphics page.
After entering on a new page, normal template, open the properties.
Go to the "ACCESS" tab and get the AN Number. (205 in this case)

Go to the "FILL" tab.

add DspGetMouseOver(205); (or -1 for the current AN?)

This would get you out of writing a function to do it - it is how they do it in the templates.
moz-screenshot-3.jpg
moz-screenshot-4.jpg
 
Trying again

Add (object - Text, "Hello World") to a graphics page.


After entering on a new page, normal template, open the properties.
Go to the "ACCESS" tab and get the AN Number. (205 in this case)

Go to the "FILL" tab.

add DspGetMouseOver(205); (or -1 for the current AN?)

This would get you out of writing a function to do it - it is how they do it in the templates.

Screenshots are attached.

Hello.jpg AN205.jpg MouseOver.jpg
 
Add (object - Text, "Hello World") to a graphics page.


After entering on a new page, normal template, open the properties.
Go to the "ACCESS" tab and get the AN Number. (205 in this case)

Go to the "FILL" tab.

add DspGetMouseOver(205); (or -1 for the current AN?)

This would get you out of writing a function to do it - it is how they do it in the templates.

Screenshots are attached.

I will try this too, and feedback how works. đź“š
 
Add (object - Text, "Hello World") to a graphics page.


After entering on a new page, normal template, open the properties.
Go to the "ACCESS" tab and get the AN Number. (205 in this case)

Go to the "FILL" tab.

add DspGetMouseOver(205); (or -1 for the current AN?)

This would get you out of writing a function to do it - it is how they do it in the templates.

Screenshots are attached.


Yes, work fine this too. Thanks ! (anyway I change objects because they shape is different...) ;)
 

Similar Topics

I'm trying to design a custom alarm page as I'm preparing for a project launch. So far I have learnt that I need to use CiCode functions such as...
Replies
6
Views
4,304
Need to run up a pop up box at a certain time of day. At the moment i've done it as such.... FUNCTION STRING sTime; //Set sTime to "00:00"...
Replies
3
Views
2,334
Hi guys, I am currently working out my project. Right now i am having a diffculty in writing my scada because my supervisor requests me to...
Replies
3
Views
2,667
Hello everyone! I have a question about the allowable syntax for an expression in CitectSCADA. If I wanted an advanced alarm to trigger based on...
Replies
2
Views
931
Hello, Just wondering if it is possible to make internal CitectSCADA project tags available to an OPC server. (Schneider OFS). There are...
Replies
0
Views
915
Back
Top Bottom