1. Home
    1. Dashboard
    2. Search
  2. Forum
    1. Unresolved Threads
    2. Members
      1. Recent Activities
      2. Users Online
      3. Team Members
      4. Search Members
      5. Trophys
  3. Articles
  4. Blog
  5. Videos
  6. Jobs
  7. Shop
    1. Orders
  • Login or register
  • Search
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • Blog Articles
  • Products
  • More Options
  1. Robotforum - Support and discussion community for industrial robots and cobots
  2. Forum
  3. Industrial Robot Support and Discussion Center
  4. KUKA Robot Forum
Your browser does not support videos RoboDK Software for simulation and programming
Visit our Mainsponsor
IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Sponsored Ads

array invalid when try to assign krc2

  • rvsh
  • August 12, 2020 at 4:04 PM
  • Thread is Unresolved
  • rvsh
    Trophies
    3
    Posts
    26
    • August 12, 2020 at 4:04 PM
    • #1

    Hi,

    I would like to assign an array (string) to another array but I got error information that " right side: array invalid"

    I tried many combinations and I can't find the right syntax.

    Could you help?

    Here is the sample code:

    Code
    DEF MSG(TOSHOW[]:IN)
      INT ANSWER
      INT OFSET
      DECL STATE_T STATE
      DECL MSG_T EMPTY_MSG
      CHAR TOSHOW[]
    
      EMPTY_MSG={MSG_T: VALID FALSE, RELEASE FALSE, TYP #NOTIFY, MODUL[] " ", KEY[] " ", PARAM_TYP #VALUE, PARAM[] " ", DLG_FORMAT[] " ", ANSWER 0}
    
      $MSG_T=EMPTY_MSG
      $MSG_T.MODUL[]=" "
    >>>  $MSG_T.KEY[] = TOSHOW[] ; HERE IS THE ERROR (I CANT ASSIGN TOSHOW[] TO KEY[]) <<<
      $MSG_T.PARAM[]="PARAM"
      $MSG_T.PARAM_TYP=#VALUE
      $MSG_T.TYP=#NOTIFY
      $MSG_T.VALID=TRUE
    END
    Display More
  • panic mode
    Reactions Received
    1,278
    Trophies
    11
    Posts
    13,079
    • August 12, 2020 at 4:43 PM
    • #2

    well... you should get error 2224 in line 8, even before you get to line 12.

    you are trying to dump values of all structure elements of several different structures into one...

    and of course most of them don't exist in this variable

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • rvsh
    Trophies
    3
    Posts
    26
    • August 13, 2020 at 1:09 PM
    • #3

    If I just change line 12 to

    $MSG_T.KEY[]="my message"

    It works ok.

    But I want to add it from array/variable.

    Could you help?

  • hermann
    Reactions Received
    406
    Trophies
    9
    Posts
    2,610
    • August 13, 2020 at 2:25 PM
    • #4

    Use a loop:

    for ii=1 to strlen(toshow[])

    $MSG_T.KEY[ii] = toshow[ii]

    endfor

    or use strcopy()

  • panic mode
    Reactions Received
    1,278
    Trophies
    11
    Posts
    13,079
    • August 13, 2020 at 2:42 PM
    • #5

    yes but note that loop would not erase characters beyond strlen(toshow[]) so if using loop, next character should be zero (unless that is beyond declared string end)

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • rvsh
    Trophies
    3
    Posts
    26
    • August 13, 2020 at 5:27 PM
    • #6

    StrLen not declared as function

    Any Ideas why?

  • rvsh
    Trophies
    3
    Posts
    26
    • August 13, 2020 at 5:28 PM
    • #7

    "Name not declared as function"

  • panic mode
    Reactions Received
    1,278
    Trophies
    11
    Posts
    13,079
    • August 13, 2020 at 5:44 PM
    • #8

    1. post your KSS version

    2. post your code... how are you trying to use it exactly?

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • rvsh
    Trophies
    3
    Posts
    26
    • August 17, 2020 at 11:57 PM
    • #9

    1. KSS4.1.7 SP08

    Code
    DEF MSG(TOSHOW[]:IN)
      INT ANSWER
      INT OFSET
      INT II
      DECL STATE_T STATE
      DECL MSG_T EMPTY_MSG
      CHAR TOSHOW[]
    
      EMPTY_MSG={MSG_T: VALID FALSE, RELEASE FALSE, TYP #NOTIFY, MODUL[] " ", KEY[] " ", PARAM_TYP #VALUE, PARAM[] " ", DLG_FORMAT[] " ", ANSWER 0}
    
      $MSG_T=EMPTY_MSG
      $MSG_T.MODUL[]=" "
      FOR II=1 TO STRLEN(TOSHOW[])
      $MSG_T.KEY[II] = TOSHOW[II]
      ENDFOR
      $MSG_T.PARAM[]="PARAM"
      $MSG_T.PARAM_TYP=#VALUE
      $MSG_T.TYP=#NOTIFY
      $MSG_T.VALID=TRUE
    END
    Display More

    If I do for example "for II=1 to 4" then it works fine if toshow length is 4 or more.

  • rvsh
    Trophies
    3
    Posts
    26
    • August 17, 2020 at 11:59 PM
    • #10

    I use it just like this

    MSG("example text to show")

Advertising from our partners

IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Advertise in Robotics
Advertise in Robotics

Job Postings

  • Anyware Robotics is hiring!

    yzhou377 February 23, 2025 at 4:54 AM
  • How to see your Job Posting (search or recruit) here in Robot-Forum.com

    Werner Hampel November 18, 2021 at 3:44 PM
Your browser does not support videos RoboDK Software for simulation and programming

Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Thread Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Tags

  • KRC2
  • Array
  • message
  1. Privacy Policy
  2. Legal Notice
Powered by WoltLab Suite™
As a registered Member:
* You will see no Google advertising
* You can translate posts into your local language
* You can ask questions or help the community with your knowledge
* You can thank the authors for their help
* You can receive notifications of replies or new topics on request
* We do not sell your data - we promise

JOIN OUR GREAT ROBOTICS COMMUNITY.
Don’t have an account yet? Register yourself now and be a part of our community!
Register Yourself Lost Password
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on Google Play
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on the App Store
Download