Copy a variable? - old forum post


#1

Marc

Joined on 03-23-2004
Posts 1
Copying a variable

I need to copy a variable instead of moving it. When I move the variable, it reinitializes the varaible. I need to leave the data intact. It’s a 32 bit integer. Thanks, Marc
Report
03-24-2004, 2:42 AM
gmitchell

Joined on 12-01-2003
Optomation Systems, Madrid, Spain
Posts 153
Re: Copying a variable

You are using the correct instruction. There is no “Copy” instruction. I think there is something else wrong. I’m sure it seems that this is what is happening, but it isn’t happening because of the “Move” instruction. If it was happening it would make any programming impossible! Just to confirm that you are not going mad, write a brand new strategy, define two integer variables, declaring one as “Initialize on Download” to “22”, and use a move instruction to transfer copy the value to the second value. If that works the problem is in your code.
10 ideas for starters to locate the problem.

  1. Another chart writing to the same variable
  2. Initialization of variable on startup or download (maybe the controller is resetting)
  3. Initializing through download file or external instruction
  4. Variable declared as Notification Variable in ioDisplay/OptoDisplay
  5. Variable initialized externally or from another controller through Peer2Peer transfer
  6. Variable as down timer counting to zero automatically
  7. Wrongly assigned pointer
  8. Variable used elsewhere for status result of instruction
  9. 64Bit Integer being moved to a 32Bit Integer
  10. Wrong I/O Base type or variable size declared in ”IO Unit” instruction.

If none of the above helps, I would suggest zip mailing your strategy file to product support at Opto22, for them to take a look at where the problem is.