Citect Genie to Pop-up Array

Tom12345

Member
Join Date
Mar 2018
Location
Czech republic
Posts
10
(note the A.S.S is without the full stops, forum seems to be filtering it as rude word)


Hello all,


Hoping someone can help, I'm trying to achieve the following:-

- I want pass a value to a genie
- I want to then pass this to a pop up window function and use the value as an INT array index.

The part I'm not sure about is the correct way to use the 'A.S.S***' function

A.S.S(-2, 1, "ArrayTag" + "[" + genieindexvalue "]", 0)

This compiles ok, but when I put into runtime it seems as though it is looking at the entire array when I press Ctrl + P on the pop-up.

Even if I put an array index, it seems to be looking at the entire array without the index

A.S.S(-2, 1, "ArrayTag[5]", 0)

The prefix method works fine, but I don't want to have 50 variables with prefixes.

A.S.S(-2, 1, genieindexvalue + "ArrayTag", 0)

Any help would be much appreciated, I tried the cicode manual and website, it only gives examples of prefixes and the ability to add an index to the pop up string ?INT 1?[XXXX - array index} which isn't useful as I want the array index to be passed through via the genie.

Best Regards,
Tom
 
Last edited:
Hi Tom,
Do you still need help? If so i will help if i can.

First off the tag you are using in the function looks like an address as you can't have square brackets in a variable tag name.
If you let me know the tag names or attach the variable.dbf and paste in the cicode you are trying to make work i will try and give some guidance.

Cheers,
Andrew
 
Hi Tom,
Do you still need help? If so i will help if i can.

First off the tag you are using in the function looks like an address as you can't have square brackets in a variable tag name.
If you let me know the tag names or attach the variable.dbf and paste in the cicode you are trying to make work i will try and give some guidance.

Cheers,
Andrew

G'day Andrew,

Many thanks for the response.
I gave up on that approach, you are right, the square brackets indicating array index position don't seem to work in cicode unless used for a fixed address e.g. Variable_tag[2] would be 3rd array in Variable_tag if it was an array.

I used prefixes in the end which work fine in cicode for the pop-up I was using the A.ss/ associate function for.

But now I have another problem, I can't pass the prefix address through the genie in another text field in another part of the project:

Purpose- want to pass the itemID through the genie to cicode.

Variable_Tag_01 (01 being the itemID)
Variable_Tag_02 (02 being the itemID etc)
Variable_Tag_03
Variable_Tag_04


Genie input = ItemID


So in the text expression field of the text object I want to call a function and send the current variable value, I think it will look something like


FunctionXYZ (Variable_Tag_ + %itemID%)

I'm not sure on the correct syntax " ' ^ etc, the cicode manual isn't much help.


Then in cicode I will use the value from the corresponding variable tag to display a string message (this works fine so haven't bothered complicating this post).
Also want to be able to disable a button in the button 'disable when' properties - also part of a genie using this address, basically the same problem, how can I can use a genie input as the variable prefix in the item porperties.

So

Disable when:

Variable_Tag_ %ItemID% = 0

Also not sure on correct syntax.

I want to stop the operator pressing a button if the variable is 0.


I hope the above makes sense, you would be doing me a great favour, I've been messing with this for quite a while!

Best Regards,
Tom
 
Hi Tom,
Sorry i think i made an incorrect assumption in my original post i should have clarified. With the arrays are you trying to declare these as local cicode variables? I was assuming you were using variable tags as in connected to a device?
If you were trying to declare an array in Cicode then it needs to be done at the Global or Module scope and they can be up to 3 dimensions.

I'm not 100% sure what you are trying to do at the moment ( i'm following some of it) or what steps you have taken to create genies and cicode so i'm going to throw out a few quick examples, using a few things you have discussed and see where that takes us. Not sure if i'm being to simplistic or overly complicated, you let me know.

Cicode example using Arrays and A.s.s. function.

Code:
String sTag[10] //Declare array as Module Scope
Function MyFunction(String sItemID)
INT iNum;

sTag[0] = sItemID+"_00"
sTag[1] = sItemID+"_01"
sTag[2] = sItemID+"_02"
etc

    FOR iNum = 0 to 10 DO
          A.S.S.(-2,iNum,sTag[iNum],0);
    END
    WinNewAt("!My Popup",15,75,1+4+16+64+512)
END


Now on the page that was called "!My Popup" you use ?1? where you would like sTag[1] to be used etc.


Onto the Genie, you create a new Genie and to keep it simple if you put an on/off indicator light using a symbol set and in the "on symbol When" box you put Variable_Tag_ %ItemID% then OK and save that genie as "my_Genie".
Create a new blank page and paste the "my_Genie" genie you will see that indicator and a popup box asking what value for ItemID. You then put the value in that you want. Obviously you create the genie with much more on it and where ever %ItemID% is used it will be replaced with that value.

