PxPlus User Forum

Main Board => Discussions => Programming => Topic started by: Peter.Higgins on July 21, 2022, 03:27:27 PM

Title: UNT & HFN returning -1
Post by: Peter.Higgins 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.
Title: Re: UNT & HFN returning -1
Post by: James Zukowski 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.
Title: Re: UNT & HFN returning -1
Post by: Peter.Higgins on July 21, 2022, 03:57:23 PM
James,  -'XF' at the time and place of the -1
Title: Re: UNT & HFN returning -1
Post by: James Zukowski 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.
Title: Re: UNT & HFN returning -1
Post by: Peter.Higgins 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