Function inside a super genie(Pop-up)

Hi.

I'm trying to figure out how to re-use the variables inside the PopUpPage.

Here's a link to the function im trying to use inside my popup.

proscada.ru/ctkbase.en/resources/attachments/q4572/exec-guid36c264eab1aa4e048470d7d23cdeb0c2.ci

This simple function works in the genie but not in a super genie.

//MouseButtonDown

ExecEx("%Drawing%")

I've tried replacing the % sign with ? and lots of other ways, with no success. (The function still works if I just type in a "direct" path to open a folder., but I want to use a variable, that I can edit)

FUNCTION

PopUpPage(INT X,INT Y,INT Mode, STRING Drawing)

WinNewAt("!PopUpPage",X,Y,Mode);
SleepMS(25);
WinTitle("TITLE");

Got any ideas?

Thanks in advance.

Robin

  • Not exactly sure of what you are trying to accomplish.
    You could try Ass(-3, "Path", strPath, 0);
    Then the WinNewAt()
    On the popup page use ExecEx(?Path?)

    Hope this helps
  • It didn't work.

    This works directly on the symbol which I click to run the popup function.
    ExecEx("C:\Users\Public\Documents\"+"%Drawing%"+".pdf")
    I can change the "value" of drawing to Motor1, Motor2 or whatever when I paste the genie on a page.
    But when I add this:
    ExecEx("C:\Users\Public\Documents\"+"%Drawing%"+".pdf")
    To a button inside the popup/super genie it doesn't work.

  • Please use this syntax instead:

    ExecEx("C:\Users\Public\Documents\%Drawing%.pdf")
  • It sounds like you are trying to create a genie that works with both hard-coded text when you place it on a page, or with a super genie association when you paste it on a super genie popup. The problem is that you have to treat a super genie association like a variable, in this case a string variable.

    So, if you had a command in the genie like: ExecEx("C:\Users\Public\Documents\%Drawing%.pdf")

    and in the genie form dialog you set the substitution name Drawing to the text: Drawing1, then after substitution, the command would be: ExecEx("C:\Users\Public\Documents\Drawing1.pdf"), which is fine.

    But, for the super genie, you need to associate the constant value "Drawing1" with an association like ?DrawingName?.  You need to do this in your PopUpPage() function before calling WinNewAt. You'd use a command like Ass(-2, "DrawingName", "'Drawing1'"); Notice mode -2 is for the next window opened. The text "Drawing1" has to be in single quotes inside of double quotes to tell Citect it is a constant value instead of a variable tag. Here's what your function would look like with a Cicode variable containing the drawing name.

    FUNCTION PopUpPage(INT X,INT Y,INT Mode, STRING Drawing)
    	Ass(-2, "DrawingName", "'" + Drawing + "'");
    	WinNewAt("!PopUpPage",X,Y,Mode);
    	SleepMS(25);
    	WinTitle("TITLE");
    END
    

    You need to edit the command in the display-drawing genie to be: ExecEx("C:\Users\Public\Documents\" + %Drawing% + ".pdf"); 

    In the super genie page, if you paste your display-drawing genie, you would set the genie substitution Drawing to ?DrawingName?  After substitution, the command would become: ExecEx("C:\Users\Public\Documents\" + ?DrawingName? + ".pdf"); In the runtime, if your Cicode function associates "Drawing1" with the super genie association DrawingName, then the final command would become: ExecEx("C:\Users\Public\Documents\" + "Drawing1" + ".pdf"); which should work.

    The only issue is that if you use this same genie with hard coded text instead of a super genie association (like if you use it on a normal page), then you can't set the substitution Drawing to Drawing1 (without quotes). You just have to add quotes around the text. You would have to set the substitution Drawing to "Drawing1" the command would be valid.

    Or, if you are not using a genie in the super genie page, and you just have a simple button object, then just edit the PopUpPage() function like I showed, and set the button command to: ExecEx("C:\Users\Public\Documents\" + ?DrawingName? + ".pdf")

  • Thank you for the detailed answer!

    I've been testing these methods that you mentioned today.
    But I'm getting a fatal error because of: Ass(-2, "DrawingName", "'" + Drawing + "'");
    It says: incorrect number of arguments for function(E2022).

    I'll try to clarify how my genies/super genies look like:
    I've got a genie that has the symbol of a motor.
    There's an UP command, to get to a popup with a sensor that has an ON/OFF state
    and there's also a button with the ExecEx function, to access the drawing of that motor.

    I only tried to put the ExecEx function inside the motor symbol(genie) with Middle mouse button down just to get the correct syntax, which worked with the %Drawing%, same thing goes for the appearance of the motor symbol, I can use a ON/OFF statement here with the same %Drawing% .
    However, I can't figure out how to make it work on the inside of the popup/super genie.

    I'm using a similar association in the cicode as the one you showed me, which works:
    Ass(-2,1,Drawing+"Sensor",0);

    And then inside the popup I've got a symbol that has an ON/OFF state (On symbol when ?1?=1)
    In this case it works, but I've not found a way to use that string variable in the ExecEx function, I believe it is looking for a local variable in the Exec.ci, the popup function is stored in another cicode file. (Just my thought, might as well be that I'm using the incorrect syntax.)
  • Ass(-2, "DrawingName", "'" + Drawing + "'",0);

  • Thanks!

    Tried this, I'm not getting any errors.

    But I still can't figure out how to solve the problem.

  • perhaps the knowledgebase can help you?

    https://softwaresupportsp.aveva.com/#/okmimarticle/docid/tn6855

    Passing a String when using SuperGenie Association
    LEGACY TECH NOTE #
    4651


    SUMMARY

    How can I pass a String of Text using Super Genie Association, without it treating the substituted value as a Citect tag, and trying to substitute the value of the tag.

    This is useful when:

    * Some functions require the Tag name, not the Tag value
    * Sometime I want to pass in the heading of a SuperGenie, without saving this value to a STRING tag.

    SITUATION

    CitectSCADA 6.xx and above
    CitectHMI 6.xx and above


    ACTION

    In order to pass an actual String of text (not the value of a STRING tag) to a SuperGenie, you need to use the following format:

    " ' This is my Text String ' "

    (The spaces above are just to illustrate the " and ', so when you use this, without spaces, it will look like:)
    "'This is my Text String'"

    And on your SuperGenie, the text object must be set to the String type, with the substitution expression ?STRING 1? in the String expression field.

    i.e. to use the AssPage() Command to pass a string (in this case, the Name of a Trend):

    AssPage("SG_trend","'trend1'")

    NOTE: It is important to note the syntax. the SG_Trend is the name of the page, and is surrounded by " marks.
    NOTE: The Trend1 etc. are surrounded by " marks AND ' marks. This will use SuperGenie substitution to parse a string instead of a Tag Value. i.e. "'Trend1'"
  • Sorry, I forgot the ",0" in the Ass command.

    I'm not completely clear what you're trying to do. I was just guessing in my previous comment. You might want to make and upload a simple project to demonstrate what is failing. Or, make screenshots of the command(s) that associate tags and open the super genie, the command in the super genie that's not working, the genie form(s) where you set substitution values, and any Cicode (other than the Exec() function).
  • I'll try to explain by pictures, I've tried to make it more simple, since everything is in swedish and there will just be confusion with lots of tags.

    The genie

    Same genie (cropped out mode, just so you can see the part about Drawing)

    "Genie form substitution" NOTE, Here's also the substitution for Drawing, I just cropped the pictures, since the variables are in swedish.

    PopUpPage with a go-to button

    Another page/super genie
    Appearance, using the ass function.

    Same page as above(Infopage)

    The problem https://softwareforums.aveva.com/cfs-file/__key/system/emoji/1f61b.svg

    FUNCTION

    PopUpPage(INT X,INT Y,INT Mode,STRING Drawing)

    Ass(-2,1,Drawing+"_o_MAN",0);
    Ass(-2,2,Drawing+"_o_AUT",0);
    Ass(-2,100,"'"+Drawing+"'",0);

    WinNewAt("!PopUpPage",X,Y,Mode);
    SleepMS(25);
    WinTitle(Drawing+" Info");

    END

    So to sum things up, all I want to do is to use a substitution for the STRING Drawing (example: Bird, and if I press the button it will open up a picture of a bird), which works fine if I use the ExecEx function in the circle/genie.

    However, when trying to use the ExecEx function in one of the super genies it doesn't work with either the % sign or the ?

    I hope this was a better explanation https://softwareforums.aveva.com/cfs-file/__key/system/emoji/1f603.svg