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

why use CLR_IO_STAT Karel built-in?

  • DuhbCakes
  • April 11, 2015 at 9:50 PM
  • Thread is Resolved
  • DuhbCakes
    Guest
    • April 11, 2015 at 9:50 PM
    • #1

    IO_STATUS(file_id)
    Return an INTEGER value indicating the success or type of failure of the last operation on the file argument

    CLR_IO_STATUS(file_id)
    Clear the results of the last operation on the file argument

    in all of the program examples i find in the Karel manual whenever IO_STATUS is used it is immediately followed by CLR_IO_STATUS. This does not seem to be needed. i put together a quick test and it read out as follows.

    open MC:\IO.csv failed
    2014
    UD1:\IO.csv opened
    0

    To me this means that the CLR_IO_STATUS is not needed as the value will be replaced by the next operation that uses it. the CLOSE FILE built in always sets it to zero. my favorite part is that 2014 is not a listed code in the table. i would expect either 12327 Open file failed or 12328 file is not opened.

    Code
    PROGRAM fileopentest
    %NOLOCKGROUP
    
    
    VAR
     STATUS, entry :INTEGER
     devicePath :STRING[64]
     inputFile :FILE
    
    
    BEGIN
    
    
    GET_VAR(entry,'*SYSTEM*','$DEVICE',devicePath,STATUS)   -- path was set to wrong location for this test MC:\IO.csv does not exist. file is saved at UD1:\IO.csv
    -- FILE_LIST('IO.csv', n_skip, format, ary_nam, n_files, status)
    devicePath = devicePath + '\IO.csv'
    
    
    OPEN FILE inputFile ('RO',devicePath)
    IF (IO_STATUS(inputFile) <> 0 ) THEN
     --	CLR_IO_STAT(inputFile)
      WRITE('open ', devicePath, ' failed',CR)
      WRITE(IO_STATUS(inputFile),CR)  -- returns 
      CLOSE FILE inputFile  -- sets IO_STATUS back to zero by default  
      devicePath = 'UD1:\IO.csv'  -- set path to correct location  
      OPEN FILE inputFile ('RO',devicePath)
      WRITE(devicePath, ' opened',CR)
      WRITE(IO_STATUS(inputFile),CR)
    ELSE
      WRITE(devicePath, ' opened',CR) 		
    ENDIF
    
    END fileopentest
    Display More
  • rf103
    Reactions Received
    17
    Trophies
    4
    Posts
    264
    • April 15, 2015 at 11:15 AM
    • #2
    Quote from DuhbCakes


    my favorite part is that 2014 is not a listed code in the table. i would expect either 12327 Open file failed or 12328 file is not opened.

    2-014 is FILE-014: File not found

    The Karel manual very rarely lists possible errors in the function descriptions, possibly because that would make the manual four times its current size.

  • DuhbCakes
    Guest
    • April 15, 2015 at 7:18 PM
    • #3

    you are correct sir. i should have known better. the lack of leading zeros threw me off. I should have used POST_ERR(IO_STATUS(inputFile),'',0,0) then i would see the dictionary entry posted on the Teach Pendent. That does however reinforce my point. why even use the CLR_IO_STATUS?

  • rf103
    Reactions Received
    17
    Trophies
    4
    Posts
    264
    • April 17, 2015 at 9:19 AM
    • #4

    If I remember correctly there are some IO operations that do not necessarily reset / override the IO_STATUS of a previous operation. An example would be a READ on a file descriptor that has been configured with a timeout (SET_FILE_ATR(fd, ATR_TIMEOUT, ..)). If you don't clear the status prior to calling READ, a call to IO_STATUS() will return whatever it was before the READ in some cases. That makes checking it essentially useless, as you cannot be certain that you are looking at the result of the last READ.

    Besides that, it is good practice to reset things to a known state before attempting any new operations, so you can safely reason about the results.

  • DuhbCakes
    Guest
    • April 22, 2015 at 2:15 AM
    • #5

    confirmed. Fanuc got back to me and it is as you say. interestingly enough the CLOSE FILE does not update the status with a fault even if it generates one. I agree that it is good practice, and will continue to use it. I just like to know what exactly i am asking the robot to do. call it a programmer's quirk.

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