Variable Type Plugin

Variable Type Plugin - Including a function that will show the type a variable is - Messages

#1 Posted: 1/8/2013 11:49:29 AM
sublim21

sublim21

3 likes in 36 posts.

Group: User

Hey all,

I've been trying to build a program that will return the type a variable is.

Basically, the function is an expansion of the IsString function, such that there is,

IsMatrix
IsNumber
IsSystem

etc..

I've attempted to accomplish this with num2str declarations and then seeing if there exists a string of "mat(" in the beginning. However, due to the problems of num2str 'ing matrices, this method fails. As does any other method i've tried.

I feel the best way to accomplish the variable type would be by building a plugin, however, my plugin building skills aren't up to the task. :/

-Pete
#2 Posted: 1/8/2013 12:54:55 PM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

Wrote

Hey all,

I've been trying to build a program that will return the type a variable is.

Basically, the function is an expansion of the IsString function, such that there is,

IsMatrix
IsNumber
IsSystem

etc..

I've attempted to accomplish this with num2str declarations and then seeing if there exists a string of "mat(" in the beginning. However, due to the problems of num2str 'ing matrices, this method fails. As does any other method i've tried.

I feel the best way to accomplish the variable type would be by building a plugin, however, my plugin building skills aren't up to the task. :/

-Pete



