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. Kawasaki 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

Kawasaki AS - Get sub array from array

  • dhindhimathai
  • June 8, 2023 at 12:29 PM
  • Thread is Unresolved
  • dhindhimathai
    Reactions Received
    2
    Trophies
    1
    Posts
    15
    • June 8, 2023 at 12:29 PM
    • #1

    Hi all,

    I have been stuck on this for some time now. It seems to be a very trivial thing but can't find a solution to it.

    How do I extract a subarray from an array?

    Suppose I have a two-dimensional array called array_var, how do I get the subarray array_var[0:3,1:2]?

    I tried to go through the AS manual but could not find anything...

    Thank you in advance for your help.

  • Go to Best Answer
  • panic mode June 8, 2023 at 1:43 PM

    Approved the thread.
  • kwakisaki
    Reactions Received
    694
    Trophies
    11
    Posts
    4,770
    • June 8, 2023 at 1:59 PM
    • #2

    Yes Kawasaki manuals are very empty regarding arrays.

    So simply (you were close) you have the following syntax:

    tst1[0] ; single dimension

    tst2[0,0]; two dimesion

    tst3[0,0,0]; three dimension

    View my channel at Industrial Robotics Consultancy Limited - YouTube

  • dhindhimathai
    Reactions Received
    2
    Trophies
    1
    Posts
    15
    • June 8, 2023 at 2:06 PM
    • #3

    Hi kwakisaki

    Thank you very much as usual for your prompt answer.

    I didn't actually undestand how to get a sub array. What you seem to show me is getting individual elements of an array, right?

    For example, if I have an array with 5 elements and I want to create another array containing elements from 3 to 5, how can I do?

    If I do array[2:4] it gives me P0119: Incorrect array suffix error.

    Thanks again in advance.

  • dm.bogachev
    Reactions Received
    45
    Trophies
    2
    Posts
    86
    • June 8, 2023 at 2:14 PM
    • #4
    Quote from dhindhimathai

    Hi kwakisaki

    Thank you very much as usual for your prompt answer.

    I didn't actually undestand how to get a sub array. What you seem to show me is getting individual elements of an array, right?

    For example, if I have an array with 5 elements and I want to create another array containing elements from 3 to 5, how can I do?

    If I do array[2:4] it gives me P0119: Incorrect array suffix error.

    Thanks again in advance.

    Display More

    AS Language does not support sub arrays. You should use FOR loop for this task.

    Arrays in AS are not arrays in common case, like arrays in Python or C++. It's more like syntax sugar. For example, command var[222] = 1 is valid and only var[222] variable is created. var[0] to var[221] will still be nonexistent

  • kwakisaki
    Reactions Received
    694
    Trophies
    11
    Posts
    4,770
    • June 9, 2023 at 6:23 AM
    • Best Answer
    • #5

    Yes, this is AS Language not any other language.

    Quote from dhindhimathai

    For example, if I have an array with 5 elements and I want to create another array containing elements from 3 to 5, how can I do?

    If you lets say have:

    POINT test[0] = HERE

    You have now declared to the controller that variable name test in the location register is now referenced as a single dimension array and just contains 1 element.

    Therefore you have:

    - Defined an array in the location register with the variable name.

    - Defined 1 dimensional element to that array variable.

    - Defined a variable name and declared it as an array but you with no range of elements

    - This variable name can only be referenced by way test[element no.] and not test.

    So if you wanted to define an array of 10 elements with a range of 0-9 you would simply have:

    FOR .tmp 0 TO 9

    POINT pos[.tmp] = HERE

    END

    Quote from dhindhimathai

    For example, if I have an array with 5 elements and I want to create another array containing elements from 3 to 5, how can I do?

    You may want to look into MININDEX and MAXINDEX for assistance in your process of extracting/returning information on arrays and elements.

    What dm.bogachev mentioned is exactly correct.

    Quote from dm.bogachev

    For example, command var[222] = 1 is valid and only var[222] variable is created. var[0] to var[221] will still be nonexistent

    View my channel at Industrial Robotics Consultancy Limited - YouTube

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

Similar Threads

  • Help with Fanuc R30ia Ethernet ip setup with PLC

    • joshrice1
    • March 12, 2020 at 12:41 AM
    • Fanuc Robot Forum

Tags

  • Array
  • AS
  • subarray
  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