PxPlus User Forum

Twitter Twitter Twitter

Author Topic: UNT & HFN returning -1  (Read 985 times)

Peter.Higgins

  • Diamond Member
  • *****
  • Posts: 124
    • View Profile
UNT & HFN returning -1
« on: July 21, 2022, 03:27:27 PM »
This is a new one in my experience.  I'm wondering why I am getting this from these two functions.  It is 5 levels into an object stack when the file handles appear to run out, but chn doesn't span more than 1 and half lines.  Same code has been running for a week with this object on thousands of imports for another project without this error occurring.

James Zukowski

  • Diamond Member
  • *****
  • Posts: 297
    • View Profile
Re: UNT & HFN returning -1
« Reply #1 on: July 21, 2022, 03:50:50 PM »
Are you running with the 'XF' parameter set? If not, you're limited to 63 channels open at a time. If you hit the limit, that probably explains the -1...none left to give you.
James Zukowski
Sr. Developer - J&E

BRAND>SAFWAY
Brand Industrial Services

Peter.Higgins

  • Diamond Member
  • *****
  • Posts: 124
    • View Profile
Re: UNT & HFN returning -1
« Reply #2 on: July 21, 2022, 03:57:23 PM »
James,  -'XF' at the time and place of the -1

James Zukowski

  • Diamond Member
  • *****
  • Posts: 297
    • View Profile
Re: UNT & HFN returning -1
« Reply #3 on: July 21, 2022, 05:02:35 PM »
That means you're running with a limit of 63 local channels (+ console), and 64 globals. If you set_param 'XF', that will open the channel numbers to about 32k each (though documentation indicates a total limit of 500 open per session).
Beware if you have any old code that relies on 2- or 3-digit channel numbers, especially in strings. HFN with 'XF' will start at 32767 instead of 63. UNT will always count up from 1.
James Zukowski
Sr. Developer - J&E

BRAND>SAFWAY
Brand Industrial Services

Peter.Higgins

  • Diamond Member
  • *****
  • Posts: 124
    • View Profile
Re: UNT & HFN returning -1
« Reply #4 on: July 21, 2022, 08:29:39 PM »
Thanks James,
You are correct.  I followed the example in HFN below and it is messed up.  Its been a long time, maybe 20 years since I've had to explicitly set XF.

set_param -'XF'
?hfn
32767