Variable Type Plugin

Variable Type Plugin - Including a function that will show the type a variable is - Сообщения

#1 Опубликовано: 08.01.2013 11:49:29
sublim21

sublim21

3 сообщений из 36 понравились пользователям.

Группа: 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 Опубликовано: 08.01.2013 12:54:55
Davide Carpi

Davide Carpi

1416 сообщений из 2873 понравились пользователям.

Группа: 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 Опубликовано: 08.01.2013 16:28:02
sublim21

sublim21

3 сообщений из 36 понравились пользователям.

Группа: 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 КиБ) скачан 42 раз(а).
#4 Опубликовано: 08.01.2013 17:03:01
Infinity

Infinity

3 сообщений из 30 понравились пользователям.

Группа: 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 пользователям понравился этот пост
Davide Carpi 08.01.2013 17:21:00, Radovan Omorjan 08.01.2013 19:28:00
#5 Опубликовано: 08.01.2013 17:37:34
Davide Carpi

Davide Carpi

1416 сообщений из 2873 понравились пользователям.

Группа: 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 Опубликовано: 08.01.2013 19:50:22
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: 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 пользователям понравился этот пост
Davide Carpi 08.01.2013 21:03:00
#7 Опубликовано: 09.01.2013 08:49:59
Davide Carpi

Davide Carpi

1416 сообщений из 2873 понравились пользователям.

Группа: 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 Опубликовано: 09.01.2013 14:24:14
sublim21

sublim21

3 сообщений из 36 понравились пользователям.

Группа: 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 КиБ) скачан 44 раз(а).
#9 Опубликовано: 09.01.2013 15:07:47
Davide Carpi

Davide Carpi

1416 сообщений из 2873 понравились пользователям.

Группа: 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 Опубликовано: 10.01.2013 11:42:42
sublim21

sublim21

3 сообщений из 36 понравились пользователям.

Группа: 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 КиБ) скачан 44 раз(а).
#11 Опубликовано: 10.01.2013 13:01:17
Davide Carpi

Davide Carpi

1416 сообщений из 2873 понравились пользователям.

Группа: 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 Опубликовано: 11.01.2013 11:00:51
sublim21

sublim21

3 сообщений из 36 понравились пользователям.

Группа: User

That's a good programming practice websurfer.

Thanks for the plugin link as well.

-Pete
#13 Опубликовано: 06.02.2013 16:59:38
stevec

stevec

1 сообщений из 5 понравились пользователям.

Группа: 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 Опубликовано: 06.02.2013 19:27:54
Davide Carpi

Davide Carpi

1416 сообщений из 2873 понравились пользователям.

Группа: 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
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений