1 Pages (7 items)
Problem with AddDefinition - Messages
#1 Posted: 8/18/2013 10:41:53 AM
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.
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.
Ed
#2 Posted: 8/18/2013 10:57:06 AM
#3 Posted: 8/18/2013 6:02:32 PM
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.
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.
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
#4 Posted: 8/18/2013 8:34:50 PM

Dim tTerms(-1) As Term
instead of:
Dim tTerms(0) As Term
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 users liked this post
Edward Ulle 8/18/2013 11:47:00 PM
#5 Posted: 8/18/2013 11:46:24 PM
w3b5urf3r
That worked. Thanks much.
That worked. Thanks much.
Ed
#6 Posted: 8/19/2013 4:37:50 AM
You're welcome, I'm glad to see you back in action
Best regards,
Davide

Best regards,
Davide
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#7 Posted: 8/19/2013 11:58:51 PM
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
Replaced
Dim tTerms(-1) As Term
with
Dim tTerms As Term()
tTerms = New Term() {}
context.AddDefinition(args(0)(0).ToString, dTerms, tTerms)
Ed
1 users liked this post
Davide Carpi 8/20/2013 4:38:00 AM
1 Pages (7 items)
-
New Posts
-
No New Posts