You can try to use/enhance the IsScalar() and IsMatrix() functions of varManager snippet (updated to fix an issue in IsArray(#)).

EDIT: If you are writing a plugin you can use something like the getNumOfElements function in StatisticalTools or NonlinearSolvers plugins


best regards,

w3b5urf3r
StatisticalTools - SharpDevelop.png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#3 Posted: 1/8/2013 4:28:02 PM
sublim21

sublim21

3 likes in 36 posts.

Group: User

Wrote

Wrote

Hey all,

I've been trying to build a program that will return the type a variable is.

Basically, the function is an expansion of the IsString function, such that there is,

IsMatrix
IsNumber
IsSystem

etc..

I've attempted to accomplish this with num2str declarations and then seeing if there exists a string of "mat(" in the beginning. However, due to the problems of num2str 'ing matrices, this method fails. As does any other method i've tried.

I feel the best way to accomplish the variable type would be by building a plugin, however, my plugin building skills aren't up to the task. :/

-Pete



You can try to use/enhance the IsScalar() and IsMatrix() functions of varManager snippet (updated to fix an issue in IsArray(#)).

EDIT: If you are writing a plugin you can use something like the getNumOfElements function in StatisticalTools or NonlinearSolvers plugins


best regards,

w3b5urf3r




whatIsFunction.sm (9 KiB) downloaded 64 time(s).
#4 Posted: 1/8/2013 5:03:01 PM
Infinity

Infinity

3 likes in 30 posts.

Group: User

Hi,

I started a new PlugIn Project called FunctionBox for SMath.
To bring it to life, I added the three requested functions
- IsMatrix
- IsSystem
- IsNumber

I did a lot of SMath plugin programming in the past and will contribute to the SMath project by providing some helpful plugins.
In the near future I will create a Wiki page for the FunctionBox where I describe the already available functions.
Also a post in this forum related to the plugin would be good to discuss new features.

So, find attached the FunctionBox.dll plugin and feel free to test it and provide feedback.

Have fun,
Infinity
Showcase.jpg
2 users liked this post
Davide Carpi 1/8/2013 5:21:00 PM, Radovan Omorjan 1/8/2013 7:28:00 PM
#5 Posted: 1/8/2013 5:37:34 PM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

Hi Infinity

I'm very glad that you came back with a new plugin

Just as a feedback the IsNumber fails evaluating infinity and imaginary unit and there are some issues with single elements arrays/systems


best regards,

w3b5urf3r
SMath Studio - [Fbox_debug.sm]_2.png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#6 Posted: 1/8/2013 7:50:22 PM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

Wrote


I did a lot of SMath plugin programming in the past and will contribute to the SMath project by providing some helpful plugins.
In the near future I will create a Wiki page for the FunctionBox where I describe the already available functions.
Also a post in this forum related to the plugin would be good to discuss new features.



Thank you Infinity for your efforts

As far as I could see, user made plugins started to grow in numbers . There are not to many of them yet, but I've already feel that I start losing the track of them mainly because they are scattered here on the Forum - most of them are in "Samples" forum and mixed with some other examples of using SMath . w3b5urf3r is trying to make a list of plugins and links to them on Wiki page PLUGINS. Essentially, we just need DLL's with accompanied help files in order to use these plugins and, therefore, I suppose that a new dedicated Forum "User plugins" might be more appropriate for this.

Any comments about it?

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
1 users liked this post
Davide Carpi 1/8/2013 9:03:00 PM
#7 Posted: 1/9/2013 8:49:59 AM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

Wrote

Thank you Infinity for your efforts

As far as I could see, user made plugins started to grow in numbers . There are not to many of them yet, but I've already feel that I start losing the track of them mainly because they are scattered here on the Forum - most of them are in "Samples" forum and mixed with some other examples of using SMath . w3b5urf3r is trying to make a list of plugins and links to them on Wiki page PLUGINS. Essentially, we just need DLL's with accompanied help files in order to use these plugins and, therefore, I suppose that a new dedicated Forum "User plugins" might be more appropriate for this.

Any comments about it?

Regards,
Radovan



I agree with you, I think that a dedicated forum/sub-forum is desirable
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#8 Posted: 1/9/2013 2:24:14 PM
sublim21

sublim21

3 likes in 36 posts.

Group: User

Updated the whatIs function to handle infinity and others. Checked to make sure correct output will be given regardless of optimization option. Corrected sheet is attached.

I also second the idea of creating a plugin forum.

Also, if we're going to create a database of plugins, and snippets, then i suggest we use couchdb as the database software to hold the code.
whatIsFunction.sm (18 KiB) downloaded 66 time(s).
#9 Posted: 1/9/2013 3:07:47 PM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

Wrote

Updated the whatIs function to handle infinity and others. Checked to make sure correct output will be given regardless of optimization option. Corrected sheet is attached.

I also second the idea of creating a plugin forum.

Also, if we're going to create a database of plugins, and snippets, then i suggest we use couchdb as the database software to hold the code.



Good, also a snippet sub-forum it's not a bad idea!

There still remain some other issues in your snippet (see the snapshot)


regards,

w3b5urf3r
SMath Studio - [whatIsFunction.sm].png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#10 Posted: 1/10/2013 11:42:42 AM
sublim21

sublim21

3 likes in 36 posts.

Group: User

Hey websurfer,

You're correct about the error. I've fixed the sheet and have attached it below.

It'll work for everything i've tested it for, except strings with leading spaces " a".

Personally i don't like how the sheet is laid out. Duck typing the solution is a bad idea. As is the weird nested function solution, but i can't do a better solution until the num2str with spaces and other characters is fixed.

for now, it is highly recommended that you stick to A-z, 0-9, and _ until the bugs can be worked out.

Speaking of which, in your sheets websurfer, i noticed you use #var inside functions, whats the reason for that?

-Pete
whatIsFunction.sm (20 KiB) downloaded 67 time(s).
#11 Posted: 1/10/2013 1:01:17 PM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

Wrote

Hey websurfer,

You're correct about the error. I've fixed the sheet and have attached it below.

It'll work for everything i've tested it for, except strings with leading spaces " a".

Personally i don't like how the sheet is laid out. Duck typing the solution is a bad idea. As is the weird nested function solution, but i can't do a better solution until the num2str with spaces and other characters is fixed.

for now, it is highly recommended that you stick to A-z, 0-9, and _ until the bugs can be worked out.

Speaking of which, in your sheets websurfer, i noticed you use #var inside functions, whats the reason for that?

-Pete



Good ^__^

I think that a better and strong variable type identification will be implemented (soon or later) in the SMath executables, but at least for now our snippets and plugins could be a good help for users.

Sometimes I use #var or _var to distinguish between local and global variables. It's not really required but sometimes could be useful (especially for large scripts debugging).


regards,

w3b5urf3r

P.S. here there's a new wiki page with a list of compiled PLUGINS.
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#12 Posted: 1/11/2013 11:00:51 AM
sublim21

sublim21

3 likes in 36 posts.

Group: User

That's a good programming practice websurfer.

Thanks for the plugin link as well.

-Pete
#13 Posted: 2/6/2013 4:59:38 PM
stevec

stevec

1 likes in 5 posts.

Group: User

A plug-in repository would get my vote!
if you decide to go down this route, might I suggest a plug-in manager plug-in such as is common in a lot of software. I would also suggest a rating system for plug-ins to indicate the maturity of a plug-in.
#14 Posted: 2/6/2013 7:27:54 PM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

Wrote

A plug-in repository would get my vote!
if you decide to go down this route, might I suggest a plug-in manager plug-in such as is common in a lot of software. I would also suggest a rating system for plug-ins to indicate the maturity of a plug-in.



You can browse the repository clicking on the "Code" button on the top of the page.

Using Tortoise SVN or other SVN tools you can see more details about each plugin.


regards,

w3b5urf3r
Variable Type Plugin - Feature Requests - SMath Studio Forum - Mozilla Firefox.png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
  • New Posts New Posts
  • No New Posts No New Posts