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

Making a library... Is it possible to force the programmers that will use it to use a qualified name to access the internal variables?

  • robotecnik
  • April 29, 2022 at 8:38 PM
  • Thread is Unresolved
  • robotecnik
    Reactions Received
    19
    Trophies
    4
    Posts
    568
    • April 29, 2022 at 8:38 PM
    • #1

    Hi all,

    As in the subject states, I am writing a code library. And, in order to keep things tidy and avoid variable, procedure, function names... collisions with whatever any operator could have declared outside the library...

    Is there any way to add a forced qualifier?

    I could insert all variables inside a RECORD, but that would leave procedures and functions out of this, plus I could not initialize the variables at declaration time.

    I could set a prefix, but it would be super that the programmers who would use it would need to add the module name in front of the functions and variables names.

    Is enforcing that possible?

    Thank you in advance.

    http://www.robotecnik.com | Robots, CNC and PLC programming.

  • Lemster68
    Reactions Received
    301
    Trophies
    9
    Posts
    2,469
    Blog Articles
    7
    • April 29, 2022 at 9:19 PM
    • #2
    Quote from Joan Murt

    I could set a prefix, but it would be super that the programmers who would use it would need to add the module name in front of the functions and variables names.

    I really do not understand what you are saying here.

  • robotecnik
    Reactions Received
    19
    Trophies
    4
    Posts
    568
    • April 30, 2022 at 12:07 AM
    • #3

    Hi Lemster.

    Using a PERS variable in a library module is direct in RAPID. Just write the name of the variable and that's it.

    Imagine I declare a variable named "i" that is pers.

    Then imagine that my library is loaded in a robot that has another "i" variable somewhere else.

    This can cause all sorts of problems.

    I need the variable "i" to be global, but at the same time I want to prevent the mentioned problem.

    It would be better if I could enforce the programmers that want to use my library to write the name of the module before the variable name, something like:

    library.i := 10;

    That would remove the ambiguous usage of i and would not make it necessary to write a_very_large_and_obscure_name_i := 10; to "avoid" that problem.

    But I can't use records because I can't initialize them at declaration time.

    the long and obscure prefix could help, but it's not a guarantee.

    I would prefer being able to enforce the scope/qualifier before the usage of the library variables and/or procedures / functions.

    Hope it's clearer now.

    Thanks for your time.

    http://www.robotecnik.com | Robots, CNC and PLC programming.

  • SkyeFire
    Reactions Received
    1,051
    Trophies
    12
    Posts
    9,426
    • May 2, 2022 at 5:26 PM
    • #4

    Using long and descriptive names is the only way I'm aware of to try to avoid the namespace collision issue.

    Also, any time you can declare a variable inside a PROC or FUNC, instead of at the Module level, also helps, since a variable declared this way has its scope limited to that routine, rather than being global or local. Also, using LOCAL on as many variables as possible at the Module level also helps reduce the opportunities for collisions.

    I also do things like special prefixes for variables. For example, any PROC-level variable would be declared with a name starting with "_", and received arguments start with an "FI_" or "FO_" for incoming or outgoing (INOUT) arguments. Avoiding common names like "Counter" or "X" helps too.

    Still, at the end of the day, all this only mitigates the collision risks, since you simply won't have control over what other libraries get added to the robot alongside yours. And if whomever wrote those libraries was careless with their variable naming, well....

  • robotecnik
    Reactions Received
    19
    Trophies
    4
    Posts
    568
    • May 5, 2022 at 12:56 PM
    • #5
    Quote from SkyeFire

    Using long and descriptive names is the only way I'm aware of to try to avoid the namespace collision issue.

    Yep... that is what I am afraid of.

    Thank you very much SkyeFire!

    http://www.robotecnik.com | Robots, CNC and PLC programming.

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

  • irc5
  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