Rank: Advanced Member Groups: Registered
Joined: 04/07/2010(UTC) Posts: 178 Was thanked: 19 time(s) in 13 post(s)
|
I was resurrecting my WizFunctions for use with the newer version of SMath Studio and code that used to work now doesn't. The problem seems to be with Store.AddDefinition. Possible causes are Definition.IsFunction has no object reference but is ReadOnly so no way to set it. Or AddDefinition variables() needs to be initialized and I don't have a clue to what. Any suggestions would be appreciated. Thanks. [Moderator] Moved.Edited by moderator 18 August 2013 18:11:05(UTC)
| Reason: Not specified |
Ed |
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,648 Location: Italy Was thanked: 1332 time(s) in 876 post(s)
|
Hi TheWizEd Here and here you can see some updated store.AddDefinition examples Best regards, Davide |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 04/07/2010(UTC) Posts: 178 Was thanked: 19 time(s) in 13 post(s)
|
w3b5urf3r I looked at your examples and at least now it doesn't crash but it's not storing the variable. What am i doing wrong? Its in "zsival(vname,value)". My idea is to be able to set variables from a source other than SMath Studio, such as a file. Code: Public Function ExpressionEvaluation(root As SMath.Manager.Term, args()() As SMath.Manager.Term, ByRef context As SMath.Math.Store, ByRef result() As SMath.Manager.Term) As Boolean Implements SMath.Math.IPluginLowLevelEvaluation.ExpressionEvaluation
Dim bResult As Boolean
Dim sValue As String
Dim dTerms As Term()
Dim tTerms(0) As Term
Dim answer As New List(Of Term)
Dim i As Integer
Dim j As Integer
bResult = False
sValue = ""
If root.Type = TermType.Function And root.Text = "ztest" Then
For i = args.GetLowerBound(0) To args.GetUpperBound(0)
sValue = sValue + "i=" + Str(i) + ": "
For j = args(i).GetLowerBound(0) To args(i).GetUpperBound(0)
sValue = sValue + " j=" + Str(j) + ": <" + args(i)(j).ToString + ">"
Next
dTerms = Decision.Preprocessing(args(i), context)
sValue = sValue + vbCrLf + "i=" + Str(i) + ": "
sValue = sValue + ListTerms(dTerms)
Next
MsgBox(sValue)
answer.AddRange(Converter.ToTerms("1"))
result = answer.ToArray()
bResult = True
ElseIf root.Type = TermType.Function And root.Text = "zsival" Then
dTerms = Decision.Preprocessing(args(1), context)
MsgBox(ListTerms(dTerms))
context.AddDefinition(args(0)(0).ToString, dTerms, tTerms)
answer.AddRange(dTerms)
result = answer.ToArray()
bResult = True
End If
Return bResult
End Function
|
Ed |
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,648 Location: Italy Was thanked: 1332 time(s) in 876 post(s)
|
try using: instead of: |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
1 user thanked Davide Carpi for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 04/07/2010(UTC) Posts: 178 Was thanked: 19 time(s) in 13 post(s)
|
w3b5urf3r
That worked. Thanks much. |
Ed |
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,648 Location: Italy Was thanked: 1332 time(s) in 876 post(s)
|
You're welcome, I'm glad to see you back in action Best regards, Davide |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 04/07/2010(UTC) Posts: 178 Was thanked: 19 time(s) in 13 post(s)
|
Not sure if it matters but I made some minor changes to my code so an instance of the empty Term array was created instead of using the local variable array. Replaced with Code:
Dim tTerms As Term()
tTerms = New Term() {}
context.AddDefinition(args(0)(0).ToString, dTerms, tTerms)
|
Ed |
1 user thanked TheWizEd for this useful post.
|
|
|
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.