MathcadFileAccess - The following functions are useful for reading various file types into arrays. - Messages





Functions list:
Reading and Writing Data using Delimited ASCII files (not implemented yet): READPRN(), READBIN(), READBIN(),
Reading and Writing Binary Data: READBIN(), WRITEBIN(),
Reading and Writing Sound Files: GETWAVINFO(), READWAV(), WRITEWAV(),
Reading and Writing Image Files: READ_IMAGE(), READBMP(), READRGB(), READ_RED(), READ_GREEN(), READ_BLUE(),
Other functions: CurrentDirectory(), DocumentDirectory(), GetFolderPath(), wfile(3), rfile(2), Play().
[albumimg]100[/albumimg] [albumimg]115[/albumimg]
MC15. Reading And Writing Binary Data.pdf (63 KiB) downloaded 337 time(s).
Thus, is the intent to provide a very big number of lines if I do not know the size of the file in advance?
Martin

[albumimg]107[/albumimg]
However, here are some issues.
- READBIN: in some situations, changes in the sheet trigger the results to become wrong. Manual re-calculation via toolbar button sets the results back to correct values, but otherwise they persist on the sheet. I attach two screenshots, the upper before re-calculation and the lower after. No other difference between these pictures, just pressed the update button. The sm-sheet is included in the zip. The problem is completely reproducible with the given example.
- READBIN: The docs refer to default values for endian, rows, skip and rows. How is the user expected to adress these defaults? Do you plan to provide READBIN(1) as in Mathcad? What would then be the default type?
- READ_xxx: These functions seem to insist on 32bpp images, at least, the one in the attached zip fails to be read in. It is a screenshot, which I intended to use instead of the not so colorful school logo.
The image region is not so picky about that, the image can be displayed without problems. However, if a read statement fails and then the result of that failed op is fed to the image, SMath crashes.
MathcadFileAccess_problems.zip (3 KiB) downloaded 118 time(s).
Wrote
...
- READ_xxx: These functions seem to insist on 32bpp images, at least, the one in the attached zip fails to be read in. It is a screenshot, which I intended to use instead of the not so colorful school logo.
The image region is not so picky about that, the image can be displayed without problems. However, if a read statement fails and then the result of that failed op is fed to the image, SMath crashes.
Try to update ImageRegion plugin. As for the images. Only two formats are supported for now: 24bppRGB and 32bppRGB (without alpha channel). Your image has an alpha channel (transparency).
[albumimg]109[/albumimg]
WroteUni, thanks again for the fast debugging response.
However, here are some issues.
- READBIN: in some situations, changes in the sheet trigger the results to become wrong. Manual re-calculation via toolbar button sets the results back to correct values, but otherwise they persist on the sheet. I attach two screenshots, the upper before re-calculation and the lower after. No other difference between these pictures, just pressed the update button. The sm-sheet is included in the zip. The problem is completely reproducible with the given example.
That I don't understand. It seems that reading is the same file, but with a different content. Below is running another writing function and it can change the data. Try to disable or enable the calculation for one of them (WRITEBIN). It is better to use a different file for testing in one sheet.
Wrote
- READBIN: The docs refer to default values for endian, rows, skip and rows. How is the user expected to adress these defaults? Do you plan to provide READBIN(1) as in Mathcad? What would then be the default type?
I forgot to remove it when copying, but it is possible to have a simplified version of the function.
WroteTry to disable or enable the calculation for one of them (WRITEBIN). It is better to use a different file for testing in one sheet.
OK, disabling the second write operation (in fact I just disabled the complete lower part of the sheet) resolves the issue. However, you might consider to change your example WRITEBIM.sm, in order not to encourage the user to do dangerous things.
I guess the trick was, that my changes were between the first write operation and the first read op. SMath upon re-calculation had no reason to go through any stuff above the change. Thus the first read op found the result of the second write op.
Sometimes SMath is simply too smart for me...
As for the Mathcad compatibility, I just do the comparison, you decide if you pay attention and time share to it. However, the name of the plugin is sort of promise...
Wrote
Try to update ImageRegion plugin. As for the images. Only two formats are supported for now: 24bppRGB and 32bppRGB (without alpha channel). Your image has an alpha channel (transparency).
The update resolved the crash issue. I was irritated by the fact that the read operation did not complain at all, but subsequent ops like asking for the number of rows gave the image format error message. That was due to the default setting of symbolic optimization, i.e. delayed execution of the read op. Obviously, just assigning the result of a read operation to some variable is no read test at all if in symbolic mode.
I am tired of repeating the issue of visually different operators for sym/num assignment and evaluation. Andrey seems to have good reasons for refusing even to give us back the arrow for symbolic evaluation. Is that protected by Mathcad patents?
WroteHi uni,
Please, where could I find READBIN() and WRITEBIN() functions parameters complete description.
Thanks and Best Regards,
Ioan
I have attached a description.
MC15. Reading And Writing Binary Data.pdf (63 KiB) downloaded 145 time(s).
[albumimg]115[/albumimg]
Edit: I'd like to also ask for a function DocumentDirectory() which returns the path name of the currently open document. Thus we could benefit from the same improvements with built-in functions like importData.
Edit: Don't forget to set file access ops to optimization> numeric. That makes quite a difference in performance.
As for the dialog box above, I'll think about it. I don't know how to implement this.
WroteThe plugin simply do no execute the write command, without any preventing message ! It takes me some time to understand what happens...
Supposedly fixing this specific (mis)behaviour by simply returning error with clear message would be enough, no need to emit some unexpected dialogs? Suppose the scenario when a sheet has quite a some different IO operations to a number of locations; and this has a potential of emitting endless series of such dialogs. Also, aquiring priveleges may end up in yet another software capable of hosting viruses...
-
New Posts
-
No New Posts