Cicode select case function

franciscoufa

Member
Join Date
Sep 2013
Location
La Villa - Asturies
Posts
61
Hello everyone!

I have made a cicode function of this form:

STRING
FUNCTION
NumeroModo(INT MxP_MODO)
SELECT CASE MxP_MODO

CASE MxP_MODO=1
MxP_NUMEROMODO="AUTOMATICO1";


CASE MxP_MODO=2
MxP_NUMEROMODO="AUTOMATICO2";


END SELECT
RETURN MxP_NUMEROMODO;
END


I added an objet that it must shows MxP_NUMEROMODO, but when I put MxP_MODO in 2, it must shows the same that the first case: AUTOMATICO1. The compilation doesn't give any error.

Are there anything wrong in the function?


Regards!
 
Not sure, but maybe:


STRING
FUNCTION
INT NumeroModo
Numeromodo=MxpModo

Select case Numeromodo

CASE = 1
MxP_NUMEROMODO="AUTOMATICO1";

Case = 2
MxP_NUMEROMODO="AUTOMATICO2";

CASE ELSE
MxP_NUMEROMODO="ERROR"

END SELECT
END

Works maybe, if you only chance bolded parts to your code?
 
Last edited:
Not sure, but maybe:


STRING
FUNCTION
INT NumeroModo
Numeromodo=MxpModo

Select case Numeromodo

CASE = 1
MxP_NUMEROMODO="AUTOMATICO1";

Case = 2
MxP_NUMEROMODO="AUTOMATICO2";

CASE ELSE
MxP_NUMEROMODO="ERROR"

END SELECT
END

Works maybe, if you only chance bolded parts to your code?

Did you talk me about this way?
 
Working sample:


FUNCTION
number_to_text_script()

STRING MxP_NUMEROMODO;
INT Numeromodo;

Numeromodo=MxpModo;

SELECT CASE Numeromodo

CASE 1
MxP_NUMEROMODO="Automatico1";

CASE 2
MxP_NUMEROMODO="Automatico2";

CASE ELSE
MxP_NUMEROMODO="ERROR";
END SELECT


Test_string=MxP_NUMEROMODO;


END


MxModo is INT variable. (I used local variables now for this, but should work also with tag-variables (at least if you use read tag command and with it you maybe need use also string to int conversion. Tag variable is on string format on cicode? Or change CASE to use string?)

I called function from displays page properties.
 
Last edited:
Thanks Lare, the program is successful!

Now, I have got the next problem:

I have done a report, and I want to show in it the variable of the function created: Test_string. Test_string is a Local Tag. I edit de Report and put as follows:

INFORME - Proyecto de Francisco Fdez Álvarez-

FECHA: {DATE(2)} HORA: {TIME(1)}

Mode: {Test_string}


The report shows all, but NO the variable {Test_string}. I tried to convert the variable in a VARIABLE TAG, but it isn't the solution!
 
Sorry, this goes above my knowledge.

Maybe tag is not updating? try copying varible data with write_Tag command to string.
 
Try formatting.
{Test_String:#-########}

I tried it, but it isn't correct!

I created the variable tag: Mx_Memoria (STRING VARIABLE), and I have done a Cicode Script where I added: Mx_Memoria=Test_string. Then, in the report is showed Mx_Memoria.

This way is almost successful, and the report shows Mx_Memoria (Automatico1, for example) but sometimes it shows only "Au" and it don't finish to write the word!

HELP PLEASE!
 

Similar Topics

Hi All, Can anyone advise me on how to determine the AN of a genie instance I writing to. I have created a genie to display a valve and some text...
Replies
0
Views
92
I am trying to display a variable within a cicode function onto a graphics page. This function queries a SQL database. I can get the value onto a...
Replies
3
Views
288
Hi guys, its my first time progamming cicode and I need to do popups alarms, there are several digital alarms and in their rising edge transition...
Replies
0
Views
507
Hi all :) , I'm very new to CitectSCADA and Cicode programming, however have good programming experience in most major programming languages...
Replies
0
Views
1,249
Hi, all :)), I'm very new to CitectSCADA and Cicode programming, however have good programming experience in most major programming languages...
Replies
7
Views
3,621
Back
Top Bottom