Writing to data files with an arbitrary extension

Writing to data files with an arbitrary extension - SMath feature to write data files with an arbitrary extension and possible workarounds. - Messages

#1 Posted: 8/2/2016 1:02:27 PM
marcofk

marcofk

8 likes in 19 posts.

Group: User

Hello all. It's been a while since I last posted, but I've still been using SMath extensively and recommended it to all my colleagues.

I've got a new question:

Currently I'm having to use "fwrite" to produce an output file, but even if I name it with an extension different from .txt, it will ignore the extension I give in the filename and write a .txt.

There are some preset option with the different export functions but if I want to create a file with, say, a .myfile extension I have to create a .txt file and then use good old .bat scripts, which, although not too complex to implement, is a rather clunky and not very user-friendly way to solve the problem.

Is there a way to write files with an arbitrary extension? Or is there any way to run a windows script (e.g. the .bat file) from within SMath or SMath viewer? Does the script region work with this?

Any suggestions?

Thanks everyone.
#2 Posted: 8/2/2016 2:57:41 PM
Davide Carpi

Davide Carpi

1416 likes in 2873 posts.

Group: Moderator

Hello marcofk,

You can run any format supported by your OS using the hyperlink region.

As for fwrite I can provide an improvement to not force the "txt" extension
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 users liked this post
marcofk 8/3/2016 8:24:00 AM
#3 Posted: 8/2/2016 3:12:32 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

I'm sure I don't understand your question. Maybe because there nothing to understand.
Smath saves in its own style, i.e: nothing to specify because it saves in its own
"mat2sys" style. Nothing universal like Mathcad read/write [*.prn, *.dat, *.txt ...].
As you open this work sheet, it will creates the appropriate directory, save what
you want [very usefull to collect model functions c/w parameters].
All that said is about Smath 5346, like Mathematica 4.0 who considered the world
was empty. File format like this or like that is one thing. The truth about data
saving is that the universal file format since long time is *.dat ...
in the worst case Excel.
Example: near where you live in UK, there is the sole world wide "climate laboratory".
This lab "HadCRU" [Hadley Climate Research Unit] saves data in *.dat, so that anybody
in the world can read.

Smath of latest version may have extra write/read options.

Jean

File Create.sm (24 KiB) downloaded 65 time(s).

#4 Posted: 8/3/2016 8:27:46 AM
marcofk

marcofk

8 likes in 19 posts.

Group: User

Wrote

Hello marcofk,

You can run any format supported by your OS using the hyperlink region.

As for fwrite I can provide an improvement to not force the "txt" extension



Davide,

thanks for the reply. In principle, an improved fwrite command will do the trick.

Cheers,

Marco
#5 Posted: 8/15/2016 7:20:44 PM
Davide Carpi

Davide Carpi

1416 likes in 2873 posts.

Group: Moderator

Updated, you can try the plugin using the latest nightly build
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 users liked this post
marcofk 8/16/2016 8:57:00 AM
#6 Posted: 8/16/2016 9:04:35 AM
marcofk

marcofk

8 likes in 19 posts.

Group: User

Hi Davide,

not sure if my previous message came through when I sent it with "Quick reply", so I'll post it again:

I've tried your update and it now saves files with an arbitrary extension, and that's good enough for me in my application. Thanks very much for that.

However, I've noticed that control characters like e.g. {\n} - which should cause the following text to be written in a new line - are now written to the file as text, i.e. as I typed in the example.

The joys of debugging, eh?

Cheers,

Marco
1 users liked this post
Davide Carpi 8/16/2016 12:10:00 PM
#7 Posted: 8/16/2016 12:10:45 PM
Davide Carpi

Davide Carpi

1416 likes in 2873 posts.

Group: Moderator

Thank you Marco

totally my fault, fixed & updated
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 users liked this post
marcofk 8/17/2016 5:05:00 AM
  • New Posts New Posts
  • No New Posts No New Posts