Cicode problem

wordless

Member
Join Date
May 2009
Location
Tehran
Posts
4
Hello.
I have a simple problem, I searched in help files and it didn't answer my question!

The problem is: I want a function to get a my string as an input (the input string is the name of a local variable) and return my local variable as a tag. just this!

for example:
I have several local variables like this:
BIT_1, BIT_2, BIT_3, ...

I want to set all of them to 1 by pressing a button. The code may be like this:


FOR I=1 TO 30 DO
TempVar = someFunction("BIT_" + intToStr(I));
TempVar = 1;
END


The problem is : "someFunction".
I have lots of nodes in my project that have the same parameters. So I create some super genie and pass the ID number of every instance to it. Now I need to access my local variable with this ID number.

I'm new in my job, and I'm trying to understand it.
Hope you can help me.
Thanks a lot.

 
Instead of using seperate local variables
Use an Array "Bits[xx]", declare as global.
Ok if is only temporay but problem if needed to be retentive.

OR use whole word

iBit = 1;
For i = 0 TO 30 DO
IF ((Word_1 BITAND iBit) = iBit) THEN;
Bit_1 = 1;
ELSE
Bit_1 = 0;
END
iBit = iBit * 2;
END

Or to set bit in word
Word_1 = Word_1 BitOr iBit;

Put in function and pass word and retrieve bit value.

Just random thoughts!
 
Last edited:
The function you are looking for is write_var (or writevar) You pass the name of a tag as a string ("BIT_" + strIndex)and it will return the value. This will only work however if the function is not used to directly display the data. On a super genie you probably should use ***_Tag or one of the other ***_ functions

(it wont let me write the first part of the function name - *** should be *=a *=s *=s)
 
Last edited:
Alternatively, you could make your local variables be tags of a disk IO device. This means you could use the TagWrite function which accepts the name of the tag as a string.
 
FUNCTION
SetVarToOne(STRING Variable)
INT I
STRING sTtemp
FOR I=1TO30DO
sTemp = Variable + IntToStr(I)
TagWrite(sTemp,"1")
//Display current ariable at Prompt field
Prompt(sTemp)

// Show a popup with the current variable and its value
Message(sTemp,inttostr(tagread(sTemp)),0)

END
END

In the button touch property

SetVarToOne("Bit_")
 
Last edited:

Similar Topics

Hey People! I got an problem with the slider property, i use the scale function to show an group of images to zoom in, after this zoomin i use...
Replies
0
Views
2,609
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
287
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
Back
Top Bottom