Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline Alex M.  
#1 Posted : 13 March 2015 01:42:55(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Good day,

I am attempting to follow through tutorial on plugin development in VB.NET:
http://smath.info/wiki/G...plugin%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!
File Attachment(s):
XLSXupdate.zip (220kb) downloaded 22 time(s).
Alex M. attached the following image(s):
VB.png
thanks 1 user thanked Alex M. for this useful post.
on 02/04/2015(UTC)

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline Davide Carpi  
#2 Posted : 13 March 2015 12:11:56(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
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 Good
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline Alex M.  
#3 Posted : 16 March 2015 18:55:25(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
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!!

Edited by user 16 March 2015 19:11:52(UTC)  | Reason: Not specified

Alex M. attached the following image(s):
VB2.png
Offline Davide Carpi  
#4 Posted : 16 March 2015 20:31:01(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
You have to delete the third argument (old syntax, I guess)

Code:
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)

Edited by user 17 March 2015 19:27:08(UTC)  | Reason: Not specified

Davide Carpi attached the following image(s):
2015-03-16 18_26_50-SMath Studio Core documentation.png
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline Alex M.  
#5 Posted : 25 March 2015 00:52:01(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
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)

Edited by user 25 March 2015 03:45:08(UTC)  | Reason: Not specified

Offline Davide Carpi  
#6 Posted : 25 March 2015 11:51:41(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
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)

Edited by user 25 March 2015 15:08:00(UTC)  | Reason: Not specified

If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline Alex M.  
#7 Posted : 28 March 2015 11:56:06(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
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.

Quote:
foreach (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);
}
Offline Davide Carpi  
#8 Posted : 28 March 2015 19:51:15(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
Yes the answer is that piece of code; this is converted by my IDE

Code:
' 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)

Edited by user 28 March 2015 20:00:02(UTC)  | Reason: Not specified

If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline Alex M.  
#9 Posted : 02 April 2015 09:09:01(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
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

Edited by user 02 April 2015 09:26:32(UTC)  | Reason: Not specified

File Attachment(s):
XLSXupdate.zip (23kb) downloaded 21 time(s).
thanks 1 user thanked Alex M. for this useful post.
on 02/04/2015(UTC)
Offline Davide Carpi  
#10 Posted : 02 April 2015 13:32:34(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
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. [...]"

Edited by user 02 April 2015 13:41:23(UTC)  | Reason: Not specified

Davide Carpi attached the following image(s):
2015-04-02 12_32_01-SMath Studio Desktop - [Page1.sm_].png
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline Alex M.  
#11 Posted : 02 April 2015 16:28:29(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
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).

Edited by user 02 April 2015 21:32:05(UTC)  | Reason: Not specified

File Attachment(s):
EXCEL IO (2002 PIA).zip (23kb) downloaded 17 time(s).
EXCEL IO (2002+ PIA).zip (23kb) downloaded 17 time(s).
thanks 1 user thanked Alex M. for this useful post.
on 07/04/2015(UTC)
Offline Alex M.  
#12 Posted : 03 April 2015 21:21:49(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
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...

Edited by user 03 April 2015 21:23:35(UTC)  | Reason: Not specified

File Attachment(s):
EXCEL IO (2003+ PIA).zip (999kb) downloaded 26 time(s).
thanks 1 user thanked Alex M. for this useful post.
on 07/04/2015(UTC)
Offline Alex M.  
#13 Posted : 31 January 2016 01:28:55(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Originally Posted by: RFreund Go to Quoted Post
Interesting 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/for...---Need-Help-Please.aspx

Than I continued in http://en.smath.info/for...n-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 ;-)

Edited by user 31 January 2016 01:39:19(UTC)  | Reason: Not specified

Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.