For disable your Syntax is correct using it in the above context.
 
Hi Andrew,

Thanks for the quick response!

I'll start from beginning (my post doesnt read well)

So I want to create a genie that has the following
1) Button to bring a pop-up
2) on pop-up is 4 selection buttons that write a different number to same ?INT 1? associated variable - essentially a 1, 2 or a 3 that is a type of combination in the PLC
3) The selection gets sent to the right array location

Then also in the same genie is a text field, I want it to go and grab the number from the PLC (from the correct Combination tag), convert it to a string and message in cicode.

The variables are real I/O devices, array of 50 INTs

I originally tried to use an array so "Combination" tag with INT[50] as data type. So a list of 50 objects each with an INT with various options indicating their selection.

This was ok for the INT to String message/ text field, so the call function was messageX (Combination[%sItemID%]) the array was detected in the argument and worked fine. But I couldn't get the A.S.S to work in cicode for the pop-up to write to that address. I tried AS.S(-2, 1, "Combination" + "["" "sItemID" "]") hoping that would be translated as Combination[3] for example if sItemId for genie was 3.

So then I changed the array from INT[50] to just 50 INTs with incremental suffix numbers:

Combination_01
Combination_02
Combination_03

So the As.s is now As.s ( -2, 1, "Combination_" + sItem, 0) which works ok for the pop-up.

But now I can't get the text display function to work, I can't pass in the suffix/sitemID to the messageXYZ function in cicode:

In the expression field of the text
messageXYZ (combination + %sItemID%)


I'm hoping that maybe it is possible to use the sItemID from the genie to point the AS.S tag to the correct INT in the array, maybe I made a mistake.
If not is there a way of using the genie input as a variable suffix.

Thanks again - as you can probably tell, I'm not great at cicode, it can be quite difficult :)
 
OK i get how you were trying to declare the array now, i have never even thought of trying that before but makes logical sense now that you say it. As you found out that will not work you can only have data types listed in the drop down singular size, you have to use Cicode or Local variables for any type of array. A tip for ease of creating tags you can edit the variable.dbf in excel with the Citect savedbf Add-in, makes life easier.

How you created your tags is logical so that is good.

With your AS.S(-2, 1, "Combination" + "["" "sItemID" "]") not sure if you had it exactly as that but there are concatenation issues with that, should be AS.S(-2, 1, "Combination[" + sItemID +"]")

So your only issue is displaying a string on the genie? This may get complex from your description of how you are trying to do it. So you are trying to run Cicode function "messageXYZ" which is in a string expression display value on a text object. The issue is this is called a foreground cicode object and it really depends what is in function "messageXYZ" and what version of Citect you are running, because if there are blocking functions in your cicode then it will probably not work (version dependant) easiest way is to look in Citect hardware alarms for any foreground cicode errors.
 
I think you may have solved my problem!

" AS.S(-2, 1, "Combination[" + sItemID +"]") - " I didn't try putting the plus sign inside the brackets, have done this before? I will test it now.

BTW I'm using dbf navigator for editing variable.dbf, its great and portable.
I think excel can cause an issue if you change column width, recommend trying.

i will update if works.

With the sMessage function it compares different cases (INT number in the variable) etcand returns a text string
 
hmm...


not quite there


"Incorrect number of arguments for function"

Line[740]: itemID +"]"){;} WinNewAt("Combination_Selection",


In cicode

***(-2, 1, "Combination_[" + itemID +"]");

Just going to try with the 0 at end....

(-2, 1, "Combination_[" + itemID +"]", 0);
 
Last edited:
Hi Andrew, thank you very very much!!!!

It compiled ok, and when I control + P on the popup it shows the array [50] address - same for each genie, so I think its ok, I'm not connected to a test PLC at the moment, but I will know for sure next week if it also points to correct index item etc during FAT :).
Sent you a PM
 

Similar Topics

Hello Everyone, I'm editing an existing Vijeo Citect project and it is my first time to use this software. I created a super genie and used a...
Replies
0
Views
3,486
I am trying to import a genie from an old project to new project, but I cannot do it and didnt find any answers yet on Google. Can anyone help me...
Replies
0
Views
746
hello everyone .. i found many projects in citect programs that have SuperGenie hidden for copyright or project's protection , so anyone help how...
Replies
0
Views
1,184
Hi all, I am very new to Citect, and trying to make my own Genie. What I have done: Create my object and assign function -> On when "...
Replies
3
Views
2,342
Hi, I'm fairly new to Citect Scada and am currently working on a little fun project that goes alone nicely with my PLC program. When I have a...
Replies
1
Views
2,441
Back
Top Bottom