Showing results 1 to 8 of 8

Thread: Copy variable value to another in a script

  1. #1
    Join Date
    29.01.2016
    Posts
    24

    Default Copy variable value to another in a script

    I see I can copy variable values from source to target in the Allocations area, but I wish to do it in a script.
    I press a button, a function runs a script and that script should copy a variable (username) into a target variable (who closed the batch).

    There doesn't seem to be a "Write value" variant that takes data from another variable.

    Any ideas?

  2. #2
    Join Date
    01.07.2008
    Location
    Salzburg, AT
    Posts
    870

    Default Re: Copy variable value to another in a script

    In Allocations you may configure trigger variable and in script - call 'write set value' functions toggling the trigger.

    Or you may define in Recipe Group Manager a recipe linking (coping) the value from one variable to another and in script - call the function executing this recipe.

  3. #3
    Join Date
    29.01.2016
    Posts
    24

    Default Re: Copy variable value to another in a script

    I don't see that anybody should spend money on Recipe Group Manager to copy values. This is an intrinsic function of every CPU ever built.

    What is the priority of an allocation? Will it interrupt my script to perform the copy? If not, how can I determine when the allocation has completed?
    How much do I need to spend to compare two numbers?

  4. #4
    Join Date
    01.07.2008
    Location
    Salzburg, AT
    Posts
    870

    Default Re: Copy variable value to another in a script

    RGM is rich in useful features and many customers decided to buy the license. The main purpose is for sure not the copying of variable values. I do not know if you have or not the RGM license, I'm giving general answer (imagine you had RGM and no one has informed you that it contains this solution). And I has informed you about possibility in RGM on the second place. No reason for emotional reactions. Maybe a day some customer having RGM will search on Forum for similar advice.

    The time needed to execute an allocation depends on driver of involved variables. I suppose your source variable - username - is SYSDRV variable - so in driver accessing memory of your PC - nano(?)seconds. If for target variable you are using Intern driver then to write the value from allocation the Intern driver will also only access the PC's memory.

    The trigger variable i suppose wiil be internal too, but not set by allocation - set by zenon function 'write set value' created by you. Thus the only eventual delay could be caused by you - if you activate in this function the checkbox 'wait for writing confirmation'. For variables of Intern driver it forces fix wait 30 seconds. Function configured in that way will delay execution of any next function in your script.

    The functions in zenon runtime are executed according to 3 priority levels, documented in Help: Manual -> Functions and scripts -> Functions -> Execution sequence during Runtime.

    What numbers you want to compare? and what for?

  5. #5
    Join Date
    29.01.2016
    Posts
    24

    Default Re: Copy variable value to another in a script

    How did you guess I'm not in charge of deciding whether my company uses Zenon or not?

  6. #6
    Join Date
    01.07.2008
    Location
    Salzburg, AT
    Posts
    870

    Default Re: Copy variable value to another in a script

    No, i didn't make such assumption.
    Why you think i did?

  7. #7
    Join Date
    29.01.2016
    Posts
    24

    Default Re: Copy variable value to another in a script

    Because copying values in an intrinsic function of all processors ever made and COPA DATA have managed to make it super complicated, just like they managed to make bitwise access of bytes insanely complicated.

    Your attitude is that we should be happy and grateful to implement convoluted workarounds to Zenons short comings.

    Well I'm not, I'm furious every single time it takes me hours to achieve and test things that should take seconds.
    I'm not learning anything new, or better. I'm just grinding.
    You want me to smile while I try to figure out a way to copy a variable value?
    Here's the smile

    It's completely honest.

  8. #8
    Join Date
    29.01.2016
    Posts
    24

    Default Re: Copy variable value to another in a script

    And in case anybody is wondering how they might copy a variable value within a script.

    The way I have done it is to set a BOOL using Write Value function.
    That BOOL is used in allocations as an Edge type trigger to copy Source to Destination.

    When the script is executed, the Write Value occurs and the allocation trigger is then executed, before the next step in the script is executed.

    When the next script step is executed, the destination will contain the source, so you can now overwrite the source without any problems.
    Having said that, all the variables I have been using are Internal types, not PLC types, so I extend my heartiest wishes of luck if you're copying to a PLC type variable.

    There, now you don't have to run a series of tests to work out if that's the order or not, because I already did it. But let's face it, you'll be on a different Zenon version and it will probably be different for no particular reason. If you're really lucky, there may even be a variable value copy function/option in the future and none of this convoluted nonsense will be even necessary.

Similar Threads

  1. How can I copy a variable between projects?
    By mjackson in forum zenon Supervisor
    Replies: 1
    Last Post: 11th July 2014, 14:02
  2. Make a copy of a project.
    By takarlsson in forum zenon Supervisor
    Replies: 5
    Last Post: 21st April 2011, 00:10
  3. Copy recipe to a CE panel.
    By takarlsson in forum zenon Operator
    Replies: 8
    Last Post: 5th April 2011, 13:18
  4. Copy from variable to other variable
    By cyrilfeasy in forum zenon Supervisor
    Replies: 2
    Last Post: 5th November 2009, 17:25
  5. copy recipes
    By hicom in forum zenon Supervisor
    Replies: 9
    Last Post: 11th May 2009, 05:28

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •