-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the EN_loadpatternfile
function to load pattern data from a .pat
file into INP
#812
Add the EN_loadpatternfile
function to load pattern data from a .pat
file into INP
#812
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the liberty of re-writing your EN_loadpatternfile
function. It avoids reallocating memory each time a new line is read from the file and uses EPANET's own getfloat
function in place of the unreliable atof
function to convert strings to numbers. Please see the attached file.
Co-Authored-By: Lew Rossman <LRossman@outlook.com>
It's good that you took the initiative, @LRossman. Feel free to make any changes as needed. Thank you! Also, we now need to add the function |
I was thinking, why have the function work only for a new pattern and not for an existing one as well. If you agree with this, then the code modification needed is shown below:
|
Yes, it's a good idea to use an existing pattern ID not only for new patterns, and I agree. Regarding the from
to
|
Co-Authored-By: Lew Rossman <LRossman@outlook.com>
I would rather not change
Neither of these involves |
I checked it, and the problem is that the |
OK, good. My preference is to change the following line:
to
|
But if we add |
The way I read the code is that if a line is blank or doesn't contain a valid number then But you're right in saying that the code needs to be tested. |
I think I found the problem. When The fix is as follows:
I tested this updated code on a number of pattern files, some with all numbers, some with blank or comment lines and some empty, and everything seemed to work ok. |
Yes, it looks good now. Thank you, @LRossman! |
No description provided.