1 страниц (7 вхождений)
Problem with AddDefinition - Сообщения
#1 Опубликовано: 12 лет назад
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 Опубликовано: 12 лет назад
#3 Опубликовано: 12 лет назад
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 Опубликовано: 12 лет назад

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 пользователям понравился этот пост
Edward Ulle 12 лет назад
#5 Опубликовано: 12 лет назад
w3b5urf3r
That worked. Thanks much.
That worked. Thanks much.
Ed
#6 Опубликовано: 12 лет назад
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 Опубликовано: 12 лет назад
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 пользователям понравился этот пост
Davide Carpi 12 лет назад
1 страниц (7 вхождений)
-
Новые сообщения
-
Нет новых сообщений