Variable Type Plugin - Including a function that will show the type a variable is - Сообщения
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
WroteHey 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
WroteWroteHey 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 раз(а).
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

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
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

Any comments about it?
Regards,
Radovan
WroteThank 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

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 раз(а).
WroteUpdated 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
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 раз(а).
WroteHey 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.
Thanks for the plugin link as well.
-Pete
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.
WroteA 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
-
Новые сообщения
-
Нет новых сообщений