1 Pages (13 items)
SMath Plugin Tutorial - Need Help Please - Messages
#1 Posted: 3/12/2015 7:42:55 PM
Good day,
I am attempting to follow through tutorial on plugin development in VB.NET:
https://smath.com/wiki/GetFile.aspx?File=Developer%20Guide/Tutorial%20on%20creating%20plugin%20for%20Smath.pdf
I have not reached a glorious conclusion yet, however even now I can notice something to be incorrect (see screenshot).
Could someone please point out what I am doing wrong? Please keep in mind that I have never attempted to piece few lines of code together before and hence might miss obvious things. I am attaching my project folder.
Thanks!

I am attempting to follow through tutorial on plugin development in VB.NET:
https://smath.com/wiki/GetFile.aspx?File=Developer%20Guide/Tutorial%20on%20creating%20plugin%20for%20Smath.pdf
I have not reached a glorious conclusion yet, however even now I can notice something to be incorrect (see screenshot).
Could someone please point out what I am doing wrong? Please keep in mind that I have never attempted to piece few lines of code together before and hence might miss obvious things. I am attaching my project folder.
Thanks!
1 users liked this post
Davide Carpi 4/2/2015 9:04:00 AM
#2 Posted: 3/13/2015 6:11:56 AM
The function argument is ByRef context As SMath.Math.Store -> change it into ByRef store As SMath.Math.Store (or change the store variables into context)
use Operators instead of Operator
use Operators instead of Operator

If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#3 Posted: 3/16/2015 12:55:25 PM
Thank you, Davide - I am just trying to get the tutorial working before I start tinkering with anything else..
Also what I am trying to do here is to come up with a plugin that will write array of data to excel using Interop.Excel to any sheet/cell (it will recalculate the file after transfer automatically). I have looked at enough tutorials to believe that I should be able to make it work once I figure out how to read array of data from SMath to VB in a form similar to:
Dim values(,) As Integer = _
{ _
{2, 4, 6}, _
{3, 6, 9}, _
{4, 8, 12}, _
{5, 10, 15} _
}
Also, back to plugin tutorial..Now how about this one:
Thank you!!

Also what I am trying to do here is to come up with a plugin that will write array of data to excel using Interop.Excel to any sheet/cell (it will recalculate the file after transfer automatically). I have looked at enough tutorials to believe that I should be able to make it work once I figure out how to read array of data from SMath to VB in a form similar to:
Dim values(,) As Integer = _
{ _
{2, 4, 6}, _
{3, 6, 9}, _
{4, 8, 12}, _
{5, 10, 15} _
}
Also, back to plugin tutorial..Now how about this one:
Thank you!!
#4 Posted: 3/16/2015 2:31:01 PM
You have to delete the third argument (old syntax, I guess)
As for the processing, you have to use the low-level evaluation or the numeric/symbolic evaluation. Some examples are in several plugins (f.e. something is in the wrapper of the GPC wrapper)

