Opened 7 years ago
Closed 7 years ago
#4710 closed defect (fixed)
Cannot pass a string “parameter” that is read from a file to a function
Reported by: | Owned by: | Adeel Asghar | |
---|---|---|---|
Priority: | high | Milestone: | 1.13.0 |
Component: | Frontend | Version: | v1.12.0 |
Keywords: | Cc: |
Description
Hello,
I have been recently experiencing an unusual warning with the new version of OM compiler (v1.12) and libraries when using the “Streams.readLine” function. I have attached a simple example to demonstrate the problem, which I suspect is a bug.
As you can see in test_line.mo, First I am trying to read line number 7 from a weather data file (i.e. weather.motab) as a string “parameter” (i.e. line7_read) and pass it to a function (i.e. getMetadata()), which leads to the following warning:
Parameter meta.line7 has no value, and is fixed during initialisation (fixed=true), using available start value (start=0.0) as default value.
This means that the “line7_read” parameter is not passed to the getMetadata() function since “meta.line7” becomes blank, that is why OM uses a default initial value (i.e. 0.0) to assign to it, which is still another bug since this is a string parameter not a real one!
However, when I manually add this line from the file to a string parameter (i.e. line7_local), the getMetadata() function works just fine. Therefore, I reckon the problem is that a parameter value read from a file cannot be passed to a function for some odd reason.
As such, I would appreciate it if you could please try to run the attached OM file along with the weather file attached, and let me know the workaround if there is one.
Looking forward to hearing from you soon.
Regards,
Ali Shirazi
Attachments (2)
Change History (3)
by , 7 years ago
Attachment: | test_line.mo added |
---|
comment:1 by , 7 years ago
Component: | OMEdit → Frontend |
---|---|
Milestone: | Future → 1.13.0 |
Resolution: | → fixed |
Status: | new → closed |
This seems to have already been fixed, at least it works fine for me in the latest build. An initial equation is generated for meta.line7 and the output of the three parameters is the same. You can use the nightly build if you wish to try it out yourself.
Also note that the parameters you print out are already Strings, so using the String function on them is unnecessary and even illegal (this is currently accepted by the compiler anyway, but will probably change in the future).
test case to reproduce the described warning