Rank: Advanced Member Groups: Registered, Advanced Member Joined: 10/11/2010(UTC) Posts: 1,494 Was thanked: 1274 time(s) in 745 post(s)
|
Mathcad File Access (now part of the Mathcad Toolbox) 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(). Edited by user 08 December 2021 17:31:40(UTC)
| Reason: Not specified |
Russia ☭ forever Viacheslav N. Mezentsev |
2 users thanked uni for this useful post.
|
on 11/04/2012(UTC), on 11/04/2012(UTC)
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 10/11/2010(UTC) Posts: 1,494 Was thanked: 1274 time(s) in 745 post(s)
|
Updated. Fixed bugs in functions for working with images. |
Russia ☭ forever Viacheslav N. Mezentsev |
1 user thanked uni for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,988 Was thanked: 1126 time(s) in 723 post(s)
|
In READBIN(), the last argument specifies the number of lines to read. If set to zero, in Mathcad you get as many lines as the file can give, in SMath you get an empty matrix (good for stacking loop init, as I learned yesterday). If I specify more lines than the file can provide, then in Mathcad the result is augmented by zeros, in SMath I get as many lines as the file can give.
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
|
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 10/11/2010(UTC) Posts: 1,494 Was thanked: 1274 time(s) in 745 post(s)
|
Ok, I'll try to fix the functions and add a description (you can find it in the Mathcad Help). |
Russia ☭ forever Viacheslav N. Mezentsev |
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 10/11/2010(UTC) Posts: 1,494 Was thanked: 1274 time(s) in 745 post(s)
|
Updated. READ_RED(), READ_GREEN() and READ_BLUE() added. READBIN() fixed. |
Russia ☭ forever Viacheslav N. Mezentsev |
1 user thanked uni for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,988 Was thanked: 1126 time(s) in 723 post(s)
|
Uni, 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. - 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. Edited by user 05 May 2013 00:41:56(UTC)
| Reason: Not specified File Attachment(s): mkraska attached the following image(s): |
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 10/11/2010(UTC) Posts: 1,494 Was thanked: 1274 time(s) in 745 post(s)
|
Originally Posted by: mkraska ... - 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). Edited by user 05 May 2013 01:19:27(UTC)
| Reason: Not specified |
Russia ☭ forever Viacheslav N. Mezentsev |
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 10/11/2010(UTC) Posts: 1,494 Was thanked: 1274 time(s) in 745 post(s)
|
Originally Posted by: mkraska Uni, 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. Originally Posted by: mkraska - 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. |
Russia ☭ forever Viacheslav N. Mezentsev |
1 user thanked uni for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,988 Was thanked: 1126 time(s) in 723 post(s)
|
Originally Posted by: uni 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.
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... |
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,988 Was thanked: 1126 time(s) in 723 post(s)
|
Originally Posted by: uni 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? |
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 10/11/2010(UTC) Posts: 1,494 Was thanked: 1274 time(s) in 745 post(s)
|
Originally Posted by: ioan92 Hi uni, Please, where could I find READBIN() and WRITEBIN() functions parameters complete description. Thanks and Best Regards, Ioan I have attached a description. |
Russia ☭ forever Viacheslav N. Mezentsev |
1 user thanked uni for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 10/11/2010(UTC) Posts: 1,494 Was thanked: 1274 time(s) in 745 post(s)
|
Updated. wfile(3) and rfile(2) added. Edited by user 06 May 2013 20:10:34(UTC)
| Reason: Not specified |
Russia ☭ forever Viacheslav N. Mezentsev |
2 users thanked uni for this useful post.
|
on 06/05/2013(UTC), on 06/05/2013(UTC)
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,988 Was thanked: 1126 time(s) in 723 post(s)
|
I propose the same changes like here in order to make relative path names relative to the directory of the currently open document instead of the current directory of the system. Thus you could make portable arrangements of data and SMath documents. 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. Edited by user 13 October 2013 14:28:58(UTC)
| Reason: Not specified mkraska attached the following image(s): |
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 10/11/2010(UTC) Posts: 1,494 Was thanked: 1274 time(s) in 745 post(s)
|
Updated. DocumentDirectory() added. Try now. |
Russia ☭ forever Viacheslav N. Mezentsev |
1 user thanked uni for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,988 Was thanked: 1126 time(s) in 723 post(s)
|
Simply great! Thanks uni. This gives two options: either you build the path for file access ops using concat or you set the current directory to the document directory. This relieves the need for the changes in the access functions, now IMHO having priority "nice to have". Edit: Don't forget to set file access ops to optimization> numeric. That makes quite a difference in performance. Edited by user 14 October 2013 23:58:08(UTC)
| Reason: Not specified mkraska attached the following image(s): |
|
1 user thanked mkraska for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 10/11/2010(UTC) Posts: 1,494 Was thanked: 1274 time(s) in 745 post(s)
|
Updated. Play() function added (for wav files). Edited by user 14 October 2013 23:54:24(UTC)
| Reason: Not specified |
Russia ☭ forever Viacheslav N. Mezentsev |
1 user thanked uni for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,988 Was thanked: 1126 time(s) in 723 post(s)
|
Handbook page for sound files added. File Attachment(s): mkraska attached the following image(s): |
|
1 user thanked mkraska for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 10/11/2010(UTC) Posts: 1,494 Was thanked: 1274 time(s) in 745 post(s)
|
I don't understand the problem and do not recommend to use the CurrentDirectory() function for this purpose. If the operating system denies write access, then I can't workaround this. I'm not sure that administrative privileges confirmation during execution is a good idea. Edited by user 27 March 2014 12:25:00(UTC)
| Reason: Not specified |
Russia ☭ forever Viacheslav N. Mezentsev |
1 user thanked uni for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 10/11/2010(UTC) Posts: 1,494 Was thanked: 1274 time(s) in 745 post(s)
|
Windows works with processes. SMath Studio - process, but functions from the plugin are not. You can assign privilegies for processes, for functions (as I know) you can't do that. So, the right way - run SMath Studio with administrative privileges. As for the dialog box above, I'll think about it. I don't know how to implement this. Edited by user 27 March 2014 15:46:16(UTC)
| Reason: Not specified |
Russia ☭ forever Viacheslav N. Mezentsev |
1 user thanked uni for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 17/01/2013(UTC) Posts: 296 Location: Khabarovsk, Russia Was thanked: 151 time(s) in 107 post(s)
|
Originally Posted by: ioan92 The 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... |
Best regards, Mike Kaganski |
1 user thanked mikekaganski for this useful post.
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.