New TermInfo("combin", TermType.Function, "(n, k) ‐ Returns the number of subsets (combinations) of k elements that can be formed from n elements.", FunctionSection.Unknown, True)
As for the processing, you have to use the low-level evaluation or the numeric/symbolic evaluation. Some examples are in several plugins (f.e. something is in the wrapper of the GPC wrapper)
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#5 Posted: 3/24/2015 6:52:01 PM
Davide,
So i got to a point where my plugin can import / export single cell with recalculation (heavily influenced by the code of Alexander Antonov and Andrey Ivashov).
My end goal is to get a function like the following (keep in mind I intend to use excel as a data processing tool):
excel_IO(save y/n,workbook, sheet, input value, input cell, output range start, output range end)
Few questions to you, or to anyone who can help:
1. is there an already proven way to convert SMath matrix into a VB.net array that can be assigned to a cell range? The array might contain elements that are text, decimal or integers.
2. How about a reverse operation from (1), i.e. output VB.net string array to SMath matrix?
3. When specifying a path to excel file, how can I avoid using absolute references (i.e. I want to specify path with respect to the root folder of SMath workbook)
More questions will come as I proceed with the code (which I write during my sparse free time).
Thanks!
P.S.: Possibilities of the excel.interop are truly exiting - you can even (theoretically) connect to running excel process (should speed up things a bit if you are feeding bunch variable sets to a single excel file for the sole purpose of generating output)
So i got to a point where my plugin can import / export single cell with recalculation (heavily influenced by the code of Alexander Antonov and Andrey Ivashov).
My end goal is to get a function like the following (keep in mind I intend to use excel as a data processing tool):
excel_IO(save y/n,workbook, sheet, input value, input cell, output range start, output range end)
Few questions to you, or to anyone who can help:
1. is there an already proven way to convert SMath matrix into a VB.net array that can be assigned to a cell range? The array might contain elements that are text, decimal or integers.
2. How about a reverse operation from (1), i.e. output VB.net string array to SMath matrix?
3. When specifying a path to excel file, how can I avoid using absolute references (i.e. I want to specify path with respect to the root folder of SMath workbook)
More questions will come as I proceed with the code (which I write during my sparse free time).
Thanks!
P.S.: Possibilities of the excel.interop are truly exiting - you can even (theoretically) connect to running excel process (should speed up things a bit if you are feeding bunch variable sets to a single excel file for the sole purpose of generating output)
#6 Posted: 3/25/2015 5:51:41 AM
Wonderful,
As for the arrays, take a look at the code of the XlsxImportExport plugin (import,export). Is C# but you can convert it easily to VB.NET
The relative path can be built using the store.FileName property (an example is in the export routine above)
As for the arrays, take a look at the code of the XlsxImportExport plugin (import,export). Is C# but you can convert it easily to VB.NET
The relative path can be built using the store.FileName property (an example is in the export routine above)
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#7 Posted: 3/28/2015 5:56:06 AM
Davide, I have successfully created a function that exports range of cells from SMath to excel with recalculation. Plugin can connect to already opened excel file if desired.
I am working on import function right now. I am pretty much done except for a frustrating circumstance - I do not know what result to return back to SMath (assuming I have a 2D array of objects).
I tried sending back string of mat(#,#,#,#,#,#,2,3) assuming it will spit out a matrix, however it does not work. I assume that code below is the answer, however I am having trouble interpreting what exactly it is doing and what would be its VB.net equivalent. Please help whenever you have time.
I am working on import function right now. I am pretty much done except for a frustrating circumstance - I do not know what result to return back to SMath (assuming I have a 2D array of objects).
I tried sending back string of mat(#,#,#,#,#,#,2,3) assuming it will spit out a matrix, however it does not work. I assume that code below is the answer, however I am having trouble interpreting what exactly it is doing and what would be its VB.net equivalent. Please help whenever you have time.
Quoteforeach (string matValue in selectionContent)
{
myResult.AddRange(SMath.Manager.Converter.ToTerms(matValue));
}
myResult.AddRange(SMath.Manager.Converter.ToTerms(selectionHeight.ToString()));
myResult.AddRange(SMath.Manager.Converter.ToTerms(selectionWidth.ToString()));
myResult.Add(new Term(Functions.Mat, TermType.Function, 2 + (selectionHeight * selectionWidth)));
// output to SMath
return Decision.Preprocessing(myResult.ToArray(), ref context);
}
#8 Posted: 3/28/2015 1:51:15 PM
Yes the answer is that piece of code; this is converted by my IDE
matValue must be in SMath format (###*10^### instead of ###E### and the decimal symbol used in your worksheet instead of the standard period)
' return selectionContent values to SMath
Dim myResult As New List(Of Term)()
For Each matValue As String In selectionContent
myResult.AddRange(SMath.Manager.Converter.ToTerms(matValue))
Next
myResult.AddRange(SMath.Manager.Converter.ToTerms(selectionHeight.ToString()))
myResult.AddRange(SMath.Manager.Converter.ToTerms(selectionWidth.ToString()))
myResult.Add(New Term(Functions.Mat, TermType.[Function], 2 + (selectionHeight * selectionWidth)))
' output to SMath
Return Decision.Preprocessing(myResult.ToArray(), context)
matValue must be in SMath format (###*10^### instead of ###E### and the decimal symbol used in your worksheet instead of the standard period)
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#9 Posted: 4/2/2015 3:09:01 AM
I have completed my EXCEL I/O plugin with recalculation (Davide, thank you for your help!). Now its time to catch some bugs! (if any). Sample excel file, smath workbook is provided to test plugins functionality.
I have started by using this plugin:
https://smath.info/svn/public/plugins/ExcelIOCom/
World Wide Web turned out to be helpful and within a week or so I have learned more about COM excel plugins that I probably wanted to - it will be quite difficult to pinpoint where parts of the code came from.I have also used some code from Davide's export plugin to output excel range back to SMath.
Three functions are added:
excel_in - export to excel (xlsx or xls)
excel_out - import from excel (xlsx or xls)
excel_IO - in memory real-time data exchange with EXCEL - meant to use excel as a data crunching tool, while input is supplied from SMath (when works as intended is extremely fast).
Please catch some bugs!
P.S.: I guess i can code VB.NET if i really want to - surprise/surprise
XLSXupdate.zip (22 KiB) downloaded 35 time(s).
I have started by using this plugin:
https://smath.info/svn/public/plugins/ExcelIOCom/
World Wide Web turned out to be helpful and within a week or so I have learned more about COM excel plugins that I probably wanted to - it will be quite difficult to pinpoint where parts of the code came from.I have also used some code from Davide's export plugin to output excel range back to SMath.
Three functions are added:
excel_in - export to excel (xlsx or xls)
excel_out - import from excel (xlsx or xls)
excel_IO - in memory real-time data exchange with EXCEL - meant to use excel as a data crunching tool, while input is supplied from SMath (when works as intended is extremely fast).
Please catch some bugs!
P.S.: I guess i can code VB.NET if i really want to - surprise/surprise
XLSXupdate.zip (22 KiB) downloaded 35 time(s).
1 users liked this post
Davide Carpi 4/2/2015 9:03:00 AM
#10 Posted: 4/2/2015 7:32:34 AM
Wonderful! Just to mention it, I think Office 2010 or later is required (the screenshot below was made using Office 2002)
P.S. the english version of the message is "Could not load file or assembly 'Microsoft.Office. [...]"
![2015-04-02 12_32_01-SMath Studio Desktop - [Page1.sm_].png](/en-US/file/K6PqnB/2015-04-02-12_32_01-SMath-Studio-Desktop---_Page1_sm___png)
P.S. the english version of the message is "Could not load file or assembly 'Microsoft.Office. [...]"
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#11 Posted: 4/2/2015 10:28:29 AM
Davide,
I have re-built the plugin with excel 2003 PIA, see attached.. Which might not work for Excel 2002 as I see. Once I found excel interop DLL for 2002 I can build using that.
So it seems that EXCEL PIA 2002 is not compatible with newer office (2003+). I am attaching both builds (could not test 2002 build since I have no 2002 excel installed).
EXCEL IO (2002+ PIA).zip (22 KiB) downloaded 35 time(s).
I have re-built the plugin with excel 2003 PIA, see attached.. Which might not work for Excel 2002 as I see. Once I found excel interop DLL for 2002 I can build using that.
So it seems that EXCEL PIA 2002 is not compatible with newer office (2003+). I am attaching both builds (could not test 2002 build since I have no 2002 excel installed).
EXCEL IO (2002+ PIA).zip (22 KiB) downloaded 35 time(s).
1 users liked this post
Davide Carpi 4/7/2015 5:01:00 AM
#12 Posted: 4/3/2015 3:21:49 PM
If anyone could test attached plugin it would be much appreciated. I have added one more function that is likely to be quite useful ;-). Office 2003+ is required...
EXCEL IO (2003+ PIA).zip (998 KiB) downloaded 43 time(s).
EXCEL IO (2003+ PIA).zip (998 KiB) downloaded 43 time(s).
1 users liked this post
Davide Carpi 4/7/2015 5:01:00 AM
#13 Posted: 1/30/2016 7:28:55 PM
WroteInteresting Thread.
Another side question -> You state that you have never coded, what did you use to learn how to create plugins in SMath, maybe I have not looked into this enough. Is there a simple example somewhere?
Sorry for sidetracking here.
Thanks.
I'm probably the definition of coding newbie - have not done it in any language ever before.
I started plug in development with this thread http://en.smath.info/forum/yaf_postst4318_SMath-Plugin-Tutorial---Need-Help-Please.aspx
Than I continued in http://en.smath.info/forum/yaf_postst4375_Plugin---EXCEL--2003--I-O-with-recalculation-and-export-to-PNG.aspx
follow through the example that is mentioned in the firstpost. At lea!t setup studio express 2010 complete with debug (seems to work with debug better than newer versions).
Once studio is up and running best to look at already working plug in for inspiration. I can provide you with working directory of my plug in that you can play with in visual studio. I did code in VB.net though and not C# which seems to be more popular on this forum.
once you see how code works (buy running debug step by step once for a simple function) you can easily modify it to do what you like.
Ask questions!
And it's pretty neat when you can add a feature to the software you like ;-)
1 Pages (13 items)
-
New Posts
-
No New Posts