Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


2 Pages12>
Options
Go to last post Go to first unread
Offline uni  
#1 Posted : 11 April 2012 12:46:21(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

Was thanked: 1274 time(s) in 745 post(s)
Mathcad File Access (now part of the Mathcad Toolbox)

SMath Studio compatibility SMath Viewer compatibility mono compatibility Extension page Sources


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

File Attachment(s):
MC15. Reading And Writing Binary Data.pdf (64kb) downloaded 277 time(s).
Russia ☭ forever
Viacheslav N. Mezentsev
thanks 2 users thanked uni for this useful post.
on 11/04/2012(UTC),  on 11/04/2012(UTC)

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline uni  
#2 Posted : 04 May 2013 17:40:33(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

Was thanked: 1274 time(s) in 745 post(s)
Updated. Fixed bugs in functions for working with images.
Russia ☭ forever
Viacheslav N. Mezentsev
thanks 1 user thanked uni for this useful post.
on 04/05/2013(UTC)
Offline mkraska  
#3 Posted : 04 May 2013 18:52:33(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,985
Germany

Was thanked: 1124 time(s) in 721 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

Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline uni  
#4 Posted : 04 May 2013 19:10:28(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

Was thanked: 1274 time(s) in 745 post(s)
Good 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
Offline uni  
#5 Posted : 04 May 2013 22:19:31(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

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
thanks 1 user thanked uni for this useful post.
on 04/05/2013(UTC)
Offline mkraska  
#6 Posted : 05 May 2013 00:37:36(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,985
Germany

Was thanked: 1124 time(s) in 721 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):
MathcadFileAccess_problems.zip (4kb) downloaded 70 time(s).
mkraska attached the following image(s):
colors.PNG
readbin1.PNG
readbin2.PNG
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline uni  
#7 Posted : 05 May 2013 00:44:51(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

Was thanked: 1274 time(s) in 745 post(s)
Originally Posted by: mkraska Go to Quoted Post

...
- 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
Offline uni  
#8 Posted : 05 May 2013 01:01:31(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

Was thanked: 1274 time(s) in 745 post(s)
Originally Posted by: mkraska Go to Quoted Post
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 Go to Quoted Post

- 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
thanks 1 user thanked uni for this useful post.
on 05/05/2013(UTC)
Offline mkraska  
#9 Posted : 05 May 2013 01:33:11(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,985
Germany

Was thanked: 1124 time(s) in 721 post(s)
Originally Posted by: uni Go to Quoted Post
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...
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline mkraska  
#10 Posted : 05 May 2013 01:51:59(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,985
Germany

Was thanked: 1124 time(s) in 721 post(s)
Originally Posted by: uni Go to Quoted Post

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?



Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline uni  
#11 Posted : 05 May 2013 20:19:39(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

Was thanked: 1274 time(s) in 745 post(s)
Originally Posted by: ioan92 Go to Quoted Post
Hi uni,
Please, where could I find READBIN() and WRITEBIN() functions parameters complete description.
Thanks and Best Regards,
Ioan

I have attached a description.
File Attachment(s):
MC15. Reading And Writing Binary Data.pdf (64kb) downloaded 92 time(s).
Russia ☭ forever
Viacheslav N. Mezentsev
thanks 1 user thanked uni for this useful post.
on 05/05/2013(UTC)
Offline uni  
#12 Posted : 06 May 2013 00:48:10(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

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
thanks 2 users thanked uni for this useful post.
on 06/05/2013(UTC),  on 06/05/2013(UTC)
Offline mkraska  
#13 Posted : 13 October 2013 13:03:31(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,985
Germany

Was thanked: 1124 time(s) in 721 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):
path.PNG
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline uni  
#14 Posted : 14 October 2013 23:23:59(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

Was thanked: 1274 time(s) in 745 post(s)
Updated. DocumentDirectory() added. Try now.
Russia ☭ forever
Viacheslav N. Mezentsev
thanks 1 user thanked uni for this useful post.
on 14/10/2013(UTC)
Offline mkraska  
#15 Posted : 14 October 2013 23:44:44(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,985
Germany

Was thanked: 1124 time(s) in 721 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):
image.PNG
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 1 user thanked mkraska for this useful post.
on 15/10/2013(UTC)
Offline uni  
#16 Posted : 14 October 2013 23:48:52(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

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
thanks 1 user thanked uni for this useful post.
on 15/10/2013(UTC)
Offline mkraska  
#17 Posted : 15 October 2013 01:12:26(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,985
Germany

Was thanked: 1124 time(s) in 721 post(s)
Handbook page for sound files added.
File Attachment(s):
Section file access wave.sm (17kb) downloaded 52 time(s).
mkraska attached the following image(s):
sound.PNG
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 1 user thanked mkraska for this useful post.
on 15/10/2013(UTC)
Offline uni  
#18 Posted : 27 March 2014 12:21:07(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

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
thanks 1 user thanked uni for this useful post.
on 27/03/2014(UTC)
Offline uni  
#19 Posted : 27 March 2014 15:42:48(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

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
thanks 1 user thanked uni for this useful post.
on 27/03/2014(UTC)
Offline mikekaganski  
#20 Posted : 27 March 2014 17:02:03(UTC)
mikekaganski


Rank: Advanced Member

Groups: Registered
Joined: 17/01/2013(UTC)
Posts: 296
Man
Russian Federation
Location: Khabarovsk, Russia

Was thanked: 151 time(s) in 107 post(s)
Originally Posted by: ioan92 Go to Quoted Post
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
thanks 1 user thanked mikekaganski for this useful post.
on 27/03/2014(UTC)
Users browsing this topic
Guest
Similar Topics
[MathcadFileAccess] Read Image Puzzle (Bugs & Problems)
by Jean Giraud 21/02/2016 23:26:19(UTC)
2 Pages12>
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.